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,
|
SEARCH_EXPAND_SUCCESS,
|
||||||
} from 'soapbox/actions/search';
|
} from 'soapbox/actions/search';
|
||||||
|
|
||||||
import reducer from '../search';
|
import reducer, { ReducerRecord } from '../search';
|
||||||
|
|
||||||
describe('search reducer', () => {
|
describe('search reducer', () => {
|
||||||
it('should return the initial state', () => {
|
it('should return the initial state', () => {
|
||||||
expect(reducer(undefined, {})).toEqual(ImmutableMap({
|
expect(reducer(undefined, {})).toEqual(ReducerRecord({
|
||||||
value: '',
|
value: '',
|
||||||
submitted: false,
|
submitted: false,
|
||||||
submittedValue: '',
|
submittedValue: '',
|
||||||
|
@ -22,7 +22,7 @@ describe('search reducer', () => {
|
||||||
|
|
||||||
describe('SEARCH_CHANGE', () => {
|
describe('SEARCH_CHANGE', () => {
|
||||||
it('sets the value', () => {
|
it('sets the value', () => {
|
||||||
const state = ImmutableMap({ value: 'hell' });
|
const state = ReducerRecord({ value: 'hell' });
|
||||||
const action = { type: SEARCH_CHANGE, value: 'hello' };
|
const action = { type: SEARCH_CHANGE, value: 'hello' };
|
||||||
expect(reducer(state, action).get('value')).toEqual('hello');
|
expect(reducer(state, action).get('value')).toEqual('hello');
|
||||||
});
|
});
|
||||||
|
@ -30,7 +30,7 @@ describe('search reducer', () => {
|
||||||
|
|
||||||
describe('SEARCH_CLEAR', () => {
|
describe('SEARCH_CLEAR', () => {
|
||||||
it('resets the state', () => {
|
it('resets the state', () => {
|
||||||
const state = ImmutableMap({
|
const state = ReducerRecord({
|
||||||
value: 'hello world',
|
value: 'hello world',
|
||||||
submitted: true,
|
submitted: true,
|
||||||
submittedValue: 'hello world',
|
submittedValue: 'hello world',
|
||||||
|
@ -41,7 +41,7 @@ describe('search reducer', () => {
|
||||||
|
|
||||||
const action = { type: SEARCH_CLEAR };
|
const action = { type: SEARCH_CLEAR };
|
||||||
|
|
||||||
const expected = ImmutableMap({
|
const expected = ReducerRecord({
|
||||||
value: '',
|
value: '',
|
||||||
submitted: false,
|
submitted: false,
|
||||||
submittedValue: '',
|
submittedValue: '',
|
||||||
|
@ -56,7 +56,7 @@ describe('search reducer', () => {
|
||||||
|
|
||||||
describe(SEARCH_EXPAND_SUCCESS, () => {
|
describe(SEARCH_EXPAND_SUCCESS, () => {
|
||||||
it('imports hashtags as maps', () => {
|
it('imports hashtags as maps', () => {
|
||||||
const state = ImmutableMap({
|
const state = ReducerRecord({
|
||||||
value: 'artist',
|
value: 'artist',
|
||||||
submitted: true,
|
submitted: true,
|
||||||
submittedValue: 'artist',
|
submittedValue: 'artist',
|
||||||
|
@ -82,7 +82,7 @@ describe('search reducer', () => {
|
||||||
searchType: 'hashtags',
|
searchType: 'hashtags',
|
||||||
};
|
};
|
||||||
|
|
||||||
const expected = ImmutableMap({
|
const expected = ReducerRecord({
|
||||||
value: 'artist',
|
value: 'artist',
|
||||||
submitted: true,
|
submitted: true,
|
||||||
submittedValue: 'artist',
|
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';
|
import { SUGGESTIONS_DISMISS } from 'soapbox/actions/suggestions';
|
||||||
|
|
||||||
|
@ -6,10 +9,10 @@ import reducer from '../suggestions';
|
||||||
|
|
||||||
describe('suggestions reducer', () => {
|
describe('suggestions reducer', () => {
|
||||||
it('should return the initial state', () => {
|
it('should return the initial state', () => {
|
||||||
expect(reducer(undefined, {})).toEqual(ImmutableMap({
|
const result = reducer(undefined, {});
|
||||||
items: ImmutableList(),
|
expect(ImmutableRecord.isRecord(result)).toBe(true);
|
||||||
isLoading: false,
|
expect(result.items.isEmpty()).toBe(true);
|
||||||
}));
|
expect(result.isLoading).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('SUGGESTIONS_DISMISS', () => {
|
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';
|
import reducer from '../trends';
|
||||||
|
|
||||||
describe('trends reducer', () => {
|
describe('trends reducer', () => {
|
||||||
it('should return the initial state', () => {
|
it('should return the initial state', () => {
|
||||||
expect(reducer(undefined, {})).toEqual(ImmutableMap({
|
const result = reducer(undefined, {});
|
||||||
items: ImmutableList(),
|
expect(ImmutableRecord.isRecord(result)).toBe(true);
|
||||||
isLoading: false,
|
expect(result.items.isEmpty()).toBe(true);
|
||||||
}));
|
expect(result.isLoading).toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -25,7 +25,7 @@ import {
|
||||||
|
|
||||||
import type { AnyAction } from 'redux';
|
import type { AnyAction } from 'redux';
|
||||||
|
|
||||||
const ReducerRecord = ImmutableRecord({
|
export const ReducerRecord = ImmutableRecord({
|
||||||
value: '',
|
value: '',
|
||||||
submitted: false,
|
submitted: false,
|
||||||
submittedValue: '',
|
submittedValue: '',
|
||||||
|
|
Loading…
Reference in a new issue