Skip to content

Commit

Permalink
Add Settings.isNotificationGroupingSupported
Browse files Browse the repository at this point in the history
  • Loading branch information
gasi-signal committed May 4, 2018
1 parent c742212 commit f20e0d3
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
62 changes: 62 additions & 0 deletions ts/test/types/Settings_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,66 @@ describe('Settings', () => {
});
});
});

describe('isNotificationGroupingSupported', () => {
context('on macOS', () => {
beforeEach(() => {
sandbox.stub(process, 'platform').value('darwin');
});

afterEach(() => {
sandbox.restore();
});

it('should return true', () => {
assert.isTrue(Settings.isNotificationGroupingSupported());
});
});

context('on Windows', () => {
context('version 7', () => {
beforeEach(() => {
sandbox.stub(process, 'platform').value('win32');
sandbox.stub(os, 'release').returns('7.0.0');
});

afterEach(() => {
sandbox.restore();
});

it('should return false', () => {
assert.isFalse(Settings.isNotificationGroupingSupported());
});
});

context('version 8+', () => {
beforeEach(() => {
sandbox.stub(process, 'platform').value('win32');
sandbox.stub(os, 'release').returns('8.0.0');
});

afterEach(() => {
sandbox.restore();
});

it('should return true', () => {
assert.isTrue(Settings.isNotificationGroupingSupported());
});
});
});

context('on Linux', () => {
beforeEach(() => {
sandbox.stub(process, 'platform').value('linux');
});

afterEach(() => {
sandbox.restore();
});

it('should return true', () => {
assert.isTrue(Settings.isNotificationGroupingSupported());
});
});
});
});
5 changes: 5 additions & 0 deletions ts/types/Settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@ const MIN_WINDOWS_VERSION = '8.0.0';

export const isAudioNotificationSupported = () =>
OS.isWindows(MIN_WINDOWS_VERSION) || OS.isMacOS();

// Using `Notification::tag` has a bug on Windows 7:
// https://github.com/electron/electron/issues/11189
export const isNotificationGroupingSupported = () =>
!OS.isWindows() || OS.isWindows(MIN_WINDOWS_VERSION);

0 comments on commit f20e0d3

Please sign in to comment.