add tests for View and WebContentsView
This commit is contained in:
parent
3b81312cf7
commit
300c7a4b04
2 changed files with 39 additions and 0 deletions
14
spec/api-view-spec.js
Normal file
14
spec/api-view-spec.js
Normal file
|
@ -0,0 +1,14 @@
|
|||
'use strict'
|
||||
|
||||
const {closeWindow} = require('./window-helpers')
|
||||
const {TopLevelWindow, View} = require('electron').remote
|
||||
|
||||
describe('View', () => {
|
||||
let w = null
|
||||
afterEach(() => closeWindow(w).then(() => { w = null }))
|
||||
|
||||
it('can be used as content view', () => {
|
||||
w = new TopLevelWindow({show: false})
|
||||
w.setContentView(new View())
|
||||
})
|
||||
})
|
25
spec/api-web-contents-view-spec.js
Normal file
25
spec/api-web-contents-view-spec.js
Normal file
|
@ -0,0 +1,25 @@
|
|||
'use strict'
|
||||
|
||||
const assert = require('assert')
|
||||
const {closeWindow} = require('./window-helpers')
|
||||
const {webContents, TopLevelWindow, WebContentsView} = require('electron').remote
|
||||
|
||||
describe('WebContentsView', () => {
|
||||
let w = null
|
||||
afterEach(() => closeWindow(w).then(() => { w = null }))
|
||||
|
||||
it('can be used as content view', () => {
|
||||
const web = webContents.create({})
|
||||
w = new TopLevelWindow({show: false})
|
||||
w.setContentView(new WebContentsView(web))
|
||||
})
|
||||
|
||||
it('prevents adding same WebContents', () => {
|
||||
const web = webContents.create({})
|
||||
w = new TopLevelWindow({show: false})
|
||||
w.setContentView(new WebContentsView(web))
|
||||
assert.throws(() => {
|
||||
w.setContentView(new WebContentsView(web))
|
||||
}, /The WebContents has already been added to a View/)
|
||||
})
|
||||
})
|
Loading…
Reference in a new issue