Destroy BrowserViews after each test

This commit is contained in:
Birunthan Mohanathas 2017-04-13 00:52:07 +03:00
parent 06fcf2c19d
commit ccdeb4746e

View file

@ -8,6 +8,7 @@ const {BrowserView, BrowserWindow} = remote
describe('View module', function () { describe('View module', function () {
var w = null var w = null
var view = null
beforeEach(function () { beforeEach(function () {
w = new BrowserWindow({ w = new BrowserWindow({
@ -21,17 +22,22 @@ describe('View module', function () {
}) })
afterEach(function () { afterEach(function () {
if (view) {
view.destroy()
view = null
}
return closeWindow(w).then(function () { w = null }) return closeWindow(w).then(function () { w = null })
}) })
describe('BrowserView.setBackgroundColor()', function () { describe('BrowserView.setBackgroundColor()', function () {
it('does not throw for valid args', function () { it('does not throw for valid args', function () {
const view = new BrowserView() view = new BrowserView()
view.setBackgroundColor('#000') view.setBackgroundColor('#000')
}) })
it('throws for invalid args', function () { it('throws for invalid args', function () {
const view = new BrowserView() view = new BrowserView()
assert.throws(function () { assert.throws(function () {
view.setBackgroundColor(null) view.setBackgroundColor(null)
}, /conversion failure/) }, /conversion failure/)
@ -40,13 +46,13 @@ describe('View module', function () {
describe('BrowserView.setAutoResize()', function () { describe('BrowserView.setAutoResize()', function () {
it('does not throw for valid args', function () { it('does not throw for valid args', function () {
const view = new BrowserView() view = new BrowserView()
view.setAutoResize({}) view.setAutoResize({})
view.setAutoResize({ width: true, height: false }) view.setAutoResize({ width: true, height: false })
}) })
it('throws for invalid args', function () { it('throws for invalid args', function () {
const view = new BrowserView() view = new BrowserView()
assert.throws(function () { assert.throws(function () {
view.setAutoResize(null) view.setAutoResize(null)
}, /conversion failure/) }, /conversion failure/)
@ -55,12 +61,12 @@ describe('View module', function () {
describe('BrowserView.setBounds()', function () { describe('BrowserView.setBounds()', function () {
it('does not throw for valid args', function () { it('does not throw for valid args', function () {
const view = new BrowserView() view = new BrowserView()
view.setBounds({ x: 0, y: 0, width: 1, height: 1 }) view.setBounds({ x: 0, y: 0, width: 1, height: 1 })
}) })
it('throws for invalid args', function () { it('throws for invalid args', function () {
const view = new BrowserView() view = new BrowserView()
assert.throws(function () { assert.throws(function () {
view.setBounds(null) view.setBounds(null)
}, /conversion failure/) }, /conversion failure/)
@ -72,12 +78,12 @@ describe('View module', function () {
describe('BrowserWindow.setBrowserView()', function () { describe('BrowserWindow.setBrowserView()', function () {
it('does not throw for valid args', function () { it('does not throw for valid args', function () {
const view = new BrowserView() view = new BrowserView()
w.setBrowserView(view) w.setBrowserView(view)
}) })
it('does not throw if called multiple times with same view', function () { it('does not throw if called multiple times with same view', function () {
const view = new BrowserView() view = new BrowserView()
w.setBrowserView(view) w.setBrowserView(view)
w.setBrowserView(view) w.setBrowserView(view)
w.setBrowserView(view) w.setBrowserView(view)