test: move tray api tests to main process (#18986)

This commit is contained in:
Micha Hanselmann 2019-06-28 07:43:05 -07:00 committed by Shelley Vohr
parent 0a9438dbba
commit e44bb8474b

View file

@ -1,18 +1,20 @@
const { remote } = require('electron') import { expect } from 'chai'
const { expect } = require('chai') import { Menu, Tray, nativeImage } from 'electron'
const { Menu, Tray, nativeImage } = remote
describe('tray module', () => { describe('tray module', () => {
let tray let tray: Tray;
beforeEach(() => { beforeEach(() => {
tray = new Tray(nativeImage.createEmpty()) tray = new Tray(nativeImage.createEmpty())
}) })
afterEach(() => {
tray = null as any
})
describe('tray.setContextMenu', () => { describe('tray.setContextMenu', () => {
afterEach(() => { afterEach(() => {
tray.destroy() tray.destroy()
tray = null
}) })
it('accepts menu instance', () => { it('accepts menu instance', () => {
@ -26,18 +28,16 @@ describe('tray module', () => {
describe('tray.destroy()', () => { describe('tray.destroy()', () => {
it('destroys a tray', () => { it('destroys a tray', () => {
expect(tray.isDestroyed()).to.be.false() expect(tray.isDestroyed()).to.be.false('tray should not be destroyed')
tray.destroy() tray.destroy()
expect(tray.isDestroyed()).to.be.true() expect(tray.isDestroyed()).to.be.true('tray should be destroyed')
tray = null
}) })
}) })
describe('tray.popUpContextMenu', () => { describe('tray.popUpContextMenu', () => {
afterEach(() => { afterEach(() => {
tray.destroy() tray.destroy()
tray = null
}) })
before(function () { before(function () {
@ -59,7 +59,6 @@ describe('tray module', () => {
tray.setImage(nativeImage.createEmpty()) tray.setImage(nativeImage.createEmpty())
tray.destroy() tray.destroy()
tray = null
}) })
}) })
@ -68,7 +67,6 @@ describe('tray module', () => {
tray.setPressedImage(nativeImage.createEmpty()) tray.setPressedImage(nativeImage.createEmpty())
tray.destroy() tray.destroy()
tray = null
}) })
}) })
@ -79,7 +77,6 @@ describe('tray module', () => {
afterEach(() => { afterEach(() => {
tray.destroy() tray.destroy()
tray = null
}) })
it('sets/gets non-empty title', () => { it('sets/gets non-empty title', () => {