2022-06-12 07:30:48 -07:00
|
|
|
import { Record as ImmutableRecord } from 'immutable';
|
2022-01-10 14:25:06 -08:00
|
|
|
|
2020-07-09 16:44:23 -07:00
|
|
|
import {
|
|
|
|
MUTES_INIT_MODAL,
|
|
|
|
MUTES_TOGGLE_HIDE_NOTIFICATIONS,
|
|
|
|
} from 'soapbox/actions/mutes';
|
2022-01-10 14:25:06 -08:00
|
|
|
|
2022-01-10 14:01:24 -08:00
|
|
|
import reducer from '../mutes';
|
2020-06-09 18:08:07 -07:00
|
|
|
|
|
|
|
describe('mutes reducer', () => {
|
|
|
|
it('should return the initial state', () => {
|
2022-07-06 09:53:55 -07:00
|
|
|
expect(reducer(undefined, {} as any).toJS()).toEqual({
|
2022-06-12 07:30:48 -07:00
|
|
|
new: {
|
2020-06-09 18:08:07 -07:00
|
|
|
isSubmitting: false,
|
2022-06-12 07:30:48 -07:00
|
|
|
accountId: null,
|
2020-06-09 18:08:07 -07:00
|
|
|
notifications: true,
|
2022-07-31 02:57:31 -07:00
|
|
|
duration: 0,
|
2022-06-12 07:30:48 -07:00
|
|
|
},
|
|
|
|
});
|
2020-06-09 18:08:07 -07:00
|
|
|
});
|
2020-07-09 16:44:23 -07:00
|
|
|
|
|
|
|
it('should handle MUTES_INIT_MODAL', () => {
|
2022-06-12 07:30:48 -07:00
|
|
|
const state = ImmutableRecord({
|
|
|
|
new: ImmutableRecord({
|
2020-07-09 16:44:23 -07:00
|
|
|
isSubmitting: false,
|
2022-06-12 07:30:48 -07:00
|
|
|
accountId: null,
|
2020-07-09 16:44:23 -07:00
|
|
|
notifications: true,
|
2022-07-31 02:57:31 -07:00
|
|
|
duration: 0,
|
2022-06-12 07:30:48 -07:00
|
|
|
})(),
|
|
|
|
})();
|
2020-07-09 16:44:23 -07:00
|
|
|
const action = {
|
|
|
|
type: MUTES_INIT_MODAL,
|
2022-06-12 07:30:48 -07:00
|
|
|
account: { id: 'account1' },
|
2020-07-09 17:37:04 -07:00
|
|
|
};
|
2022-06-12 07:30:48 -07:00
|
|
|
expect(reducer(state, action).toJS()).toEqual({
|
|
|
|
new: {
|
2020-07-09 16:44:23 -07:00
|
|
|
isSubmitting: false,
|
2022-06-12 07:30:48 -07:00
|
|
|
accountId: 'account1',
|
2020-07-09 16:44:23 -07:00
|
|
|
notifications: true,
|
2022-07-31 02:57:31 -07:00
|
|
|
duration: 0,
|
2022-06-12 07:30:48 -07:00
|
|
|
},
|
|
|
|
});
|
2020-07-09 16:44:23 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should handle MUTES_TOGGLE_HIDE_NOTIFICATIONS', () => {
|
2022-06-12 07:30:48 -07:00
|
|
|
const state = ImmutableRecord({
|
|
|
|
new: ImmutableRecord({
|
2022-06-12 11:29:28 -07:00
|
|
|
isSubmitting: false,
|
|
|
|
accountId: null,
|
2020-07-09 16:44:23 -07:00
|
|
|
notifications: true,
|
2022-07-31 02:57:31 -07:00
|
|
|
duration: 0,
|
2022-06-12 07:30:48 -07:00
|
|
|
})(),
|
|
|
|
})();
|
2020-07-09 16:44:23 -07:00
|
|
|
const action = {
|
|
|
|
type: MUTES_TOGGLE_HIDE_NOTIFICATIONS,
|
2020-07-09 17:37:04 -07:00
|
|
|
};
|
2022-06-12 07:30:48 -07:00
|
|
|
expect(reducer(state, action).toJS()).toEqual({
|
|
|
|
new: {
|
2022-06-12 11:29:28 -07:00
|
|
|
isSubmitting: false,
|
|
|
|
accountId: null,
|
2020-07-09 16:44:23 -07:00
|
|
|
notifications: false,
|
2022-07-31 02:57:31 -07:00
|
|
|
duration: 0,
|
2022-06-12 07:30:48 -07:00
|
|
|
},
|
|
|
|
});
|
2020-07-09 16:44:23 -07:00
|
|
|
});
|
|
|
|
|
2020-06-09 18:08:07 -07:00
|
|
|
});
|