2 * Copyright © 2018 European Support Limited
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http: //www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 import { NAME, ASC, DESC } from 'features/catalog/catalogConstants';
20 import catalogReducer, { initialState } from 'features/catalog/catalogReducer';
21 import { updateWorkflow, resetWorkflow } from 'features/catalog/catalogActions';
23 describe('Catalog Reducer', () => {
28 id: '755eab7752374a2380544065b59b082d',
30 description: 'description description 1'
33 id: 'ef8159204dac4c10a85b29ec30b4bd56',
35 description: 'description description 2'
54 id: '755eab7752374a2380544065b59b082d',
56 description: 'description description 11'
59 id: 'ef8159204dac4c10a85b29ec30b4bd56',
61 description: 'description description 22'
66 it('returns the initial state', () => {
67 expect(catalogReducer(undefined, {})).toEqual(initialState);
70 it('should replace results when page is first', () => {
71 expect(catalogReducer(state, updateWorkflow({ ...data }))).toEqual({
74 hasMore: data.results.length < data.total,
80 it('should add results when page is not first', () => {
82 catalogReducer(state, updateWorkflow({ ...data, page: 1 })).results
83 ).toEqual(expect.arrayContaining([...data.results, ...state.results]));
86 it('should reset state', () => {
87 expect(catalogReducer({ ...state, sort }, resetWorkflow())).toEqual({