Skip to content
Permalink
Browse files

Added tests set up and main browser window test

  • Loading branch information...
smpadhy committed Feb 7, 2017
1 parent 3b6338b commit b78baf89c4c9124a6464121a513c635a98987fda
Showing with 90 additions and 6 deletions.
  1. +7 −2 package.json
  2. +2 −3 src/index.html
  3. +1 −1 src/main.js
  4. +46 −0 tests/global-setup.js
  5. +34 −0 tests/mainWindow-test.js
@@ -4,13 +4,18 @@
"description": "",
"main": "src/main.js",
"scripts": {
"start": "electron ."
"start": "electron .",
"test:e2e": "./node_modules/mocha/bin/mocha tests/mainWindow-test.js"
},
"keywords": [],
"author": "Smruti Padhy",
"license": "MIT",
"devDependencies": {
"electron": "^1.4.11"
"chai": "^3.5.0",
"chai-as-promised": "^6.0.0",
"electron": "^1.4.11",
"mocha": "^3.2.0",
"spectron": "^3.5.0"
},
"dependencies": {
"bootstrap": "^3.3.7",
@@ -61,8 +61,8 @@ <h1>BrainVerse</h1>
<p> Collaborative Electronic Laboratory Notebook</p>
<p><a class="btn btn-primary btn-lg" href="https://github.com/ReproNim/brainverse" role="button">Learn more &raquo;</a></p>
</div>
<p><a class="btn btn-primary btn-lg" href="addProject.html" role="button"> Add a Project &raquo;</a></p>
<p><a class="btn btn-primary btn-lg" href="addExperiment.html" role="button"> Add an Experiment &raquo;</a></p>
<p><a class="btn btn-primary btn-lg" href="addProject.html" role="button" id="addProjectButton"> Add a Project </a></p>
<p><a class="btn btn-primary btn-lg" href="addExperiment.html" role="button" id="addExperimentButton"> Add an Experiment </a></p>
</div>
</div>
</div>
@@ -73,4 +73,3 @@ <h1>BrainVerse</h1>
</script>
</body>
</html>

@@ -22,7 +22,7 @@ function createWindow () {
}))

// Open the DevTools.
mainWindow.webContents.openDevTools()
//mainWindow.webContents.openDevTools()

// Emitted when the window is closed.
mainWindow.on('closed', function () {
@@ -0,0 +1,46 @@
/*
* Global test set up in BrainVerse
* Adapted from spectron tests example:
* https://github.com/electron/spectron/blob/master/test/global-setup.js
*
*/
const Application = require('spectron').Application
const assert = require('assert')
const chai = require('chai')
const chaiAsPromised = require('chai-as-promised')
const path = require('path')

global.before(function () {
chai.should()
chai.use(chaiAsPromised)
})

exports.getElectronPath = function () {
let electronPath = path.join(__dirname, '..', 'node_modules', '.bin', 'electron')
if (process.platform === 'win32') electronPath += '.cmd'
return electronPath
}

exports.getAppPath = function () {
return path.join(__dirname, '..')
}

exports.startApplication = function (options) {
options.path = exports.getElectronPath()
options.args = [exports.getAppPath()]
console.log(options)
var app = new Application(options)
return app.start().then(function () {
assert.equal(app.isRunning(), true)
chaiAsPromised.transferPromiseness = app.transferPromiseness
return app
})
}

exports.stopApplication = function (app) {
if (!app || !app.isRunning()) return

return app.stop().then(function () {
assert.equal(app.isRunning(), false)
})
}
@@ -0,0 +1,34 @@
const helpers = require('./global-setup')

describe('Main BrowserWindow Test', function () {
let app = null

before(function(){
return helpers.startApplication({}).then(function (startedApp) {app = startedApp})
})

after(function () {
return helpers.stopApplication(app)
})

it('opens a window', function () {
return app.client.waitUntilWindowLoaded()
.getWindowCount().should.eventually.equal(1)
})
it('gets a title', function () {
return app.client.waitUntilWindowLoaded()
.getTitle().should.eventually.equal('BrainVerse')
})
it('checks for add-project button', function () {
return app.client.waitUntilWindowLoaded()
.isExisting('#addProjectButton').should.eventually.equal(true).then(function(){
return app.client.getText('#addProjectButton').should.eventually.equal('Add a Project')
})
})
it('checks for add-experiment button', function () {
return app.client.waitUntilWindowLoaded()
.isExisting('#addExperimentButton').should.eventually.equal(true).then(function(){
return app.client.getText('#addExperimentButton').should.eventually.equal('Add an Experiment')
})
})
})

0 comments on commit b78baf8

Please sign in to comment.
You can’t perform that action at this time.