Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak 2022-04-14 00:04:41 +02:00
parent 50797119ff
commit 2faaa75d9c
2 changed files with 60 additions and 60 deletions

View File

@ -1,4 +1,4 @@
import { Map as ImmutableMap, List as ImmutableList } from 'immutable'; import { List as ImmutableList, Record as ImmutableRecord } from 'immutable';
import * as actions from 'soapbox/actions/lists'; import * as actions from 'soapbox/actions/lists';
@ -6,87 +6,87 @@ import reducer from '../list_adder';
describe('list_adder reducer', () => { describe('list_adder reducer', () => {
it('should return the initial state', () => { it('should return the initial state', () => {
expect(reducer(undefined, {})).toEqual(ImmutableMap({ expect(reducer(undefined, {})).toMatchObject({
accountId: null, accountId: null,
lists: ImmutableMap({ lists: {
items: ImmutableList(), items: ImmutableList(),
loaded: false, loaded: false,
isLoading: false, isLoading: false,
}), },
})); });
}); });
it('should handle LIST_ADDER_RESET', () => { it('should handle LIST_ADDER_RESET', () => {
const state = ImmutableMap({ const state = ImmutableRecord({
accountId: null, accountId: null,
lists: ImmutableMap({ lists: ImmutableRecord({
items: ImmutableList(), items: ImmutableList(),
loaded: false, loaded: false,
isLoading: false, isLoading: false,
}), })(),
}); })();
const action = { const action = {
type: actions.LIST_ADDER_RESET, type: actions.LIST_ADDER_RESET,
}; };
expect(reducer(state, action)).toEqual(ImmutableMap({ expect(reducer(state, action)).toMatchObject({
accountId: null, accountId: null,
lists: ImmutableMap({ lists: {
items: ImmutableList(), items: ImmutableList(),
loaded: false, loaded: false,
isLoading: false, isLoading: false,
}), },
})); });
}); });
it('should handle LIST_ADDER_LISTS_FETCH_REQUEST', () => { it('should handle LIST_ADDER_LISTS_FETCH_REQUEST', () => {
const state = ImmutableMap({ const state = ImmutableRecord({
accountId: null, accountId: null,
lists: ImmutableMap({ lists: ImmutableRecord({
items: ImmutableList(), items: ImmutableList(),
loaded: false, loaded: false,
isLoading: false, isLoading: false,
}), })(),
}); })();
const action = { const action = {
type: actions.LIST_ADDER_LISTS_FETCH_REQUEST, type: actions.LIST_ADDER_LISTS_FETCH_REQUEST,
}; };
expect(reducer(state, action)).toEqual(ImmutableMap({ expect(reducer(state, action)).toMatchObject({
accountId: null, accountId: null,
lists: ImmutableMap({ lists: {
items: ImmutableList(), items: ImmutableList(),
loaded: false, loaded: false,
isLoading: true, isLoading: true,
}), },
})); });
}); });
it('should handle LIST_ADDER_LISTS_FETCH_FAIL', () => { it('should handle LIST_ADDER_LISTS_FETCH_FAIL', () => {
const state = ImmutableMap({ const state = ImmutableRecord({
accountId: null, accountId: null,
lists: ImmutableMap({ lists: ImmutableRecord({
items: ImmutableList(), items: ImmutableList(),
loaded: false, loaded: false,
isLoading: false, isLoading: false,
}), })(),
}); })();
const action = { const action = {
type: actions.LIST_ADDER_LISTS_FETCH_FAIL, type: actions.LIST_ADDER_LISTS_FETCH_FAIL,
}; };
expect(reducer(state, action)).toEqual(ImmutableMap({ expect(reducer(state, action)).toMatchObject({
accountId: null, accountId: null,
lists: ImmutableMap({ lists: {
items: ImmutableList(), items: ImmutableList(),
loaded: false, loaded: false,
isLoading: false, isLoading: false,
}), },
})); });
}); });
// it('should handle LIST_ADDER_LISTS_FETCH_SUCCESS', () => { // it('should handle LIST_ADDER_LISTS_FETCH_SUCCESS', () => {

View File

@ -1,4 +1,4 @@
import { Map as ImmutableMap, List as ImmutableList } from 'immutable'; import { Map as ImmutableMap, List as ImmutableList, Record as ImmutableRecord } from 'immutable';
import * as actions from 'soapbox/actions/lists'; import * as actions from 'soapbox/actions/lists';
@ -6,83 +6,83 @@ import reducer from '../list_editor';
describe('list_editor reducer', () => { describe('list_editor reducer', () => {
it('should return the initial state', () => { it('should return the initial state', () => {
expect(reducer(undefined, {})).toEqual(ImmutableMap({ expect(reducer(undefined, {})).toMatchObject({
listId: null, listId: null,
isSubmitting: false, isSubmitting: false,
isChanged: false, isChanged: false,
title: '', title: '',
accounts: ImmutableMap({ accounts: {
items: ImmutableList(), items: ImmutableList(),
loaded: false, loaded: false,
isLoading: false, isLoading: false,
}), },
suggestions: ImmutableMap({ suggestions: {
value: '', value: '',
items: ImmutableList(), items: ImmutableList(),
}), },
})); });
}); });
it('should handle LIST_EDITOR_RESET', () => { it('should handle LIST_EDITOR_RESET', () => {
const state = ImmutableMap({ const state = ImmutableRecord({
listId: null, listId: null,
isSubmitting: false, isSubmitting: false,
isChanged: false, isChanged: false,
title: '', title: '',
accounts: ImmutableMap({ accounts: ImmutableRecord({
items: ImmutableList(), items: ImmutableList(),
loaded: false, loaded: false,
isLoading: false, isLoading: false,
}), })(),
suggestions: ImmutableMap({ suggestions: ImmutableRecord({
value: '', value: '',
items: ImmutableList(), items: ImmutableList(),
}), })(),
}); })();
const action = { const action = {
type: actions.LIST_EDITOR_RESET, type: actions.LIST_EDITOR_RESET,
}; };
expect(reducer(state, action)).toEqual(ImmutableMap({ expect(reducer(state, action)).toMatchObject({
listId: null, listId: null,
isSubmitting: false, isSubmitting: false,
isChanged: false, isChanged: false,
title: '', title: '',
accounts: ImmutableMap({ accounts: {
items: ImmutableList(), items: ImmutableList(),
loaded: false, loaded: false,
isLoading: false, isLoading: false,
}), },
suggestions: ImmutableMap({ suggestions: {
value: '', value: '',
items: ImmutableList(), items: ImmutableList(),
}), },
})); });
}); });
it('should handle LIST_EDITOR_SETUP', () => { it('should handle LIST_EDITOR_SETUP', () => {
const state = ImmutableMap({ const state = ImmutableRecord({
listId: null, listId: null,
isSubmitting: false, isSubmitting: false,
isChanged: false, isChanged: false,
title: '', title: '',
accounts: ImmutableMap({ accounts: ImmutableRecord({
items: ImmutableList(), items: ImmutableList(),
loaded: false, loaded: false,
isLoading: false, isLoading: false,
}), })(),
suggestions: ImmutableMap({ suggestions: ImmutableRecord({
value: '', value: '',
items: ImmutableList(), items: ImmutableList(),
}), })(),
}); })();
const action = { const action = {
type: actions.LIST_EDITOR_SETUP, type: actions.LIST_EDITOR_SETUP,
list: ImmutableMap({ list: ImmutableMap({
@ -90,23 +90,23 @@ describe('list_editor reducer', () => {
title: 'list 1', title: 'list 1',
}), }),
}; };
expect(reducer(state, action)).toEqual(ImmutableMap({ expect(reducer(state, action)).toMatchObject({
listId: '22', listId: '22',
isSubmitting: false, isSubmitting: false,
isChanged: false, isChanged: false,
title: 'list 1', title: 'list 1',
accounts: ImmutableMap({ accounts: {
items: ImmutableList(), items: ImmutableList(),
loaded: false, loaded: false,
isLoading: false, isLoading: false,
}), },
suggestions: ImmutableMap({ suggestions: {
value: '', value: '',
items: ImmutableList(), items: ImmutableList(),
}), },
})); });
}); });
it('should handle LIST_EDITOR_TITLE_CHANGE', () => { it('should handle LIST_EDITOR_TITLE_CHANGE', () => {