2022-01-30 09:46:57 -08:00
|
|
|
import { List as ImmutableList } from 'immutable';
|
|
|
|
|
2022-02-02 05:33:12 -08:00
|
|
|
import { MODAL_OPEN, MODAL_CLOSE } from 'soapbox/actions/modals';
|
2022-01-10 14:25:06 -08:00
|
|
|
|
2022-02-02 05:33:12 -08:00
|
|
|
import reducer from '../modals';
|
2020-06-09 18:08:07 -07:00
|
|
|
|
|
|
|
describe('modal reducer', () => {
|
|
|
|
it('should return the initial state', () => {
|
2022-01-30 09:46:57 -08:00
|
|
|
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', () => {
|
2022-01-30 09:46:57 -08:00
|
|
|
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
|
|
|
};
|
2022-01-30 09:46:57 -08:00
|
|
|
expect(reducer(state, action)).toMatchObject(ImmutableList([{
|
2020-07-09 16:44:23 -07:00
|
|
|
modalType: 'type1',
|
|
|
|
modalProps: { props1: '1' },
|
2022-01-30 09:46:57 -08:00
|
|
|
}]));
|
2020-07-09 16:44:23 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should handle MODAL_CLOSE', () => {
|
2022-01-30 09:46:57 -08:00
|
|
|
const state = ImmutableList([{
|
2020-07-09 16:44:23 -07:00
|
|
|
modalType: 'type1',
|
|
|
|
modalProps: { props1: '1' },
|
2022-01-30 09:46:57 -08:00
|
|
|
}]);
|
|
|
|
const action = {
|
|
|
|
type: MODAL_CLOSE,
|
2020-07-09 17:37:04 -07:00
|
|
|
};
|
2022-01-30 09:46:57 -08: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,
|
2022-01-30 09:46:57 -08:00
|
|
|
modalType: 'type2',
|
2020-07-09 17:37:04 -07:00
|
|
|
};
|
2022-01-30 09:46:57 -08: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
|
|
|
});
|