bigbuffet-rw/app/soapbox/reducers/__tests__/accounts.test.ts

30 lines
1,016 B
TypeScript
Raw Normal View History

2022-03-12 12:52:03 -08:00
import { Map as ImmutableMap, Record as ImmutableRecord } from 'immutable';
2022-03-08 21:59:59 -08:00
import { ACCOUNT_IMPORT } from 'soapbox/actions/importer';
2022-01-10 14:01:24 -08:00
import reducer from '../accounts';
2020-06-09 18:08:07 -07:00
describe('accounts reducer', () => {
it('should return the initial state', () => {
expect(reducer(undefined, {} as any)).toEqual(ImmutableMap());
2020-06-09 18:08:07 -07:00
});
2022-03-08 21:59:59 -08:00
describe('ACCOUNT_IMPORT', () => {
it('parses the account as a Record', () => {
const account = require('soapbox/__fixtures__/pleroma-account.json');
const action = { type: ACCOUNT_IMPORT, account };
const result = reducer(undefined, action).get('9v5bmRalQvjOy0ECcC');
2022-03-12 12:52:03 -08:00
expect(ImmutableRecord.isRecord(result)).toBe(true);
2022-03-08 21:59:59 -08:00
});
2022-03-12 12:52:03 -08:00
it('minifies a moved account', () => {
const account = require('soapbox/__fixtures__/account-moved.json');
const action = { type: ACCOUNT_IMPORT, account };
const result = reducer(undefined, action).get('106801667066418367');
2022-03-12 12:52:03 -08:00
expect(result.moved).toBe('107945464165013501');
});
});
2020-06-09 18:08:07 -07:00
});