Test that reducers parse as Records

This commit is contained in:
Alex Gleason 2022-03-08 23:59:59 -06:00
parent 10116a312a
commit 831741bea5
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
3 changed files with 25 additions and 2 deletions

View file

@ -1,4 +1,6 @@
import { Map as ImmutableMap } from 'immutable';
import { Map as ImmutableMap, Record } from 'immutable';
import { ACCOUNT_IMPORT } from 'soapbox/actions/importer';
import reducer from '../accounts';
// import * as actions from 'soapbox/actions/importer';
@ -10,6 +12,16 @@ describe('accounts reducer', () => {
expect(reducer(undefined, {})).toEqual(ImmutableMap());
});
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');
expect(Record.isRecord(result)).toBe(true);
});
});
// fails to add normalized accounts to state
// it('should handle ACCOUNT_IMPORT', () => {
// const state = ImmutableMap({ });

View file

@ -1,3 +1,5 @@
import { Record } from 'immutable';
import { INSTANCE_REMEMBER_SUCCESS } from 'soapbox/actions/instance';
import reducer from '../instance';
@ -23,6 +25,7 @@ describe('instance reducer', () => {
version: '0.0.0',
};
expect(Record.isRecord(result)).toBe(true);
expect(result.toJS()).toMatchObject(expected);
});

View file

@ -1,4 +1,4 @@
import { Map as ImmutableMap, fromJS } from 'immutable';
import { Map as ImmutableMap, Record, fromJS } from 'immutable';
import { STATUS_IMPORT } from 'soapbox/actions/importer';
import {
@ -14,6 +14,14 @@ describe('statuses reducer', () => {
});
describe('STATUS_IMPORT', () => {
it('parses the status as a Record', () => {
const status = require('soapbox/__fixtures__/pleroma-quote-post.json');
const action = { type: STATUS_IMPORT, status };
const result = reducer(undefined, action).get('AFmFMSpITT9xcOJKcK');
expect(Record.isRecord(result)).toBe(true);
});
it('fixes the order of mentions', () => {
const status = require('soapbox/__fixtures__/status-unordered-mentions.json');
const action = { type: STATUS_IMPORT, status };