Fix reducer tests
This commit is contained in:
parent
295eb40f14
commit
2e192153ed
4 changed files with 21 additions and 18 deletions
|
@ -6,11 +6,11 @@ import {
|
|||
SEARCH_EXPAND_SUCCESS,
|
||||
} from 'soapbox/actions/search';
|
||||
|
||||
import reducer from '../search';
|
||||
import reducer, { ReducerRecord } from '../search';
|
||||
|
||||
describe('search reducer', () => {
|
||||
it('should return the initial state', () => {
|
||||
expect(reducer(undefined, {})).toEqual(ImmutableMap({
|
||||
expect(reducer(undefined, {})).toEqual(ReducerRecord({
|
||||
value: '',
|
||||
submitted: false,
|
||||
submittedValue: '',
|
||||
|
@ -22,7 +22,7 @@ describe('search reducer', () => {
|
|||
|
||||
describe('SEARCH_CHANGE', () => {
|
||||
it('sets the value', () => {
|
||||
const state = ImmutableMap({ value: 'hell' });
|
||||
const state = ReducerRecord({ value: 'hell' });
|
||||
const action = { type: SEARCH_CHANGE, value: 'hello' };
|
||||
expect(reducer(state, action).get('value')).toEqual('hello');
|
||||
});
|
||||
|
@ -30,7 +30,7 @@ describe('search reducer', () => {
|
|||
|
||||
describe('SEARCH_CLEAR', () => {
|
||||
it('resets the state', () => {
|
||||
const state = ImmutableMap({
|
||||
const state = ReducerRecord({
|
||||
value: 'hello world',
|
||||
submitted: true,
|
||||
submittedValue: 'hello world',
|
||||
|
@ -41,7 +41,7 @@ describe('search reducer', () => {
|
|||
|
||||
const action = { type: SEARCH_CLEAR };
|
||||
|
||||
const expected = ImmutableMap({
|
||||
const expected = ReducerRecord({
|
||||
value: '',
|
||||
submitted: false,
|
||||
submittedValue: '',
|
||||
|
@ -56,7 +56,7 @@ describe('search reducer', () => {
|
|||
|
||||
describe(SEARCH_EXPAND_SUCCESS, () => {
|
||||
it('imports hashtags as maps', () => {
|
||||
const state = ImmutableMap({
|
||||
const state = ReducerRecord({
|
||||
value: 'artist',
|
||||
submitted: true,
|
||||
submittedValue: 'artist',
|
||||
|
@ -82,7 +82,7 @@ describe('search reducer', () => {
|
|||
searchType: 'hashtags',
|
||||
};
|
||||
|
||||
const expected = ImmutableMap({
|
||||
const expected = ReducerRecord({
|
||||
value: 'artist',
|
||||
submitted: true,
|
||||
submittedValue: 'artist',
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
import { Map as ImmutableMap, List as ImmutableList, fromJS } from 'immutable';
|
||||
import {
|
||||
Record as ImmutableRecord,
|
||||
fromJS,
|
||||
} from 'immutable';
|
||||
|
||||
import { SUGGESTIONS_DISMISS } from 'soapbox/actions/suggestions';
|
||||
|
||||
|
@ -6,10 +9,10 @@ import reducer from '../suggestions';
|
|||
|
||||
describe('suggestions reducer', () => {
|
||||
it('should return the initial state', () => {
|
||||
expect(reducer(undefined, {})).toEqual(ImmutableMap({
|
||||
items: ImmutableList(),
|
||||
isLoading: false,
|
||||
}));
|
||||
const result = reducer(undefined, {});
|
||||
expect(ImmutableRecord.isRecord(result)).toBe(true);
|
||||
expect(result.items.isEmpty()).toBe(true);
|
||||
expect(result.isLoading).toBe(false);
|
||||
});
|
||||
|
||||
describe('SUGGESTIONS_DISMISS', () => {
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
|
||||
import { Record as ImmutableRecord } from 'immutable';
|
||||
|
||||
import reducer from '../trends';
|
||||
|
||||
describe('trends reducer', () => {
|
||||
it('should return the initial state', () => {
|
||||
expect(reducer(undefined, {})).toEqual(ImmutableMap({
|
||||
items: ImmutableList(),
|
||||
isLoading: false,
|
||||
}));
|
||||
const result = reducer(undefined, {});
|
||||
expect(ImmutableRecord.isRecord(result)).toBe(true);
|
||||
expect(result.items.isEmpty()).toBe(true);
|
||||
expect(result.isLoading).toBe(false);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -25,7 +25,7 @@ import {
|
|||
|
||||
import type { AnyAction } from 'redux';
|
||||
|
||||
const ReducerRecord = ImmutableRecord({
|
||||
export const ReducerRecord = ImmutableRecord({
|
||||
value: '',
|
||||
submitted: false,
|
||||
submittedValue: '',
|
||||
|
|
Loading…
Reference in a new issue