2018-09-13 16:10:51 +00:00
|
|
|
const { remote } = require('electron')
|
2019-03-18 19:40:34 +00:00
|
|
|
const { expect } = require('chai')
|
2018-09-13 16:10:51 +00:00
|
|
|
const { Menu, Tray, nativeImage } = remote
|
2018-08-27 16:58:47 +00:00
|
|
|
|
|
|
|
describe('tray module', () => {
|
2018-08-30 09:16:56 +00:00
|
|
|
let tray
|
2018-08-27 16:58:47 +00:00
|
|
|
|
2018-08-30 09:16:56 +00:00
|
|
|
beforeEach(() => {
|
|
|
|
tray = new Tray(nativeImage.createEmpty())
|
|
|
|
})
|
2018-08-27 16:58:47 +00:00
|
|
|
|
2018-08-30 09:16:56 +00:00
|
|
|
afterEach(() => {
|
|
|
|
tray.destroy()
|
|
|
|
tray = null
|
|
|
|
})
|
2018-08-27 16:58:47 +00:00
|
|
|
|
2018-08-30 09:16:56 +00:00
|
|
|
describe('tray.setContextMenu', () => {
|
2018-08-27 16:58:47 +00:00
|
|
|
it('accepts menu instance', () => {
|
|
|
|
tray.setContextMenu(new Menu())
|
|
|
|
})
|
|
|
|
|
|
|
|
it('accepts null', () => {
|
|
|
|
tray.setContextMenu(null)
|
|
|
|
})
|
|
|
|
})
|
2018-08-30 09:16:56 +00:00
|
|
|
|
2019-03-22 04:56:22 +00:00
|
|
|
describe('tray.popUpContextMenu', () => {
|
|
|
|
before(function () {
|
|
|
|
if (process.platform !== 'win32') {
|
|
|
|
this.skip()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
it('can be called when menu is showing', (done) => {
|
|
|
|
tray.setContextMenu(Menu.buildFromTemplate([{ label: 'Test' }]))
|
|
|
|
setTimeout(() => {
|
|
|
|
tray.popUpContextMenu()
|
|
|
|
done()
|
|
|
|
})
|
|
|
|
tray.popUpContextMenu()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2018-08-30 09:16:56 +00:00
|
|
|
describe('tray.setImage', () => {
|
|
|
|
it('accepts empty image', () => {
|
|
|
|
tray.setImage(nativeImage.createEmpty())
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('tray.setPressedImage', () => {
|
|
|
|
it('accepts empty image', () => {
|
|
|
|
tray.setPressedImage(nativeImage.createEmpty())
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2019-03-18 19:40:34 +00:00
|
|
|
describe('tray title get/set', () => {
|
|
|
|
before(function () {
|
|
|
|
if (process.platform !== 'darwin') {
|
|
|
|
this.skip()
|
|
|
|
}
|
2018-08-30 09:16:56 +00:00
|
|
|
})
|
|
|
|
|
2019-03-18 19:40:34 +00:00
|
|
|
it('sets/gets non-empty title', () => {
|
|
|
|
const title = 'Hello World!'
|
|
|
|
tray.setTitle(title)
|
|
|
|
const newTitle = tray.getTitle()
|
|
|
|
|
|
|
|
expect(newTitle).to.equal(title)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('sets/gets empty title', () => {
|
|
|
|
const title = ''
|
|
|
|
tray.setTitle(title)
|
|
|
|
const newTitle = tray.getTitle()
|
|
|
|
|
|
|
|
expect(newTitle).to.equal(title)
|
2018-08-30 09:16:56 +00:00
|
|
|
})
|
|
|
|
})
|
2018-08-27 16:58:47 +00:00
|
|
|
})
|