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';
@ -6,87 +6,87 @@ import reducer from '../list_adder';
describe('list_adder reducer', () => {
it('should return the initial state', () => {
expect(reducer(undefined, {})).toEqual(ImmutableMap({
expect(reducer(undefined, {})).toMatchObject({
accountId: null,
lists: ImmutableMap({
lists: {
items: ImmutableList(),
loaded: false,
isLoading: false,
}),
}));
},
});
});
it('should handle LIST_ADDER_RESET', () => {
const state = ImmutableMap({
const state = ImmutableRecord({
accountId: null,
lists: ImmutableMap({
lists: ImmutableRecord({
items: ImmutableList(),
loaded: false,
isLoading: false,
}),
});
})(),
})();
const action = {
type: actions.LIST_ADDER_RESET,
};
expect(reducer(state, action)).toEqual(ImmutableMap({
expect(reducer(state, action)).toMatchObject({
accountId: null,
lists: ImmutableMap({
lists: {
items: ImmutableList(),
loaded: false,
isLoading: false,
}),
}));
},
});
});
it('should handle LIST_ADDER_LISTS_FETCH_REQUEST', () => {
const state = ImmutableMap({
const state = ImmutableRecord({
accountId: null,
lists: ImmutableMap({
lists: ImmutableRecord({
items: ImmutableList(),
loaded: false,
isLoading: false,
}),
});
})(),
})();
const action = {
type: actions.LIST_ADDER_LISTS_FETCH_REQUEST,
};
expect(reducer(state, action)).toEqual(ImmutableMap({
expect(reducer(state, action)).toMatchObject({
accountId: null,
lists: ImmutableMap({
lists: {
items: ImmutableList(),
loaded: false,
isLoading: true,
}),
}));
},
});
});
it('should handle LIST_ADDER_LISTS_FETCH_FAIL', () => {
const state = ImmutableMap({
const state = ImmutableRecord({
accountId: null,
lists: ImmutableMap({
lists: ImmutableRecord({
items: ImmutableList(),
loaded: false,
isLoading: false,
}),
});
})(),
})();
const action = {
type: actions.LIST_ADDER_LISTS_FETCH_FAIL,
};
expect(reducer(state, action)).toEqual(ImmutableMap({
expect(reducer(state, action)).toMatchObject({
accountId: null,
lists: ImmutableMap({
lists: {
items: ImmutableList(),
loaded: false,
isLoading: false,
}),
}));
},
});
});
// 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';
@ -6,83 +6,83 @@ import reducer from '../list_editor';
describe('list_editor reducer', () => {
it('should return the initial state', () => {
expect(reducer(undefined, {})).toEqual(ImmutableMap({
expect(reducer(undefined, {})).toMatchObject({
listId: null,
isSubmitting: false,
isChanged: false,
title: '',
accounts: ImmutableMap({
accounts: {
items: ImmutableList(),
loaded: false,
isLoading: false,
}),
},
suggestions: ImmutableMap({
suggestions: {
value: '',
items: ImmutableList(),
}),
}));
},
});
});
it('should handle LIST_EDITOR_RESET', () => {
const state = ImmutableMap({
const state = ImmutableRecord({
listId: null,
isSubmitting: false,
isChanged: false,
title: '',
accounts: ImmutableMap({
accounts: ImmutableRecord({
items: ImmutableList(),
loaded: false,
isLoading: false,
}),
})(),
suggestions: ImmutableMap({
suggestions: ImmutableRecord({
value: '',
items: ImmutableList(),
}),
});
})(),
})();
const action = {
type: actions.LIST_EDITOR_RESET,
};
expect(reducer(state, action)).toEqual(ImmutableMap({
expect(reducer(state, action)).toMatchObject({
listId: null,
isSubmitting: false,
isChanged: false,
title: '',
accounts: ImmutableMap({
accounts: {
items: ImmutableList(),
loaded: false,
isLoading: false,
}),
},
suggestions: ImmutableMap({
suggestions: {
value: '',
items: ImmutableList(),
}),
}));
},
});
});
it('should handle LIST_EDITOR_SETUP', () => {
const state = ImmutableMap({
const state = ImmutableRecord({
listId: null,
isSubmitting: false,
isChanged: false,
title: '',
accounts: ImmutableMap({
accounts: ImmutableRecord({
items: ImmutableList(),
loaded: false,
isLoading: false,
}),
})(),
suggestions: ImmutableMap({
suggestions: ImmutableRecord({
value: '',
items: ImmutableList(),
}),
});
})(),
})();
const action = {
type: actions.LIST_EDITOR_SETUP,
list: ImmutableMap({
@ -90,23 +90,23 @@ describe('list_editor reducer', () => {
title: 'list 1',
}),
};
expect(reducer(state, action)).toEqual(ImmutableMap({
expect(reducer(state, action)).toMatchObject({
listId: '22',
isSubmitting: false,
isChanged: false,
title: 'list 1',
accounts: ImmutableMap({
accounts: {
items: ImmutableList(),
loaded: false,
isLoading: false,
}),
},
suggestions: ImmutableMap({
suggestions: {
value: '',
items: ImmutableList(),
}),
}));
},
});
});
it('should handle LIST_EDITOR_TITLE_CHANGE', () => {