[MM-36456] Add support for Gnome's do-not-disturb (#2278)
* Add support for gnome do-not-disturb mode * Add tests * Invert condition
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
'use strict';
|
||||
import cp from 'child_process';
|
||||
|
||||
import {Notification, shell} from 'electron';
|
||||
|
||||
@@ -15,10 +16,16 @@ import {localizeMessage} from 'main/i18nManager';
|
||||
|
||||
import WindowManager from '../windows/windowManager';
|
||||
|
||||
import getLinuxDoNotDisturb from './dnd-linux';
|
||||
|
||||
import {displayMention, displayDownloadCompleted, currentNotifications} from './index';
|
||||
|
||||
const mentions = [];
|
||||
|
||||
jest.mock('child_process', () => ({
|
||||
execSync: jest.fn(),
|
||||
}));
|
||||
|
||||
jest.mock('electron', () => {
|
||||
class NotificationMock {
|
||||
static isSupported = jest.fn();
|
||||
@@ -231,4 +238,23 @@ describe('main/notifications', () => {
|
||||
expect(shell.showItemInFolder).toHaveBeenCalledWith('/path/to/file');
|
||||
});
|
||||
});
|
||||
|
||||
describe('getLinuxDoNotDisturb', () => {
|
||||
it('should return false', () => {
|
||||
cp.execSync.mockReturnValue('true');
|
||||
expect(getLinuxDoNotDisturb()).toBe(false);
|
||||
});
|
||||
|
||||
it('should return false if error is thrown', () => {
|
||||
cp.execSync.mockImplementation(() => {
|
||||
throw Error('error');
|
||||
});
|
||||
expect(getLinuxDoNotDisturb()).toBe(false);
|
||||
});
|
||||
|
||||
it('should return true', () => {
|
||||
cp.execSync.mockReturnValue('false');
|
||||
expect(getLinuxDoNotDisturb()).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user