Tests: Notification reducer NOTIFICATIONS_EXPAND_SUCCESS

merge-requests/67/merge
Alex Gleason 4 years ago
parent d78a62ed41
commit 0e86d03c97
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7

File diff suppressed because it is too large Load Diff

@ -1,5 +1,10 @@
import {
NOTIFICATIONS_EXPAND_SUCCESS,
} from 'soapbox/actions/notifications';
import reducer from '../notifications';
import notifications from 'soapbox/__fixtures__/notifications.json';
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
import { take } from 'lodash';
describe('notifications reducer', () => {
it('should return the initial state', () => {
@ -14,4 +19,53 @@ describe('notifications reducer', () => {
lastRead: -1,
}));
});
test('NOTIFICATIONS_EXPAND_SUCCESS', () => {
const state = undefined;
const action = {
type: NOTIFICATIONS_EXPAND_SUCCESS,
notifications: take(notifications, 3),
next: null,
skipLoading: true,
};
expect(reducer(state, action)).toEqual(ImmutableMap({
items: ImmutableList([
ImmutableMap({
id: '10744',
type: 'pleroma:emoji_reaction',
account: '9vMAje101ngtjlMj7w',
created_at: '2020-06-10T02:54:39.000Z',
status: '9vvNxoo5EFbbnfdXQu',
emoji: '😢',
is_seen: false,
}),
ImmutableMap({
id: '10743',
type: 'favourite',
account: '9v5c6xSEgAi3Zu1Lv6',
created_at: '2020-06-10T02:51:05.000Z',
status: '9vvNxoo5EFbbnfdXQu',
emoji: undefined,
is_seen: true,
}),
ImmutableMap({
id: '10741',
type: 'favourite',
account: '9v5cKMOPGqPcgfcWp6',
created_at: '2020-06-10T02:05:06.000Z',
status: '9vvNxoo5EFbbnfdXQu',
emoji: undefined,
is_seen: true,
}),
]),
hasMore: false,
top: false,
unread: 0,
isLoading: false,
queuedNotifications: ImmutableList(),
totalQueuedNotificationsCount: 0,
lastRead: -1,
}));
});
});

@ -23,6 +23,7 @@ import { TIMELINE_DELETE, TIMELINE_DISCONNECT } from '../actions/timelines';
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
import compareId from '../compare_id';
import { fromJS } from 'immutable';
import { get } from 'lodash';
const initialState = ImmutableMap({
items: ImmutableList(),
@ -42,6 +43,7 @@ const notificationToMap = notification => ImmutableMap({
created_at: notification.created_at,
status: notification.status ? notification.status.id : null,
emoji: notification.emoji,
is_seen: get(notification, ['pleroma', 'is_seen'], true),
});
const normalizeNotification = (state, notification) => {

Loading…
Cancel
Save