refactor: ginify Notification (#22821)
This commit is contained in:
parent
629465aac7
commit
765c08c600
4 changed files with 68 additions and 30 deletions
|
@ -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?
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue