2022-01-10 14:01:24 -08:00
|
|
|
import { Map as ImmutableMap } from 'immutable';
|
2022-01-10 14:25:06 -08:00
|
|
|
|
2022-03-18 09:08:42 -07:00
|
|
|
import { __stub } from 'soapbox/api';
|
2022-04-04 08:53:47 -07:00
|
|
|
import { mockStore } from 'soapbox/jest/test-helpers';
|
2022-01-10 14:25:06 -08:00
|
|
|
|
2022-01-10 14:17:52 -08:00
|
|
|
import { VERIFY_CREDENTIALS_REQUEST } from '../auth';
|
|
|
|
import { ACCOUNTS_IMPORT } from '../importer';
|
2021-09-22 07:23:37 -07:00
|
|
|
import {
|
|
|
|
MASTODON_PRELOAD_IMPORT,
|
|
|
|
preloadMastodon,
|
|
|
|
} from '../preload';
|
|
|
|
|
|
|
|
describe('preloadMastodon()', () => {
|
|
|
|
it('creates the expected actions', () => {
|
|
|
|
const data = require('soapbox/__fixtures__/mastodon_initial_state.json');
|
|
|
|
|
2022-03-18 09:08:42 -07:00
|
|
|
__stub(mock => {
|
|
|
|
mock.onGet('/api/v1/accounts/verify_credentials')
|
|
|
|
.reply(200, {});
|
|
|
|
});
|
2021-09-24 16:47:22 -07:00
|
|
|
|
2021-09-22 07:23:37 -07:00
|
|
|
const store = mockStore(ImmutableMap());
|
|
|
|
store.dispatch(preloadMastodon(data));
|
|
|
|
const actions = store.getActions();
|
|
|
|
|
|
|
|
expect(actions[0].type).toEqual(ACCOUNTS_IMPORT);
|
|
|
|
expect(actions[0].accounts[0].username).toEqual('Gargron');
|
|
|
|
expect(actions[0].accounts[1].username).toEqual('benis911');
|
|
|
|
|
2021-09-24 16:47:22 -07:00
|
|
|
expect(actions[1]).toEqual({
|
|
|
|
type: VERIFY_CREDENTIALS_REQUEST,
|
|
|
|
token: 'Nh15V9JWyY5Fshf2OJ_feNvOIkTV7YGVfEJFr0Y0D6Q',
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(actions[2]).toEqual({ type: MASTODON_PRELOAD_IMPORT, data });
|
2021-09-22 07:23:37 -07:00
|
|
|
});
|
|
|
|
});
|