8e9bdbd4220ff646d6565fd6fee60c7d83826a8a
[sdc/sdc-workflow-designer.git] /
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 import {
18     getInputOutput,
19     getCurrent,
20     getIsShowInputs,
21     getSearch,
22     getDataRows,
23     getTypes,
24     getError
25 } from 'features/version/inputOutput/inputOutputSelectors';
26
27 describe('Input/Output Selectors', () => {
28     const state = {
29         currentVersion: {
30             general: {
31                 id: '1e659854c7e240c881f1dd8d5bd833cc',
32                 name: '1.0',
33                 description: 'Initial version',
34                 baseId: null,
35                 creationTime: '2018-07-19T13:09:39.066+0000',
36                 modificationTime: '2018-07-19T13:09:39.355+0000',
37                 state: 'DRAFT',
38                 inputs: [],
39                 outputs: []
40             },
41             inputOutput: {
42                 current: 'outputs',
43                 inputs: [
44                     {
45                         name: 'IP Address',
46                         value: 'String',
47                         mandatory: true,
48                         type: 'Integer'
49                     },
50                     {
51                         name: 'MAC Address',
52                         value: 'String',
53                         mandatory: false,
54                         type: 'Integer'
55                     },
56                     {
57                         name: 'IP',
58                         value: 'String',
59                         mandatory: true,
60                         type: 'Boolean'
61                     },
62                     {
63                         name: 'IP',
64                         value: 'String',
65                         mandatory: false
66                     },
67                     {
68                         name: '',
69                         value: 'String',
70                         mandatory: false
71                     },
72                     {
73                         name: '',
74                         value: 'String',
75                         mandatory: false
76                     }
77                 ],
78                 outputs: [
79                     {
80                         name: 'IP Address',
81                         value: 'String',
82                         mandatory: true
83                     },
84                     {
85                         name: 'IP',
86                         value: 'String',
87                         mandatory: true
88                     },
89                     {
90                         name: 'IP',
91                         value: 'String',
92                         mandatory: false,
93                         type: 'Boolean'
94                     }
95                 ],
96                 search: 'IP',
97                 types: ['String', 'Boolean', 'Integer', 'Float'],
98                 error: {
99                     inputs: {
100                         alreadyExists: [1, 2],
101                         invalidCharacters: []
102                     },
103                     outputs: {
104                         alreadyExists: [1, 2],
105                         invalidCharacters: []
106                     }
107                 }
108             }
109         }
110     };
111
112     it('should `getInputOutput`', () => {
113         expect(getInputOutput(state)).toEqual(state.currentVersion.inputOutput);
114     });
115
116     it('should `getCurrent`', () => {
117         expect(getCurrent(state)).toEqual(
118             state.currentVersion.inputOutput.current
119         );
120     });
121
122     it('should `getIsShowInputs`', () => {
123         expect(getIsShowInputs(state)).toBeFalsy();
124     });
125
126     it('should `getSearch`', () => {
127         expect(getSearch(state)).toEqual(
128             state.currentVersion.inputOutput.search
129         );
130     });
131
132     it('should `getDataRows`', () => {
133         expect(getDataRows(state)).toEqual(
134             state.currentVersion.inputOutput.outputs
135         );
136     });
137
138     it('should `getTypes`', () => {
139         expect(getTypes(state)).toEqual(state.currentVersion.inputOutput.types);
140     });
141
142     it('should `getError`', () => {
143         expect(getError(state)).toEqual(
144             state.currentVersion.inputOutput.error[
145                 state.currentVersion.inputOutput.current
146             ]
147         );
148     });
149 });