mirror of
https://github.com/electron/electron.git
synced 2026-05-02 03:00:22 -04:00
refactor: ginify Notification (#22821)
This commit is contained in:
@@ -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?
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user