test: ensure legacy callback functions work (#16436)

* test: test legacy callback functions

* add TODO removal comments

* fix callback spec
This commit is contained in:
Shelley Vohr 2019-01-17 14:17:16 -08:00 committed by GitHub
parent 720197f9c8
commit f105c84349
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 114 additions and 9 deletions

View file

@ -483,7 +483,7 @@ describe('BrowserWindow module', () => {
})
})
describe('BrowserWindow.getFocusedWindow()', (done) => {
describe('BrowserWindow.getFocusedWindow()', () => {
it('returns the opener window when dev tools window is focused', (done) => {
w.show()
w.webContents.once('devtools-focused', () => {
@ -494,7 +494,7 @@ describe('BrowserWindow module', () => {
})
})
describe('BrowserWindow.capturePage(rect)', () => {
describe('BrowserWindow.capturePage(rect)', (done) => {
it('returns a Promise with a Buffer', async () => {
const image = await w.capturePage({
x: 0,
@ -506,6 +506,19 @@ describe('BrowserWindow module', () => {
expect(image.isEmpty()).to.be.true()
})
// TODO(codebytere): remove when promisification is complete
it('returns a Promise with a Buffer (callback)', () => {
w.capturePage({
x: 0,
y: 0,
width: 100,
height: 100
}, (image) => {
expect(image.isEmpty()).to.be.true()
done()
})
})
it('preserves transparency', async () => {
const w = await openTheWindow({
show: false,
@ -525,6 +538,28 @@ describe('BrowserWindow module', () => {
// Values can be 0,2,3,4, or 6. We want 6, which is RGB + Alpha
expect(imgBuffer[25]).to.equal(6)
})
// TODO(codebytere): remove when promisification is complete
it('preserves transparency (callback)', async () => {
const w = await openTheWindow({
show: false,
width: 400,
height: 400,
transparent: true
})
const p = emittedOnce(w, 'ready-to-show')
w.loadURL('data:text/html,<html><body background-color: rgba(255,255,255,0)></body></html>')
await p
w.show()
w.capturePage((image) => {
const imgBuffer = image.toPNG()
// Check the 25th byte in the PNG.
// Values can be 0,2,3,4, or 6. We want 6, which is RGB + Alpha
expect(imgBuffer[25]).to.equal(6)
done()
})
})
})
describe('BrowserWindow.setBounds(bounds[, animate])', () => {