build: enable JS semicolons (#22783)

This commit is contained in:
Samuel Attard 2020-03-20 13:28:31 -07:00 committed by GitHub
parent 24e21467b9
commit 5d657dece4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
354 changed files with 21512 additions and 21510 deletions

View file

@ -1,128 +1,128 @@
import { expect } from 'chai'
import { Menu, Tray, nativeImage } from 'electron'
import { ifdescribe, ifit } from './spec-helpers'
import * as path from 'path'
import { expect } from 'chai';
import { Menu, Tray, nativeImage } from 'electron';
import { ifdescribe, ifit } from './spec-helpers';
import * as path from 'path';
describe('tray module', () => {
let tray: Tray
let tray: Tray;
beforeEach(() => { tray = new Tray(nativeImage.createEmpty()) })
beforeEach(() => { tray = new Tray(nativeImage.createEmpty()); });
afterEach(() => {
tray.destroy()
tray = null as any
})
tray.destroy();
tray = null as any;
});
describe('new Tray', () => {
it('throws a descriptive error for a missing file', () => {
const badPath = path.resolve('I', 'Do', 'Not', 'Exist')
const badPath = path.resolve('I', 'Do', 'Not', 'Exist');
expect(() => {
tray = new Tray(badPath)
}).to.throw(/Image could not be created from .*/)
})
tray = new Tray(badPath);
}).to.throw(/Image could not be created from .*/);
});
ifit(process.platform === 'win32')('throws a descriptive error if an invlaid guid is given', () => {
expect(() => {
tray = new Tray(nativeImage.createEmpty(), 'I am not a guid')
}).to.throw('Invalid GUID format')
})
tray = new Tray(nativeImage.createEmpty(), 'I am not a guid');
}).to.throw('Invalid GUID format');
});
ifit(process.platform === 'win32')('accepts a valid guid', () => {
expect(() => {
tray = new Tray(nativeImage.createEmpty(), '0019A433-3526-48BA-A66C-676742C0FEFB')
}).to.not.throw()
})
})
tray = new Tray(nativeImage.createEmpty(), '0019A433-3526-48BA-A66C-676742C0FEFB');
}).to.not.throw();
});
});
ifdescribe(process.platform === 'darwin')('tray get/set ignoreDoubleClickEvents', () => {
it('returns false by default', () => {
const ignored = tray.getIgnoreDoubleClickEvents()
expect(ignored).to.be.false('ignored')
})
const ignored = tray.getIgnoreDoubleClickEvents();
expect(ignored).to.be.false('ignored');
});
it('can be set to true', () => {
tray.setIgnoreDoubleClickEvents(true)
tray.setIgnoreDoubleClickEvents(true);
const ignored = tray.getIgnoreDoubleClickEvents()
expect(ignored).to.be.true('not ignored')
})
})
const ignored = tray.getIgnoreDoubleClickEvents();
expect(ignored).to.be.true('not ignored');
});
});
describe('tray.setContextMenu(menu)', () => {
it('accepts both null and Menu as parameters', () => {
expect(() => { tray.setContextMenu(new Menu()) }).to.not.throw()
expect(() => { tray.setContextMenu(null) }).to.not.throw()
})
})
expect(() => { tray.setContextMenu(new Menu()); }).to.not.throw();
expect(() => { tray.setContextMenu(null); }).to.not.throw();
});
});
describe('tray.destroy()', () => {
it('destroys a tray', () => {
expect(tray.isDestroyed()).to.be.false('tray should not be destroyed')
tray.destroy()
expect(tray.isDestroyed()).to.be.false('tray should not be destroyed');
tray.destroy();
expect(tray.isDestroyed()).to.be.true('tray should be destroyed')
})
})
expect(tray.isDestroyed()).to.be.true('tray should be destroyed');
});
});
describe('tray.popUpContextMenu()', () => {
ifit(process.platform === 'win32')('can be called when menu is showing', function (done) {
tray.setContextMenu(Menu.buildFromTemplate([{ label: 'Test' }]))
tray.setContextMenu(Menu.buildFromTemplate([{ label: 'Test' }]));
setTimeout(() => {
tray.popUpContextMenu()
done()
})
tray.popUpContextMenu()
})
})
tray.popUpContextMenu();
done();
});
tray.popUpContextMenu();
});
});
describe('tray.closeContextMenu()', () => {
ifit(process.platform === 'win32')('does not crash when called more than once', function (done) {
tray.setContextMenu(Menu.buildFromTemplate([{ label: 'Test' }]))
tray.setContextMenu(Menu.buildFromTemplate([{ label: 'Test' }]));
setTimeout(() => {
tray.closeContextMenu()
tray.closeContextMenu()
done()
})
tray.popUpContextMenu()
})
})
tray.closeContextMenu();
tray.closeContextMenu();
done();
});
tray.popUpContextMenu();
});
});
describe('tray.getBounds()', () => {
afterEach(() => { tray.destroy() })
afterEach(() => { tray.destroy(); });
ifit(process.platform !== 'linux')('returns a bounds object', function () {
const bounds = tray.getBounds()
expect(bounds).to.be.an('object').and.to.have.all.keys('x', 'y', 'width', 'height')
})
})
const bounds = tray.getBounds();
expect(bounds).to.be.an('object').and.to.have.all.keys('x', 'y', 'width', 'height');
});
});
describe('tray.setImage(image)', () => {
it('accepts empty image', () => {
tray.setImage(nativeImage.createEmpty())
})
})
tray.setImage(nativeImage.createEmpty());
});
});
describe('tray.setPressedImage(image)', () => {
it('accepts empty image', () => {
tray.setPressedImage(nativeImage.createEmpty())
})
})
tray.setPressedImage(nativeImage.createEmpty());
});
});
ifdescribe(process.platform === 'darwin')('tray get/set title', () => {
it('sets/gets non-empty title', () => {
const title = 'Hello World!'
tray.setTitle(title)
const newTitle = tray.getTitle()
const title = 'Hello World!';
tray.setTitle(title);
const newTitle = tray.getTitle();
expect(newTitle).to.equal(title)
})
expect(newTitle).to.equal(title);
});
it('sets/gets empty title', () => {
const title = ''
tray.setTitle(title)
const newTitle = tray.getTitle()
const title = '';
tray.setTitle(title);
const newTitle = tray.getTitle();
expect(newTitle).to.equal(title)
})
})
})
expect(newTitle).to.equal(title);
});
});
});