Clean up contexts test
This commit is contained in:
parent
2290bfb334
commit
0329cc4d04
2 changed files with 13 additions and 13 deletions
|
@ -9,11 +9,11 @@ import context2 from 'soapbox/__fixtures__/context_2.json';
|
||||||
import { CONTEXT_FETCH_SUCCESS } from 'soapbox/actions/statuses';
|
import { CONTEXT_FETCH_SUCCESS } from 'soapbox/actions/statuses';
|
||||||
import { TIMELINE_DELETE } from 'soapbox/actions/timelines';
|
import { TIMELINE_DELETE } from 'soapbox/actions/timelines';
|
||||||
|
|
||||||
import reducer from '../contexts';
|
import reducer, { ReducerRecord } from '../contexts';
|
||||||
|
|
||||||
describe('contexts reducer', () => {
|
describe('contexts reducer', () => {
|
||||||
it('should return the initial state', () => {
|
it('should return the initial state', () => {
|
||||||
expect(reducer(undefined, {})).toEqual(ImmutableMap({
|
expect(reducer(undefined, {})).toEqual(ReducerRecord({
|
||||||
inReplyTos: ImmutableMap(),
|
inReplyTos: ImmutableMap(),
|
||||||
replies: ImmutableMap(),
|
replies: ImmutableMap(),
|
||||||
}));
|
}));
|
||||||
|
@ -25,7 +25,7 @@ describe('contexts reducer', () => {
|
||||||
result = reducer(result, { type: CONTEXT_FETCH_SUCCESS, id: '9zIH8WYwtnUx4yDzUm', ancestors: context1.ancestors, descendants: context1.descendants });
|
result = reducer(result, { type: CONTEXT_FETCH_SUCCESS, id: '9zIH8WYwtnUx4yDzUm', ancestors: context1.ancestors, descendants: context1.descendants });
|
||||||
result = reducer(result, { type: CONTEXT_FETCH_SUCCESS, id: '9zIH7PUdhK3Ircg4hM', ancestors: context2.ancestors, descendants: context2.descendants });
|
result = reducer(result, { type: CONTEXT_FETCH_SUCCESS, id: '9zIH7PUdhK3Ircg4hM', ancestors: context2.ancestors, descendants: context2.descendants });
|
||||||
|
|
||||||
expect(result).toEqual(ImmutableMap({
|
expect(result).toEqual(ReducerRecord({
|
||||||
inReplyTos: ImmutableMap({
|
inReplyTos: ImmutableMap({
|
||||||
'9zIH7PUdhK3Ircg4hM': '9zIH6kDXA10YqhMKqO',
|
'9zIH7PUdhK3Ircg4hM': '9zIH6kDXA10YqhMKqO',
|
||||||
'9zIH7mMGgc1RmJwDLM': '9zIH6kDXA10YqhMKqO',
|
'9zIH7mMGgc1RmJwDLM': '9zIH6kDXA10YqhMKqO',
|
||||||
|
@ -60,22 +60,22 @@ describe('contexts reducer', () => {
|
||||||
it('deletes the status', () => {
|
it('deletes the status', () => {
|
||||||
const action = { type: TIMELINE_DELETE, id: 'B' };
|
const action = { type: TIMELINE_DELETE, id: 'B' };
|
||||||
|
|
||||||
const state = fromJS({
|
const state = ReducerRecord({
|
||||||
inReplyTos: {
|
inReplyTos: fromJS({
|
||||||
B: 'A',
|
B: 'A',
|
||||||
C: 'B',
|
C: 'B',
|
||||||
},
|
}),
|
||||||
replies: {
|
replies: fromJS({
|
||||||
A: ImmutableOrderedSet(['B']),
|
A: ImmutableOrderedSet(['B']),
|
||||||
B: ImmutableOrderedSet(['C']),
|
B: ImmutableOrderedSet(['C']),
|
||||||
},
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
const expected = fromJS({
|
const expected = ReducerRecord({
|
||||||
inReplyTos: {},
|
inReplyTos: fromJS({}),
|
||||||
replies: {
|
replies: fromJS({
|
||||||
A: ImmutableOrderedSet(),
|
A: ImmutableOrderedSet(),
|
||||||
},
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(reducer(state, action)).toEqual(expected);
|
expect(reducer(state, action)).toEqual(expected);
|
||||||
|
|
|
@ -20,7 +20,7 @@ import { TIMELINE_DELETE } from '../actions/timelines';
|
||||||
import type { ReducerStatus } from './statuses';
|
import type { ReducerStatus } from './statuses';
|
||||||
import type { AnyAction } from 'redux';
|
import type { AnyAction } from 'redux';
|
||||||
|
|
||||||
const ReducerRecord = ImmutableRecord({
|
export const ReducerRecord = ImmutableRecord({
|
||||||
inReplyTos: ImmutableMap<string, string>(),
|
inReplyTos: ImmutableMap<string, string>(),
|
||||||
replies: ImmutableMap<string, ImmutableOrderedSet<string>>(),
|
replies: ImmutableMap<string, ImmutableOrderedSet<string>>(),
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue