bigbuffet-rw/app/soapbox/reducers/__tests__/mutes.test.ts

68 lines
1.5 KiB
TypeScript
Raw Normal View History

import { Record as ImmutableRecord } from 'immutable';
2020-07-09 16:44:23 -07:00
import {
MUTES_INIT_MODAL,
MUTES_TOGGLE_HIDE_NOTIFICATIONS,
} from 'soapbox/actions/mutes';
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({
new: {
2020-06-09 18:08:07 -07:00
isSubmitting: false,
accountId: null,
2020-06-09 18:08:07 -07:00
notifications: true,
duration: 0,
},
});
2020-06-09 18:08:07 -07:00
});
2020-07-09 16:44:23 -07:00
it('should handle MUTES_INIT_MODAL', () => {
const state = ImmutableRecord({
new: ImmutableRecord({
2020-07-09 16:44:23 -07:00
isSubmitting: false,
accountId: null,
2020-07-09 16:44:23 -07:00
notifications: true,
duration: 0,
})(),
})();
2020-07-09 16:44:23 -07:00
const action = {
type: MUTES_INIT_MODAL,
account: { id: 'account1' },
2020-07-09 17:37:04 -07:00
};
expect(reducer(state, action).toJS()).toEqual({
new: {
2020-07-09 16:44:23 -07:00
isSubmitting: false,
accountId: 'account1',
2020-07-09 16:44:23 -07:00
notifications: true,
duration: 0,
},
});
2020-07-09 16:44:23 -07:00
});
it('should handle MUTES_TOGGLE_HIDE_NOTIFICATIONS', () => {
const state = ImmutableRecord({
new: ImmutableRecord({
isSubmitting: false,
accountId: null,
2020-07-09 16:44:23 -07:00
notifications: true,
duration: 0,
})(),
})();
2020-07-09 16:44:23 -07:00
const action = {
type: MUTES_TOGGLE_HIDE_NOTIFICATIONS,
2020-07-09 17:37:04 -07:00
};
expect(reducer(state, action).toJS()).toEqual({
new: {
isSubmitting: false,
accountId: null,
2020-07-09 16:44:23 -07:00
notifications: false,
duration: 0,
},
});
2020-07-09 16:44:23 -07:00
});
2020-06-09 18:08:07 -07:00
});