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

34 lines
934 B
JavaScript
Raw Normal View History

2022-04-24 17:02:25 -07:00
import { Record as ImmutableRecord } from 'immutable';
2020-07-04 19:25:43 -07:00
import { PATRON_ACCOUNT_FETCH_SUCCESS } from '../../actions/patron';
import reducer from '../patron';
2020-06-09 18:08:07 -07:00
describe('patron reducer', () => {
it('should return the initial state', () => {
2022-04-24 17:02:25 -07:00
const result = reducer(undefined, {});
expect(ImmutableRecord.isRecord(result)).toBe(true);
expect(result.instance.url).toBe('');
2020-06-09 18:08:07 -07:00
});
2020-07-04 19:25:43 -07:00
describe('PATRON_ACCOUNT_FETCH_SUCCESS', () => {
it('should add the account', () => {
const action = {
type: PATRON_ACCOUNT_FETCH_SUCCESS,
account: {
url: 'https://gleasonator.com/users/alex',
is_patron: true,
},
};
2022-04-24 17:02:25 -07:00
const result = reducer(undefined, action);
expect(result.accounts.toJS()).toEqual({
'https://gleasonator.com/users/alex': {
is_patron: true,
url: 'https://gleasonator.com/users/alex',
2020-07-04 19:25:43 -07:00
},
2022-04-24 17:02:25 -07:00
});
2020-07-04 19:25:43 -07:00
});
});
2020-06-09 18:08:07 -07:00
});