bigbuffet-rw/app/soapbox/reducers/__tests__/modals-test.js
marcin mikołajczak a041a4452b Rename modal -> modals
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2022-02-02 16:36:20 +01:00

57 lines
1.3 KiB
JavaScript

import { List as ImmutableList } from 'immutable';
import { MODAL_OPEN, MODAL_CLOSE } from 'soapbox/actions/modals';
import reducer from '../modals';
describe('modal reducer', () => {
it('should return the initial state', () => {
expect(reducer(undefined, {})).toEqual(ImmutableList());
});
it('should handle MODAL_OPEN', () => {
const state = ImmutableList();
const action = {
type: MODAL_OPEN,
modalType: 'type1',
modalProps: { props1: '1' },
};
expect(reducer(state, action)).toMatchObject(ImmutableList([{
modalType: 'type1',
modalProps: { props1: '1' },
}]));
});
it('should handle MODAL_CLOSE', () => {
const state = ImmutableList([{
modalType: 'type1',
modalProps: { props1: '1' },
}]);
const action = {
type: MODAL_CLOSE,
};
expect(reducer(state, action)).toMatchObject(ImmutableList());
});
it('should handle MODAL_CLOSE with specified modalType', () => {
const state = ImmutableList([
{
modalType: 'type1',
},
{
modalType: 'type2',
},
{
modalType: 'type1',
},
]);
const action = {
type: MODAL_CLOSE,
modalType: 'type2',
};
expect(reducer(state, action)).toMatchObject(ImmutableList([{
modalType: 'type1',
}]));
});
});