refactor: ginify Notification (#22821)

This commit is contained in:
Jeremy Apthorp 2020-03-31 11:42:32 -07:00 committed by GitHub
parent 629465aac7
commit 765c08c600
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 68 additions and 30 deletions

View file

@ -1,7 +1,13 @@
import { expect } from 'chai';
import { Notification } from 'electron';
import { emittedOnce } from './events-helpers';
import { ifit } from './spec-helpers';
describe('Notification module', () => {
it('is supported', () => {
expect(Notification.isSupported()).to.be.a('boolean');
});
it('inits, gets and sets basic string properties correctly', () => {
const n = new Notification({
title: 'title',
@ -92,5 +98,33 @@ describe('Notification module', () => {
expect(n.actions[1].text).to.equal('4');
});
it('can be shown and closed', () => {
const n = new Notification({
title: 'test notification',
body: 'test body',
silent: true
});
n.show();
n.close();
});
ifit(process.platform === 'darwin')('emits show and close events', async () => {
const n = new Notification({
title: 'test notification',
body: 'test body',
silent: true
});
{
const e = emittedOnce(n, 'show');
n.show();
await e;
}
{
const e = emittedOnce(n, 'close');
n.close();
await e;
}
});
// TODO(sethlu): Find way to test init with notification icon?
});