2022-04-24 17:02:25 -07:00
|
|
|
import { Record as ImmutableRecord } from 'immutable';
|
2022-01-10 14:25:06 -08:00
|
|
|
|
2020-07-04 19:25:43 -07:00
|
|
|
import { PATRON_ACCOUNT_FETCH_SUCCESS } from '../../actions/patron';
|
2022-01-10 14:17:52 -08:00
|
|
|
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
|
|
|
});
|