Files
ncd-fe/packages/pl-fe/src/reducers/list-adder.test.ts
marcin mikołajczak 966b04fdf0 Call it pl-fe internally
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2024-08-28 13:41:08 +02:00

117 lines
2.6 KiB
TypeScript

import { List as ImmutableList, Record as ImmutableRecord } from 'immutable';
import * as actions from 'pl-fe/actions/lists';
import reducer from './list-adder';
describe('list_adder reducer', () => {
it('should return the initial state', () => {
expect(reducer(undefined, {} as any)).toMatchObject({
accountId: null,
lists: {
items: ImmutableList(),
loaded: false,
isLoading: false,
},
});
});
it('should handle LIST_ADDER_RESET', () => {
const state = ImmutableRecord({
accountId: null,
lists: ImmutableRecord({
items: ImmutableList<string>(),
loaded: false,
isLoading: false,
})(),
})();
const action = {
type: actions.LIST_ADDER_RESET,
};
expect(reducer(state, action)).toMatchObject({
accountId: null,
lists: {
items: ImmutableList(),
loaded: false,
isLoading: false,
},
});
});
it('should handle LIST_ADDER_LISTS_FETCH_REQUEST', () => {
const state = ImmutableRecord({
accountId: null,
lists: ImmutableRecord({
items: ImmutableList<string>(),
loaded: false,
isLoading: false,
})(),
})();
const action = {
type: actions.LIST_ADDER_LISTS_FETCH_REQUEST,
};
expect(reducer(state, action)).toMatchObject({
accountId: null,
lists: {
items: ImmutableList(),
loaded: false,
isLoading: true,
},
});
});
it('should handle LIST_ADDER_LISTS_FETCH_FAIL', () => {
const state = ImmutableRecord({
accountId: null,
lists: ImmutableRecord({
items: ImmutableList<string>(),
loaded: false,
isLoading: false,
})(),
})();
const action = {
type: actions.LIST_ADDER_LISTS_FETCH_FAIL,
};
expect(reducer(state, action)).toMatchObject({
accountId: null,
lists: {
items: ImmutableList(),
loaded: false,
isLoading: false,
},
});
});
// it('should handle LIST_ADDER_LISTS_FETCH_SUCCESS', () => {
// const state = ImmutableMap({
// accountId: null,
//
// lists: ImmutableMap({
// items: ImmutableList(),
// loaded: false,
// isLoading: false,
// }),
// });
// const action = {
// type: actions.LIST_ADDER_LISTS_FETCH_SUCCESS,
// };
// expect(reducer(state, action)).toEqual(ImmutableMap({
// accountId: null,
//
// lists: ImmutableMap({
// items: ImmutableList(),
// loaded: true,
// isLoading: false,
// }),
// }));
// });
});