Use spectron and ava for testing

This commit is contained in:
Leo Lamprecht 2016-09-22 08:08:56 +02:00
parent e30c49994f
commit de3c7d01e9
No known key found for this signature in database
GPG key ID: C251EE4DA454117B
4 changed files with 34 additions and 33 deletions

View file

@ -14,10 +14,8 @@
"dependencies": {
"aphrodite-simple": "0.4.1",
"color": "0.11.3",
"electron-mocha": "^3.0.0",
"hterm-umdjs": "1.1.3",
"json-loader": "0.5.4",
"mocha": "^3.0.0",
"mousetrap": "1.6.0",
"ms": "0.7.1",
"object-values": "1.0.0",
@ -30,10 +28,10 @@
"redux": "3.6.0",
"redux-thunk": "2.1.0",
"reselect": "2.5.4",
"seamless-immutable": "6.1.1",
"should": "^11.0.0"
"seamless-immutable": "6.1.1"
},
"devDependencies": {
"ava": "^0.16.0",
"babel-cli": "^6.11.4",
"babel-core": "^6.11.4",
"babel-loader": "^6.2.4",
@ -47,6 +45,7 @@
"eslint-plugin-react": "^6.2.2",
"husky": "^0.11.6",
"redux-logger": "^2.6.1",
"spectron": "^3.4.0",
"webpack": "^2.1.0-beta.15",
"xo": "^0.16.0"
},
@ -107,7 +106,7 @@
"start": "concurrently --kill-others --raw \"npm run dev\" \"electron app\"",
"dev": "webpack -w",
"build": "NODE_ENV=production webpack",
"test": "xo && electron-mocha test/*",
"test": "npm run pack && xo && ava",
"prepublish": "npm test",
"prepush": "npm test",
"postinstall": "install-app-deps",

View file

@ -1,23 +0,0 @@
/* eslint-disable prefer-arrow-callback */
require('../setup');
const {_toDependencies} = require('../../app/plugins');
describe('plugins', function () {
describe('#toDependencies()', function () {
it('should convert dependencies form hyperterm\'s format to npm\'s', function () {
const plugins = ['project1', 'project2#1.0.0', 'project3@beta',
'@org1/project4#1.0.0', '@org2/project5@alpha',
'@org3/project6'];
_toDependencies({plugins}).should.be.eql({
'project1': 'latest',
'project2': '1.0.0',
'project3': 'beta',
'@org1/project4': '1.0.0',
'@org2/project5': 'alpha',
'@org3/project6': 'latest'
});
});
});
});

30
test/index.js Normal file
View file

@ -0,0 +1,30 @@
// Native
import path from 'path';
// Packages
import test from 'ava';
import {Application} from 'spectron';
let app;
test.before(async () => {
app = new Application({
path: path.join(__dirname, '../dist/mac/HyperTerm.app/Contents/MacOS/HyperTerm')
});
await app.start();
});
test.after(async () => {
await app.stop();
});
test('check window count', async t => {
await app.client.waitUntilWindowLoaded();
t.is(await app.client.getWindowCount(), 4);
});
test('see if dev tools are open', async t => {
await app.client.waitUntilWindowLoaded();
t.false(await app.browserWindow.isDevToolsOpened());
});

View file

@ -1,5 +0,0 @@
require('should');
const config = require('../app/config');
config.init();