Inhibit local notifications when local notifications are silenced (#9328)
This commit is contained in:
parent
951cad98d3
commit
a49603b9b8
4 changed files with 122 additions and 5 deletions
|
@ -18,6 +18,7 @@ import { MatrixEvent } from "matrix-js-sdk/src/models/event";
|
|||
import { mocked } from "jest-mock";
|
||||
|
||||
import {
|
||||
localNotificationsAreSilenced,
|
||||
createLocalNotificationSettingsIfNeeded,
|
||||
getLocalNotificationAccountDataEventType,
|
||||
} from "../../src/utils/notifications";
|
||||
|
@ -27,7 +28,7 @@ import { getMockClientWithEventEmitter } from "../test-utils/client";
|
|||
jest.mock("../../src/settings/SettingsStore");
|
||||
|
||||
describe('notifications', () => {
|
||||
const accountDataStore = {};
|
||||
let accountDataStore = {};
|
||||
const mockClient = getMockClientWithEventEmitter({
|
||||
isGuest: jest.fn().mockReturnValue(false),
|
||||
getAccountData: jest.fn().mockImplementation(eventType => accountDataStore[eventType]),
|
||||
|
@ -42,6 +43,7 @@ describe('notifications', () => {
|
|||
const accountDataEventKey = getLocalNotificationAccountDataEventType(mockClient.deviceId);
|
||||
|
||||
beforeEach(() => {
|
||||
accountDataStore = {};
|
||||
mocked(SettingsStore).getValue.mockReturnValue(false);
|
||||
});
|
||||
|
||||
|
@ -76,4 +78,17 @@ describe('notifications', () => {
|
|||
expect(event?.getContent().is_silenced).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('localNotificationsAreSilenced', () => {
|
||||
it('defaults to true when no setting exists', () => {
|
||||
expect(localNotificationsAreSilenced(mockClient)).toBeTruthy();
|
||||
});
|
||||
it('checks the persisted value', () => {
|
||||
mockClient.setAccountData(accountDataEventKey, { is_silenced: true });
|
||||
expect(localNotificationsAreSilenced(mockClient)).toBeTruthy();
|
||||
|
||||
mockClient.setAccountData(accountDataEventKey, { is_silenced: false });
|
||||
expect(localNotificationsAreSilenced(mockClient)).toBeFalsy();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue