pleroma/app/soapbox/reducers/__tests__/suggestions-test.js

43 lines
1.1 KiB
JavaScript
Raw Normal View History

2022-05-14 12:13:58 -07:00
import {
Record as ImmutableRecord,
fromJS,
} from 'immutable';
2021-10-02 13:18:27 -07:00
import { SUGGESTIONS_DISMISS } from 'soapbox/actions/suggestions';
2022-01-10 14:01:24 -08:00
import reducer from '../suggestions';
2020-06-09 18:08:07 -07:00
describe('suggestions reducer', () => {
it('should return the initial state', () => {
2022-05-14 12:13:58 -07:00
const result = reducer(undefined, {});
expect(ImmutableRecord.isRecord(result)).toBe(true);
expect(result.items.isEmpty()).toBe(true);
expect(result.isLoading).toBe(false);
2020-06-09 18:08:07 -07:00
});
2021-10-02 13:18:27 -07:00
describe('SUGGESTIONS_DISMISS', () => {
it('should remove the account', () => {
const action = { type: SUGGESTIONS_DISMISS, id: '123' };
const state = fromJS({
items: [
{ account: '123', source: 'past_interactions' },
{ account: '456', source: 'past_interactions' },
{ account: '789', source: 'past_interactions' },
],
isLoading: false,
});
const expected = fromJS({
items: [
{ account: '456', source: 'past_interactions' },
{ account: '789', source: 'past_interactions' },
],
isLoading: false,
});
expect(reducer(state, action)).toEqual(expected);
});
});
2020-06-09 18:08:07 -07:00
});