Migrate sdc-sdc-workflow-designer docs
[sdc/sdc-workflow-designer.git] / workflow-designer-ui / src / main / frontend / src / shared / loader / __tests__ / loaderReducer-test.js
1 /*
2 * Copyright © 2018 European Support Limited
3 *
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
7 *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16
17 'use strict';
18
19 import loaderReducer from 'shared/loader/LoaderReducer';
20 import {
21     initialState,
22     sendRequestAction,
23     recieveResponseAction
24 } from 'shared/loader/LoaderConstants';
25
26 describe('Loader reducer', () => {
27     it('return initial state', () => {
28         expect(loaderReducer(undefined, {})).toEqual(initialState);
29     });
30
31     it('send request action test', () => {
32         const url = 'TEST';
33         const loaderData = {
34             fetchingRequests: 1,
35             currentlyFetching: [url],
36             isLoading: true
37         };
38
39         expect(loaderReducer(initialState, sendRequestAction(url))).toEqual(
40             loaderData
41         );
42     });
43
44     it('recieve response action test', () => {
45         const url = 'TEST';
46         const loaderData = {
47             fetchingRequests: 1,
48             currentlyFetching: [url],
49             isLoading: true
50         };
51
52         expect(loaderReducer(loaderData, recieveResponseAction(url))).toEqual(
53             initialState
54         );
55     });
56 });