mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
add final tests for push devices and notifications
This commit is contained in:
@@ -18,5 +18,37 @@ describe('UserNotification Model', () => {
|
||||
expect(safeNotifications[0].type).to.equal('ABC');
|
||||
expect(safeNotifications[0].id).to.equal('123');
|
||||
});
|
||||
|
||||
it('removes multiple NEW_CHAT_MESSAGE for the same group', () => {
|
||||
const notifications = [
|
||||
new UserNotification({
|
||||
type: 'NEW_CHAT_MESSAGE',
|
||||
id: 123,
|
||||
data: { group: { id: 12345 } },
|
||||
}),
|
||||
new UserNotification({
|
||||
type: 'NEW_CHAT_MESSAGE',
|
||||
id: 1234,
|
||||
data: { group: { id: 12345 } },
|
||||
}),
|
||||
new UserNotification({
|
||||
type: 'NEW_CHAT_MESSAGE',
|
||||
id: 123,
|
||||
data: { group: { id: 123456 } },
|
||||
}), // not duplicate, different group
|
||||
new UserNotification({
|
||||
type: 'NEW_CHAT_MESSAGE_DIFF',
|
||||
id: 123,
|
||||
data: { group: { id: 12345 } },
|
||||
}), // not duplicate, different type
|
||||
];
|
||||
|
||||
const safeNotifications = UserNotification.cleanupCorruptData(notifications);
|
||||
expect(safeNotifications.length).to.equal(3);
|
||||
expect(safeNotifications[0].data).to.deep.equal({ group: { id: 12345 } });
|
||||
expect(safeNotifications[0].seen).to.equal(false);
|
||||
expect(safeNotifications[0].type).to.equal('NEW_CHAT_MESSAGE');
|
||||
expect(safeNotifications[0].id).to.equal('123');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user