Files
ncd-fe/packages/pl-fe/src/actions/notifications.test.ts
nicole mikołajczyk a80bb6d938 pl-fe: change import alias so it won't change on each project rename
Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
2026-02-07 22:41:47 +01:00

43 lines
1.1 KiB
TypeScript

import { OrderedMap as ImmutableOrderedMap } from 'immutable';
import { __stub } from '@/api';
import { mockStore, rootState } from '@/jest/test-helpers';
import { normalizeNotification } from '@/normalizers/notification';
import { markReadNotifications } from './notifications';
describe('markReadNotifications()', () => {
it('fires off marker when top notification is newer than lastRead', async() => {
__stub((mock) => mock.onPost('/api/v1/markers').reply(200, {}));
const items = ImmutableOrderedMap({
'10': normalizeNotification({ id: '10' }),
});
const state = {
...rootState,
me: '123',
notifications: rootState.notifications.merge({
lastRead: '9',
items,
}),
};
const store = mockStore(state);
const expectedActions = [{
type: 'MARKER_SAVE_REQUEST',
marker: {
notifications: {
last_read_id: '10',
},
},
}];
store.dispatch(markReadNotifications());
const actions = store.getActions();
expect(actions).toEqual(expectedActions);
});
});