bigbuffet-rw/app/soapbox/reducers/__tests__/statuses-test.js

42 lines
1.1 KiB
JavaScript
Raw Normal View History

2020-06-09 18:08:07 -07:00
import reducer from '../statuses';
2021-11-12 10:18:11 -08:00
import { Map as ImmutableMap, fromJS } from 'immutable';
import {
STATUS_CREATE_REQUEST,
STATUS_CREATE_FAIL,
} from 'soapbox/actions/statuses';
2020-06-09 18:08:07 -07:00
describe('statuses reducer', () => {
it('should return the initial state', () => {
expect(reducer(undefined, {})).toEqual(ImmutableMap());
});
2021-11-12 10:18:11 -08:00
describe('STATUS_CREATE_REQUEST', () => {
it('increments the replies_count of its parent', () => {
const state = fromJS({ '123': { replies_count: 4 } });
const action = {
type: STATUS_CREATE_REQUEST,
params: { in_reply_to_id: '123' },
};
const result = reducer(state, action).getIn(['123', 'replies_count']);
expect(result).toEqual(5);
});
});
describe('STATUS_CREATE_FAIL', () => {
it('decrements the replies_count of its parent', () => {
const state = fromJS({ '123': { replies_count: 5 } });
const action = {
type: STATUS_CREATE_FAIL,
params: { in_reply_to_id: '123' },
};
const result = reducer(state, action).getIn(['123', 'replies_count']);
expect(result).toEqual(4);
});
});
2020-06-09 18:08:07 -07:00
});