bigbuffet-rw/app/soapbox/reducers/__tests__/modal-test.js
marcin mikołajczak 807b3c7e5b Use stack for modals
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2022-01-30 18:53:47 +01:00

57 lines
1.3 KiB
JavaScript

import { List as ImmutableList } from 'immutable';
import { MODAL_OPEN, MODAL_CLOSE } from 'soapbox/actions/modal';
import reducer from '../modal';
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',
}]));
});
});