2020-06-09 18:08:07 -07:00
|
|
|
import reducer from '../alerts';
|
2020-07-14 16:21:49 -07:00
|
|
|
import { List as ImmutableList } from 'immutable';
|
2020-07-14 15:11:05 -07:00
|
|
|
import * as actions from 'soapbox/actions/alerts';
|
2020-06-09 18:08:07 -07:00
|
|
|
|
|
|
|
describe('alerts reducer', () => {
|
|
|
|
it('should return the initial state', () => {
|
|
|
|
expect(reducer(undefined, {})).toEqual(ImmutableList());
|
|
|
|
});
|
2020-07-05 17:38:32 -07:00
|
|
|
|
2020-07-14 15:11:05 -07:00
|
|
|
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-05 17:38:32 -07:00
|
|
|
|
2020-07-08 20:05:22 -07:00
|
|
|
// it('should handle ALERT_DISMISS', () => {
|
2020-07-14 15:11:05 -07:00
|
|
|
// 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,
|
2020-07-14 15:11:05 -07:00
|
|
|
// alert: { key: 0 },
|
2020-07-08 20:05:22 -07:00
|
|
|
// };
|
2020-07-14 15:11:05 -07:00
|
|
|
// expect(reducer(state, action).toJS()).toMatchObject([
|
|
|
|
// {
|
|
|
|
// key: 1,
|
|
|
|
// message: 'message_2',
|
|
|
|
// title: 'title_2',
|
|
|
|
// }
|
|
|
|
// ]);
|
2020-07-08 20:05:22 -07:00
|
|
|
// });
|
2020-07-05 17:38:32 -07:00
|
|
|
|
2020-07-14 15:11:05 -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',
|
|
|
|
},
|
|
|
|
]);
|
2020-07-14 15:11:05 -07:00
|
|
|
const action = {
|
|
|
|
type: actions.ALERT_CLEAR,
|
|
|
|
};
|
|
|
|
expect(reducer(state, action).toJS()).toMatchObject({
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-06-09 18:08:07 -07:00
|
|
|
});
|