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

75 lines
1.6 KiB
JavaScript
Raw Normal View History

2020-07-14 16:21:49 -07:00
import { List as ImmutableList } from 'immutable';
import * as actions from 'soapbox/actions/alerts';
2022-01-10 14:01:24 -08:00
import reducer from '../alerts';
2020-06-09 18:08:07 -07:00
describe('alerts reducer', () => {
it('should return the initial state', () => {
expect(reducer(undefined, {})).toEqual(ImmutableList());
});
it('should handle ALERT_SHOW', () => {
const state = ImmutableList([]);
const action = {
type: actions.ALERT_SHOW,
title: 'alert_title',
message: 'this is an alert message',
};
expect(reducer(state, action).toJS()).toMatchObject([
{
key: 0,
message: 'this is an alert message',
title: 'alert_title',
},
]);
});
2020-07-08 20:05:22 -07:00
// it('should handle ALERT_DISMISS', () => {
// const state = ImmutableList([
// {
// key: 0,
// message: 'message_1',
// title: 'title_1',
// },
// {
// key: 1,
// message: 'message_2',
// title: 'title_2',
// },
// ]);
2020-07-08 20:05:22 -07:00
// const action = {
// type: actions.ALERT_DISMISS,
// alert: { key: 0 },
2020-07-08 20:05:22 -07:00
// };
// expect(reducer(state, action).toJS()).toMatchObject([
// {
// key: 1,
// message: 'message_2',
// title: 'title_2',
// }
// ]);
2020-07-08 20:05:22 -07:00
// });
it('should handle ALERT_CLEAR', () => {
2020-07-28 12:13:29 -07:00
const state = ImmutableList([
{
key: 0,
message: 'message_1',
title: 'title_1',
},
{
key: 1,
message: 'message_2',
title: 'title_2',
},
]);
const action = {
type: actions.ALERT_CLEAR,
};
expect(reducer(state, action).toJS()).toMatchObject({
});
});
2020-06-09 18:08:07 -07:00
});