2020-07-09 16:44:23 -07:00
|
|
|
import { MODAL_OPEN, MODAL_CLOSE } from 'soapbox/actions/modal';
|
2022-01-10 14:25:06 -08:00
|
|
|
|
2022-01-10 14:01:24 -08:00
|
|
|
import reducer from '../modal';
|
2020-06-09 18:08:07 -07:00
|
|
|
|
|
|
|
describe('modal reducer', () => {
|
|
|
|
it('should return the initial state', () => {
|
|
|
|
expect(reducer(undefined, {})).toEqual({
|
|
|
|
modalType: null,
|
|
|
|
modalProps: {},
|
2022-01-06 15:41:07 -08:00
|
|
|
noPop: false,
|
2020-06-09 18:08:07 -07:00
|
|
|
});
|
|
|
|
});
|
2020-07-09 16:44:23 -07:00
|
|
|
|
|
|
|
it('should handle MODAL_OPEN', () => {
|
|
|
|
const state = {
|
|
|
|
modalType: null,
|
|
|
|
modalProps: {},
|
2022-01-06 15:41:07 -08:00
|
|
|
noPop: false,
|
2020-07-09 17:37:04 -07:00
|
|
|
};
|
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
|
|
|
};
|
2020-07-09 16:44:23 -07:00
|
|
|
expect(reducer(state, action)).toMatchObject({
|
|
|
|
modalType: 'type1',
|
|
|
|
modalProps: { props1: '1' },
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should handle MODAL_CLOSE', () => {
|
|
|
|
const state = {
|
|
|
|
modalType: 'type1',
|
|
|
|
modalProps: { props1: '1' },
|
2020-07-09 17:37:04 -07:00
|
|
|
};
|
2020-07-09 16:44:23 -07:00
|
|
|
const action = {
|
|
|
|
type: MODAL_CLOSE,
|
2020-07-09 17:37:04 -07:00
|
|
|
};
|
2020-07-09 16:44:23 -07:00
|
|
|
expect(reducer(state, action)).toMatchObject({
|
|
|
|
modalType: null,
|
|
|
|
modalProps: {},
|
2022-01-06 15:41:07 -08:00
|
|
|
noPop: false,
|
2020-07-09 16:44:23 -07:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-06-09 18:08:07 -07:00
|
|
|
});
|