4 changed files with 68 additions and 31 deletions
@ -1,28 +0,0 @@
|
||||
// A simple test to verify a visible window is opened with a title
|
||||
var Application = require('spectron').Application |
||||
var assert = require('assert') |
||||
|
||||
var app = new Application({ |
||||
path: 'dist/Rambox-linux-x64/Rambox' |
||||
}) |
||||
|
||||
app.start().then(function () { |
||||
// Check if the window is visible
|
||||
return app.browserWindow.isVisible() |
||||
}).then(function (isVisible) { |
||||
// Verify the window is visible
|
||||
assert.equal(isVisible, true) |
||||
}).then(function () { |
||||
// Get the window's title
|
||||
return app.client.getTitle() |
||||
}).then(function (title) { |
||||
// Verify the window's title
|
||||
assert.equal(title, 'Ramboxx') |
||||
}).then(function () { |
||||
// Stop the application
|
||||
return app.stop() |
||||
}).catch(function (error) { |
||||
// Log any failures
|
||||
console.error('Test failed', error.message) |
||||
return app.stop() |
||||
}) |
@ -0,0 +1,38 @@
|
||||
|
||||
var Application = require('spectron').Application; |
||||
var electron = require('electron-prebuilt'); |
||||
|
||||
/** |
||||
* The RamboxTestHelper contains common stuff for tests. |
||||
*/ |
||||
module.exports = function() { |
||||
|
||||
var self = this; |
||||
|
||||
/** |
||||
* Makes the Rambox Application available. |
||||
* |
||||
* @type {Application} |
||||
*/ |
||||
self.app = null; |
||||
|
||||
/** |
||||
* Starts Rambox from '/electron/main.js/'. |
||||
*/ |
||||
beforeEach(function() { |
||||
self.app = new Application({ |
||||
path: electron, |
||||
args: [__dirname + '/../../electron/main.js'] |
||||
}); |
||||
return self.app.start(); |
||||
}); |
||||
|
||||
/** |
||||
* Stops Rambox. |
||||
*/ |
||||
afterEach(function() { |
||||
if (self.app && self.app.isRunning()) { |
||||
return self.app.stop() |
||||
} |
||||
}); |
||||
}; |
@ -0,0 +1,24 @@
|
||||
/** |
||||
* This is an example test. |
||||
*/ |
||||
|
||||
var chai = require('chai'); |
||||
var expect = chai.expect; |
||||
var RamboxTestHelper = require('../../helpers/RamboxTestHelper'); |
||||
|
||||
describe('Rambox window', function() { |
||||
|
||||
/** |
||||
* The Rambox test helper does common stuff. |
||||
* |
||||
* @type {module.exports} |
||||
*/ |
||||
var ramboxTestHelper = new RamboxTestHelper(); |
||||
|
||||
it('should have "Rambox" in the title', function () { |
||||
return ramboxTestHelper.app.client.browserWindow.getTitle().then(function(title) { |
||||
expect(title).to.contain('Rambox'); |
||||
return Promise.resolve(); |
||||
}); |
||||
}) |
||||
}); |
Loading…
Reference in new issue