Refresh option in validation result page
[sdc.git] / openecomp-ui / test / softwareProduct / validationResults / SoftwareProductValidationResultsView.test.js
1 /*
2  * Copyright © 2019 Vodafone Group
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 React from 'react';
18 import { mapStateToProps } from 'sdc-app/onboarding/softwareProduct/validationResults/SoftwareProductValidationResults.js';
19 import SoftwareProductValidationResultsView from 'sdc-app/onboarding/softwareProduct/validationResults/SoftwareProductValidationResultsView.jsx';
20 import { VSPTestResultsSuccessFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationResultsFactory.js';
21 import { VSPTestResultKeysFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationResultsFactory.js';
22 import { VSPTestResultsFailureFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationResultsFactory.js';
23 import { VSPTestsMapFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js';
24 import { VSPChecksFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js';
25
26 import TestUtils from 'react-dom/test-utils';
27
28 describe('SoftwareProductValidationResults Mapper and View Classes', () => {
29      it('mapStateToProps mapper exists', () => {
30         expect(mapStateToProps).toBeTruthy();
31     });
32
33     it('mapStateToProps fail data test', () => {
34         const vspTestResults = VSPTestResultsFailureFactory.build();
35         const vspTestsMap = VSPTestsMapFactory.build();
36         const testResultKeys = VSPTestResultKeysFactory.build();
37         const version = {
38             name: 1
39         };
40         const softwareProductId = '1234';
41         var testResultToDisplay = {};
42         var vspIdAndVer = softwareProductId+version.name;
43         testResultToDisplay[vspIdAndVer] = vspTestResults.vspTestResults;
44         var testResultKeyByVspId = {};
45        testResultKeyByVspId[vspIdAndVer] = testResultKeys.testResultKeys;
46         var obj = {
47             softwareProduct: {
48                 softwareProductValidation: {
49                        testResultKeys: testResultKeys.testResultKeys
50                 },
51                 softwareProductValidationResult: {
52                     testResultToDisplay: testResultToDisplay,
53                 }
54             }
55         };
56         var results = mapStateToProps(obj);
57         expect(results.softwareProductValidationResult.testResultToDisplay[vspIdAndVer]).toBeTruthy();
58     });
59
60      it('mapStateToProps success data test', () => {
61         const vspTestResults = VSPTestResultsSuccessFactory.build();
62         const vspTestsMap = VSPTestsMapFactory.build();
63         const vspChecksList = VSPChecksFactory.build();
64         var obj = {
65             softwareProduct: {
66                 softwareProductValidation: {
67                 },
68                 softwareProductValidationResult: {
69                     vspTestResults: vspTestResults.vspTestResults,
70                     vspChecks: vspChecksList,
71                     refreshValidationResults: []
72                 }
73             }
74         };
75         var results = mapStateToProps(obj);
76         expect(results.softwareProductValidationResult.vspTestResults).toBeTruthy();
77     });
78
79     it('SoftwareProductValidationResultsView test fail render test', () => {
80         const vspTestResults = VSPTestResultsFailureFactory.build();
81         const vspTestsMap = VSPTestsMapFactory.build();
82         const testResultKeys = VSPTestResultKeysFactory.build();
83         const vspChecksList = VSPChecksFactory.build();
84
85         const version = {
86             name: 1
87         };
88         const softwareProductId = '1234';
89         var testResultToDisplay = {};
90         var vspIdAndVer = softwareProductId+version.name;
91         testResultToDisplay[vspIdAndVer] = vspTestResults.vspTestResults;
92         var testResultKeyByVspId = {};
93         testResultKeyByVspId[vspIdAndVer] = testResultKeys.testResultKeys;
94          var obj = {
95                     softwareProductId: softwareProductId,
96                     version: version,
97                     softwareProductValidation:{
98                         testResultKeys: testResultKeys.testResultKeys
99                     },
100                     softwareProductValidationResult: {
101                         testResultToDisplay: testResultToDisplay,
102                         vspChecks: vspChecksList,
103                          refreshValidationResults: [],
104                          testResultKeys: testResultKeyByVspId
105                     }
106                 };
107
108         let vspValidationResultsView = TestUtils.renderIntoDocument(
109             <SoftwareProductValidationResultsView {...obj} />
110         );
111         expect(vspValidationResultsView).toBeTruthy();
112     });
113
114     it('SoftwareProductValidationResultsView test success render test', () => {
115         const vspTestResults = VSPTestResultsSuccessFactory.build();
116         const testResultKeys = VSPTestResultKeysFactory.build();
117         const vspTestsMap = VSPTestsMapFactory.build();
118         const vspChecksList = VSPChecksFactory.build();
119         let version = {
120             name: 1
121         };
122
123         const softwareProductId = '1234';
124         var testResultToDisplay = {};
125         var vspIdAndVer = softwareProductId+version.name;
126         testResultToDisplay[vspIdAndVer] = vspTestResults.vspTestResults;
127         var testResultKeyByVspId = {};
128          testResultKeyByVspId[vspIdAndVer] = testResultKeys.testResultKeys;
129
130         var obj = {
131             softwareProductId: softwareProductId,
132             version: version,
133             softwareProductValidation:{
134                 testResultKeys: testResultKeys.testResultKeys
135             },
136             softwareProductValidationResult: {
137                 testResultToDisplay: testResultToDisplay,
138                 vspChecks: vspChecksList
139             }
140         };
141         let vspValidationResultsView = TestUtils.renderIntoDocument(
142             <SoftwareProductValidationResultsView {...obj} />
143         );
144         expect(vspValidationResultsView).toBeTruthy();
145     });
146 });