electron/spec/api-tray-spec.js
Shelley Vohr 2fb9085e5b
feat: add tray.getTitle() (#17385)
* feat: add tray.getTitle

* fix spec
2019-03-18 12:40:34 -07:00

62 lines
1.3 KiB
JavaScript

const { remote } = require('electron')
const { expect } = require('chai')
const { Menu, Tray, nativeImage } = remote
describe('tray module', () => {
let tray
beforeEach(() => {
tray = new Tray(nativeImage.createEmpty())
})
afterEach(() => {
tray.destroy()
tray = null
})
describe('tray.setContextMenu', () => {
it('accepts menu instance', () => {
tray.setContextMenu(new Menu())
})
it('accepts null', () => {
tray.setContextMenu(null)
})
})
describe('tray.setImage', () => {
it('accepts empty image', () => {
tray.setImage(nativeImage.createEmpty())
})
})
describe('tray.setPressedImage', () => {
it('accepts empty image', () => {
tray.setPressedImage(nativeImage.createEmpty())
})
})
describe('tray title get/set', () => {
before(function () {
if (process.platform !== 'darwin') {
this.skip()
}
})
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)
})
})
})