Skip to content

Commit

Permalink
chore: separate e2e and unit tests
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>
  • Loading branch information
hacdias committed Sep 2, 2019
1 parent 4036ea9 commit 8b90b9a
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 16 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ before_script:
fi
script:
- npm run test
- npm run lint
- npm run test
- npm run test:e2e
- npm run build

notifications:
Expand Down
3 changes: 2 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ install:
- npm install

build_script:
- npm run test
- npm run lint
- npm run test
- npm run test:e2e
- npm run build

test: off
27 changes: 27 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"scripts": {
"start": "cross-env NODE_ENV=development electron -r @babel/register src/index.js",
"lint": "standard",
"test": "cross-env NODE_ENV=test mocha -r @babel/register",
"test": "cross-env NODE_ENV=test mocha test/unit/**/*.spec.js -r @babel/register",
"test:e2e": "xvfb-maybe cross-env NODE_ENV=test mocha test/e2e/**/*.e2e.js -r @babel/register",
"postinstall": "run-s install-app-deps build:webui",
"install-app-deps": "electron-builder install-app-deps",
"clean:webui": "shx rm -rf assets/webui/",
Expand Down Expand Up @@ -70,7 +71,8 @@
"spectron": "^8.0.0",
"standard": "^14.1.0",
"tar": "^4.4.10",
"tmp": "0.1.0"
"tmp": "0.1.0",
"xvfb-maybe": "^0.2.1"
},
"dependencies": {
"@babel/runtime": "^7.5.5",
Expand Down
2 changes: 1 addition & 1 deletion test/launch.spec.js → test/e2e/launch.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('Application launch', function () {
}) {
app = new Application({
path: electronPath,
args: ['-r', path.join(__dirname, 'utils/include.js'), path.join(__dirname, '../src/index.js')],
args: ['-r', path.join(__dirname, 'utils/include.js'), path.join(__dirname, '../../src/index.js')],
env: {
NODE_ENV: 'test',
HOME: home,
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('Create toggler', () => {
electron = mockElectron()
store = mockStore()
webui = mockWebUI()
createToggler = proxyquire('../src/create-toggler', {
createToggler = proxyquire('../../src/create-toggler', {
electron: electron,
'./common/store': store
}).default
Expand Down
20 changes: 10 additions & 10 deletions test/dock.spec.js → test/unit/dock.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ chai.use(dirtyChai)
describe('Dock', () => {
it('show dock succeeds with dock (macOS)', () => {
const electron = mockElectron({ withDock: true })
const { show } = proxyquire('../src/dock', { electron }).default
const { show } = proxyquire('../../src/dock', { electron }).default
show()
expect(electron.app.dock.show.callCount).to.equal(1)
})

it('show dock succeeds without dock (other OSes)', () => {
const electron = mockElectron()
const { show } = proxyquire('../src/dock', { electron }).default
const { show } = proxyquire('../../src/dock', { electron }).default
show()
})

it('hide dock succeeds with dock and no windows (macOS)', () => {
const electron = mockElectron({ withDock: true })
electron.BrowserWindow.getAllWindows.returns([])
const { hide } = proxyquire('../src/dock', { electron }).default
const { hide } = proxyquire('../../src/dock', { electron }).default
hide()
expect(electron.app.dock.hide.callCount).to.equal(1)
})
Expand All @@ -40,7 +40,7 @@ describe('Dock', () => {
{ isVisible: sinon.stub().returns(false) }
]
electron.BrowserWindow.getAllWindows.returns(windows)
const { hide } = proxyquire('../src/dock', { electron }).default
const { hide } = proxyquire('../../src/dock', { electron }).default
hide()
expect(windows[0].isVisible.callCount).to.equal(1)
expect(windows[1].isVisible.callCount).to.equal(1)
Expand All @@ -54,7 +54,7 @@ describe('Dock', () => {
{ isVisible: sinon.stub().returns(false) }
]
electron.BrowserWindow.getAllWindows.returns(windows)
const { hide } = proxyquire('../src/dock', { electron }).default
const { hide } = proxyquire('../../src/dock', { electron }).default
hide()
expect(windows[0].isVisible.callCount).to.equal(1)
expect(windows[1].isVisible.callCount).to.equal(1)
Expand All @@ -63,14 +63,14 @@ describe('Dock', () => {

it('hide dock succeeds without dock (other OSes)', () => {
const electron = mockElectron()
const { hide } = proxyquire('../src/dock', { electron }).default
const { hide } = proxyquire('../../src/dock', { electron }).default
hide()
})

it('runs async function with dock (macOS)', async () => {
const electron = mockElectron({ withDock: true })
electron.BrowserWindow.getAllWindows.returns([])
const { run } = proxyquire('../src/dock', { electron }).default
const { run } = proxyquire('../../src/dock', { electron }).default
const fn = sinon.stub().resolves(5)
const res = await run(fn)
expect(res).to.equal(5)
Expand All @@ -82,7 +82,7 @@ describe('Dock', () => {
it('runs async function without dock (other OSes)', async () => {
const electron = mockElectron()
electron.BrowserWindow.getAllWindows.returns([])
const { run } = proxyquire('../src/dock', { electron }).default
const { run } = proxyquire('../../src/dock', { electron }).default
const fn = sinon.stub().resolves(5)
const res = await run(fn)
expect(res).to.equal(5)
Expand All @@ -91,7 +91,7 @@ describe('Dock', () => {
it('runs sync function with dock (macOS)', () => {
const electron = mockElectron({ withDock: true })
electron.BrowserWindow.getAllWindows.returns([])
const { runSync } = proxyquire('../src/dock', { electron }).default
const { runSync } = proxyquire('../../src/dock', { electron }).default
const fn = sinon.stub().returns(5)
const res = runSync(fn)
expect(res).to.equal(5)
Expand All @@ -103,7 +103,7 @@ describe('Dock', () => {
it('runs sync function without dock (other OSes)', () => {
const electron = mockElectron()
electron.BrowserWindow.getAllWindows.returns([])
const { runSync } = proxyquire('../src/dock', { electron }).default
const { runSync } = proxyquire('../../src/dock', { electron }).default
const fn = sinon.stub().returns(5)
const res = runSync(fn)
expect(res).to.equal(5)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 8b90b9a

Please sign in to comment.