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.
17 import { call, takeEvery } from 'redux-saga/effects';
21 } from 'features/workflow/create/createWorkflowSaga';
22 import { put } from 'redux-saga/effects';
23 import newWorkflowApi from 'features/workflow/create/createWorkflowApi';
24 import { SUBMIT_WORKFLOW } from 'features/workflow/create/createWorkflowConstants';
25 import { submitVersionAction } from 'features/version/create/createVersionConstants';
26 import { NEW_VERSION } from 'features/workflow/create/createWorkflowConstants';
30 } from 'features/workflow/workflowConstants';
31 import { genericNetworkErrorAction } from 'wfapp/appConstants';
33 describe('New workflow saga test', () => {
34 it('Create new workflow', () => {
35 const gen = watchWorkflow();
36 expect(gen.next().value).toEqual(
37 takeEvery(SUBMIT_WORKFLOW, watchSubmitWorkflow)
39 expect(gen.next().done).toEqual(true);
42 it('Submit new workflow', () => {
46 description: 'description'
49 const gen = watchSubmitWorkflow(action);
50 expect(gen.next().value).toEqual(
51 call(newWorkflowApi.createNewWorkflow, action.payload)
53 const history = undefined,
54 workflowId = undefined;
55 expect(gen.next(action.payload).value).toEqual(
56 put(submitVersionAction({ history, workflowId, ...NEW_VERSION }))
58 expect(gen.next().value).toEqual(
59 put(setWorkflowAction({ ...action.payload, id: undefined }))
62 expect(gen.throw({ error: 'error' }).value).toEqual(
63 put(clearWorkflowAction)
65 expect(gen.next().value).toEqual(
66 put(genericNetworkErrorAction({ error: 'error' }))
68 expect(gen.next().done).toBe(true);