mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-23 11:16:39 +00:00
test(spectron): Refactor tests, dereference app after use
Change-Type: patch
This commit is contained in:
parent
58f7811c7d
commit
c9a2a47ee1
@ -1,35 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2017 resin.io
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
'use strict'
|
|
||||||
|
|
||||||
const m = require('mochainon')
|
|
||||||
|
|
||||||
module.exports = () => {
|
|
||||||
describe('Browser Window', function () {
|
|
||||||
it('should set a proper title', function () {
|
|
||||||
return this.app.client.getTitle().then((title) => {
|
|
||||||
m.chai.expect(title).to.equal('Etcher')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should open a browser window', function () {
|
|
||||||
return this.app.browserWindow.isVisible().then((isVisible) => {
|
|
||||||
m.chai.expect(isVisible).to.be.true
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
const Bluebird = require('bluebird')
|
const Bluebird = require('bluebird')
|
||||||
const spectron = require('spectron')
|
const spectron = require('spectron')
|
||||||
|
const m = require('mochainon')
|
||||||
const EXIT_CODES = require('../../lib/shared/exit-codes')
|
const EXIT_CODES = require('../../lib/shared/exit-codes')
|
||||||
const entrypoint = process.env.ETCHER_SPECTRON_ENTRYPOINT
|
const entrypoint = process.env.ETCHER_SPECTRON_ENTRYPOINT
|
||||||
|
|
||||||
@ -30,22 +31,40 @@ describe('Spectron', function () {
|
|||||||
// Mainly for CI jobs
|
// Mainly for CI jobs
|
||||||
this.timeout(20000)
|
this.timeout(20000)
|
||||||
|
|
||||||
beforeEach(function () {
|
let app = null
|
||||||
this.app = new spectron.Application({
|
|
||||||
|
before('app:start', function () {
|
||||||
|
app = new spectron.Application({
|
||||||
path: entrypoint,
|
path: entrypoint,
|
||||||
args: [ '.' ]
|
args: [ '.' ]
|
||||||
})
|
})
|
||||||
|
|
||||||
return this.app.start()
|
return app.start()
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(function () {
|
after('app:stop', function () {
|
||||||
if (this.app && this.app.isRunning()) {
|
if (app && app.isRunning()) {
|
||||||
return this.app.stop()
|
return app.stop()
|
||||||
}
|
}
|
||||||
|
|
||||||
return Bluebird.resolve()
|
return Bluebird.resolve()
|
||||||
})
|
})
|
||||||
|
|
||||||
require('./browser-window')()
|
after('app:deref', function () {
|
||||||
|
app = null
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('Browser Window', function () {
|
||||||
|
it('should open a browser window', function () {
|
||||||
|
return app.browserWindow.isVisible().then((isVisible) => {
|
||||||
|
m.chai.expect(isVisible).to.be.true
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should set a proper title', function () {
|
||||||
|
return app.client.getTitle().then((title) => {
|
||||||
|
m.chai.expect(title).to.equal('Etcher')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user