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 { runSaga } from 'redux-saga';
20 import { takeLatest } from 'redux-saga/effects';
27 } from 'features/catalog/catalogConstants';
28 import catalogApi from '../catalogApi';
29 import { fetchWorkflow, updateWorkflow } from 'features/catalog/catalogActions';
33 } from 'features/catalog/catalogSagas';
35 jest.mock('../catalogApi');
37 describe('Catalog Sagas', () => {
38 it('should watch for `fetchWorkflow` action', () => {
39 const gen = catalogSaga();
41 expect(gen.next().value).toEqual(
42 takeLatest(fetchWorkflow, fetchWorkflowSaga)
44 expect(gen.next().value).toEqual(
45 takeLatest(SEARCH_CHANGED, debounceSearchChanged)
47 expect(gen.next().done).toBe(true);
50 it('should get workflows and put `updateWorkflow` action', async () => {
55 const searchNameFilter = undefined;
64 searchNameFilter: 'w',
67 id: 'c5b7ca1a0f7944bfa948b85b32c5f314',
70 versionStates: ['DRAFT'],
74 id: '221336ef3f1645c686bc81899368ac27',
77 versionStates: ['DRAFT'],
82 const dispatched = [];
84 catalogApi.getWorkflows.mockReturnValue(data);
88 dispatch: action => dispatched.push(action)
91 fetchWorkflow(sort, offset)
94 expect(dispatched).toEqual(
95 expect.arrayContaining([updateWorkflow({ sort, ...data })])
98 expect(catalogApi.getWorkflows).toBeCalledWith(