feat: Add settings for audio alert notifications (#2415)
Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
This commit is contained in:
parent
48127e00d7
commit
0bd48129b9
9 changed files with 130 additions and 42 deletions
|
@ -2,7 +2,11 @@
|
|||
* @jest-environment jsdom
|
||||
*/
|
||||
|
||||
import { shouldPlayAudio } from '../AudioNotificationHelper';
|
||||
import {
|
||||
shouldPlayAudio,
|
||||
notificationEnabled,
|
||||
getAssigneeFromNotification,
|
||||
} from '../AudioNotificationHelper';
|
||||
|
||||
describe('shouldPlayAudio', () => {
|
||||
describe('Document active', () => {
|
||||
|
@ -107,3 +111,41 @@ describe('shouldPlayAudio', () => {
|
|||
});
|
||||
});
|
||||
});
|
||||
describe('notificationEnabled', () => {
|
||||
it('returns true if mine', () => {
|
||||
const [enableAudioAlerts, userId, id] = ['mine', 1, 1];
|
||||
const result = notificationEnabled(enableAudioAlerts, userId, id);
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
it('returns true if all', () => {
|
||||
const [enableAudioAlerts, userId, id] = ['all', 1, 2];
|
||||
const result = notificationEnabled(enableAudioAlerts, userId, id);
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
it('returns false if none', () => {
|
||||
const [enableAudioAlerts, userId, id] = ['none', 1, 2];
|
||||
const result = notificationEnabled(enableAudioAlerts, userId, id);
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
});
|
||||
describe('getAssigneeFromNotification', () => {
|
||||
it('Retuns true if gets notification from assignee', () => {
|
||||
const currentConv = {
|
||||
id: 1,
|
||||
accountId: 1,
|
||||
meta: {
|
||||
assignee: {
|
||||
id: 1,
|
||||
name: 'John',
|
||||
},
|
||||
},
|
||||
};
|
||||
const result = getAssigneeFromNotification(currentConv);
|
||||
expect(result).toBe(1);
|
||||
});
|
||||
it('Retuns true if gets notification from assignee is udefined', () => {
|
||||
const currentConv = {};
|
||||
const result = getAssigneeFromNotification(currentConv);
|
||||
expect(result).toBe(undefined);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue