mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
* upgrade gulp-babel * upgrade babel-eslint * upgrade eslint-friendly-formatter * start upgrading chai * start to upgrade eslint * restore skipped tests * start to upgrqde monk * fix linting and remove unused file * fix mocha notifications, and common tests * fix unit tests * start to fix initrgration tests * more integration tests fixes * upgrade monk to latest version * lint /scripts * migrations: start moving to /archive unused migrations and run eslint with --fix * lint migrations * fix more integration tests * fix test
43 lines
1.2 KiB
JavaScript
43 lines
1.2 KiB
JavaScript
import {
|
|
generateUser,
|
|
} from '../../../../helpers/api-v3-integration.helper';
|
|
|
|
describe('POST /news/tell-me-later', () => {
|
|
let user;
|
|
|
|
beforeEach(async () => {
|
|
user = await generateUser({
|
|
'flags.newStuff': true,
|
|
});
|
|
});
|
|
|
|
it('marks new stuff as read and adds notification', async () => {
|
|
expect(user.flags.newStuff).to.equal(true);
|
|
const initialNotifications = user.notifications.length;
|
|
|
|
await user.post('/news/tell-me-later');
|
|
await user.sync();
|
|
|
|
expect(user.flags.newStuff).to.equal(false);
|
|
expect(user.notifications.length).to.equal(initialNotifications + 1);
|
|
|
|
const notification = user.notifications[user.notifications.length - 1];
|
|
|
|
expect(notification.type).to.equal('NEW_STUFF');
|
|
// should be marked as seen by default so it's not counted in the number of notifications
|
|
expect(notification.seen).to.equal(true);
|
|
expect(notification.data.title).to.be.a.string;
|
|
});
|
|
|
|
it('never adds two notifications', async () => {
|
|
const initialNotifications = user.notifications.length;
|
|
|
|
await user.post('/news/tell-me-later');
|
|
await user.post('/news/tell-me-later');
|
|
|
|
await user.sync();
|
|
|
|
expect(user.notifications.length).to.equal(initialNotifications + 1);
|
|
});
|
|
});
|