🔥 added test

This commit is contained in:
akashnimare
2016-09-10 07:57:09 +05:30
parent 05d483b44c
commit f1a5bfcabf
3 changed files with 43 additions and 3 deletions

View File

@@ -1,5 +1,6 @@
'use strict';
const gulp = require('gulp');
const mocha = require('gulp-mocha');
const electron = require('electron-connect').server.create({
verbose: true
});
@@ -27,4 +28,8 @@ gulp.task('reload:renderer', done => {
done();
});
gulp.task('default', ['dev']);
gulp.task('test', () => {
return gulp.src('tests/index.js').pipe(mocha());
});
gulp.task('default', ['dev', 'test']);

View File

@@ -13,8 +13,8 @@
},
"main": "app/main/index.js",
"scripts": {
"test": "xo",
"start": "electron .",
"test": "gulp test && xo",
"dev": "gulp dev",
"build:osx": "electron-packager . --out=dist --app-version=$npm_package_version --prune --asar --icon=app/resources/Icon.icns --overwrite --platform=darwin --arch=x64",
"build": "electron-packager . --out=dist --app-version=$npm_package_version --prune --asar --overwrite --all"
@@ -26,12 +26,14 @@
"electron"
],
"dependencies": {
"assert": "^1.4.1",
"configstore": "^2.0.0",
"dialogs": "1.1.14",
"electron-context-menu": "0.4.0",
"electron-debug": "^1.0.0",
"electron-dl": "^0.2.0",
"electron-localshortcut": "^0.6.1",
"gulp-mocha": "^3.0.1",
"node-json-db": "^0.7.2",
"request": "^2.74.0",
"simple-spellchecker": "^0.9.0",
@@ -43,6 +45,7 @@
"electron-connect": "^0.4.6",
"electron-packager": "^7.0.0",
"gulp": "^3.9.1",
"spectron": "^3.3.0",
"xo": "*"
},
"xo": {
@@ -59,9 +62,13 @@
}
}
],
"ignore": [
"tests/*.js"
],
"envs": [
"node",
"browser"
"browser",
"mocha"
]
}
}

28
tests/index.js Normal file
View File

@@ -0,0 +1,28 @@
/* eslint semi: ["error", "never"]*/
const assert = require('assert')
const Application = require('spectron').Application
describe('application launch', function () {
this.timeout(10000)
beforeEach(function () {
this.app = new Application({
path: __dirname + '/../node_modules/.bin/electron',
args: [__dirname + '/../app/main/index.js']
})
return this.app.start()
})
afterEach(function () {
if (this.app && this.app.isRunning()) {
return this.app.stop()
}
})
it('shows an initial window', function () {
return this.app.client.getWindowCount().then(function (count) {
assert.equal(count, 1)
})
})
})