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

58 lines
1.3 KiB
JavaScript
Raw Normal View History

import { List as ImmutableList } from 'immutable';
import { MODAL_OPEN, MODAL_CLOSE } from 'soapbox/actions/modals';
import reducer from '../modals';
2020-06-09 18:08:07 -07:00
describe('modal reducer', () => {
it('should return the initial state', () => {
expect(reducer(undefined, {})).toEqual(ImmutableList());
2020-06-09 18:08:07 -07:00
});
2020-07-09 16:44:23 -07:00
it('should handle MODAL_OPEN', () => {
const state = ImmutableList();
2020-07-09 16:44:23 -07:00
const action = {
type: MODAL_OPEN,
modalType: 'type1',
modalProps: { props1: '1' },
2020-07-09 17:37:04 -07:00
};
expect(reducer(state, action)).toMatchObject(ImmutableList([{
2020-07-09 16:44:23 -07:00
modalType: 'type1',
modalProps: { props1: '1' },
}]));
2020-07-09 16:44:23 -07:00
});
it('should handle MODAL_CLOSE', () => {
const state = ImmutableList([{
2020-07-09 16:44:23 -07:00
modalType: 'type1',
modalProps: { props1: '1' },
}]);
const action = {
type: MODAL_CLOSE,
2020-07-09 17:37:04 -07:00
};
expect(reducer(state, action)).toMatchObject(ImmutableList());
});
it('should handle MODAL_CLOSE with specified modalType', () => {
const state = ImmutableList([
{
modalType: 'type1',
},
{
modalType: 'type2',
},
{
modalType: 'type1',
},
]);
2020-07-09 16:44:23 -07:00
const action = {
type: MODAL_CLOSE,
modalType: 'type2',
2020-07-09 17:37:04 -07:00
};
expect(reducer(state, action)).toMatchObject(ImmutableList([{
modalType: 'type1',
}]));
2020-07-09 16:44:23 -07:00
});
2020-06-09 18:08:07 -07:00
});