2020-06-09 18:08:07 -07:00
|
|
|
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
|
2022-01-10 14:25:06 -08:00
|
|
|
|
2020-07-07 06:55:44 -07:00
|
|
|
import * as actions from 'soapbox/actions/conversations';
|
2022-01-10 14:25:06 -08:00
|
|
|
|
2022-01-10 14:01:24 -08:00
|
|
|
import reducer from '../conversations';
|
2020-06-09 18:08:07 -07:00
|
|
|
|
|
|
|
describe('conversations reducer', () => {
|
|
|
|
it('should return the initial state', () => {
|
|
|
|
expect(reducer(undefined, {})).toEqual(ImmutableMap({
|
|
|
|
items: ImmutableList(),
|
|
|
|
isLoading: false,
|
|
|
|
hasMore: true,
|
|
|
|
mounted: false,
|
|
|
|
}));
|
|
|
|
});
|
2020-07-07 06:55:44 -07:00
|
|
|
|
|
|
|
it('should handle CONVERSATIONS_FETCH_REQUEST', () => {
|
|
|
|
const state = ImmutableMap({ isLoading: false });
|
|
|
|
const action = {
|
|
|
|
type: actions.CONVERSATIONS_FETCH_REQUEST,
|
|
|
|
};
|
|
|
|
expect(reducer(state, action).toJS()).toMatchObject({
|
|
|
|
isLoading: true,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should handle CONVERSATIONS_FETCH_FAIL', () => {
|
|
|
|
const state = ImmutableMap({ isLoading: true });
|
|
|
|
const action = {
|
|
|
|
type: actions.CONVERSATIONS_FETCH_FAIL,
|
|
|
|
};
|
|
|
|
expect(reducer(state, action).toJS()).toMatchObject({
|
|
|
|
isLoading: false,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// it('should handle the Action CONVERSATIONS_MOUNT', () => {
|
|
|
|
// expect(
|
|
|
|
// reducer(
|
|
|
|
// {
|
|
|
|
// mounted: false,
|
|
|
|
// },
|
|
|
|
// {
|
|
|
|
// type: 'CONVERSATIONS_MOUNT',
|
|
|
|
// },
|
|
|
|
// ),
|
|
|
|
// ).toEqual({
|
|
|
|
// mounted: true,
|
|
|
|
// });
|
|
|
|
// });
|
|
|
|
//
|
|
|
|
// it('should handle the Action CONVERSATIONS_UNMOUNT', () => {
|
|
|
|
// expect(
|
|
|
|
// reducer(
|
|
|
|
// {
|
|
|
|
// mounted: true,
|
|
|
|
// },
|
|
|
|
// {
|
|
|
|
// type: 'CONVERSATIONS_UNMOUNT',
|
|
|
|
// },
|
|
|
|
// ),
|
|
|
|
// ).toEqual({
|
|
|
|
// mounted: false,
|
|
|
|
// });
|
|
|
|
// });
|
|
|
|
|
2020-06-09 18:08:07 -07:00
|
|
|
});
|