From e44bb8474baf37ed5a30fae92d452db370a18db8 Mon Sep 17 00:00:00 2001 From: Micha Hanselmann Date: Fri, 28 Jun 2019 07:43:05 -0700 Subject: [PATCH] test: move tray api tests to main process (#18986) --- .../api-tray-spec.ts | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) rename spec/api-tray-spec.js => spec-main/api-tray-spec.ts (84%) diff --git a/spec/api-tray-spec.js b/spec-main/api-tray-spec.ts similarity index 84% rename from spec/api-tray-spec.js rename to spec-main/api-tray-spec.ts index 49a31729d088..4d79512bb644 100644 --- a/spec/api-tray-spec.js +++ b/spec-main/api-tray-spec.ts @@ -1,18 +1,20 @@ -const { remote } = require('electron') -const { expect } = require('chai') -const { Menu, Tray, nativeImage } = remote +import { expect } from 'chai' +import { Menu, Tray, nativeImage } from 'electron' describe('tray module', () => { - let tray + let tray: Tray; beforeEach(() => { tray = new Tray(nativeImage.createEmpty()) }) + afterEach(() => { + tray = null as any + }) + describe('tray.setContextMenu', () => { afterEach(() => { tray.destroy() - tray = null }) it('accepts menu instance', () => { @@ -26,18 +28,16 @@ describe('tray module', () => { describe('tray.destroy()', () => { it('destroys a tray', () => { - expect(tray.isDestroyed()).to.be.false() + expect(tray.isDestroyed()).to.be.false('tray should not be destroyed') tray.destroy() - expect(tray.isDestroyed()).to.be.true() - tray = null + expect(tray.isDestroyed()).to.be.true('tray should be destroyed') }) }) describe('tray.popUpContextMenu', () => { afterEach(() => { tray.destroy() - tray = null }) before(function () { @@ -59,7 +59,6 @@ describe('tray module', () => { tray.setImage(nativeImage.createEmpty()) tray.destroy() - tray = null }) }) @@ -68,7 +67,6 @@ describe('tray module', () => { tray.setPressedImage(nativeImage.createEmpty()) tray.destroy() - tray = null }) }) @@ -79,7 +77,6 @@ describe('tray module', () => { afterEach(() => { tray.destroy() - tray = null }) it('sets/gets non-empty title', () => {