VSP Compliance Check for Compute Flavor
[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 { VSPTestResultsFailureFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationResultsFactory.js';
22 import { VSPTestsMapFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js';
23
24 import TestUtils from 'react-dom/test-utils';
25
26 describe('SoftwareProductValidationResults Mapper and View Classes', () => {
27     it('mapStateToProps mapper exists', () => {
28         expect(mapStateToProps).toBeTruthy();
29     });
30
31     it('mapStateToProps fail data test', () => {
32         const vspTestResults = VSPTestResultsFailureFactory.build();
33         const vspTestsMap = VSPTestsMapFactory.build();
34
35         var obj = {
36             softwareProduct: {
37                 softwareProductValidation: {
38                     vspTestResults: vspTestResults.vspTestResults,
39                     vspTestsMap: vspTestsMap.vspTestsMap
40                 }
41             }
42         };
43         var results = mapStateToProps(obj);
44         expect(results.softwareProductValidation.vspTestResults).toBeTruthy();
45     });
46
47     it('mapStateToProps success data test', () => {
48         const vspTestResults = VSPTestResultsSuccessFactory.build();
49         const vspTestsMap = VSPTestsMapFactory.build();
50
51         var obj = {
52             softwareProduct: {
53                 softwareProductValidation: {
54                     vspTestResults: vspTestResults.vspTestResults,
55                     vspTestsMap: vspTestsMap.vspTestsMap
56                 }
57             }
58         };
59         var results = mapStateToProps(obj);
60         expect(results.softwareProductValidation.vspTestResults).toBeTruthy();
61     });
62
63     it('SoftwareProductValidationResultsView test fail render test', () => {
64         const vspTestResults = VSPTestResultsFailureFactory.build();
65         const vspTestsMap = VSPTestsMapFactory.build();
66
67         const version = {
68             name: 1
69         };
70         const softwareProductId = '1234';
71         var obj = {
72             softwareProductId: softwareProductId,
73             version: version,
74             softwareProductValidation: {
75                 vspTestResults: vspTestResults.vspTestResults,
76                 vspTestsMap: vspTestsMap.vspTestsMap
77             }
78         };
79         let vspValidationResultsView = TestUtils.renderIntoDocument(
80             <SoftwareProductValidationResultsView {...obj} />
81         );
82         expect(vspValidationResultsView).toBeTruthy();
83     });
84
85     it('SoftwareProductValidationResultsView test success render test', () => {
86         const vspTestResults = VSPTestResultsSuccessFactory.build();
87         const vspTestsMap = VSPTestsMapFactory.build();
88
89         let version = {
90             name: 1
91         };
92         const softwareProductId = '1234';
93         var obj = {
94             softwareProductId: softwareProductId,
95             version: version,
96             softwareProductValidation: {
97                 vspTestResults: vspTestResults.vspTestResults,
98                 vspTestsMap: vspTestsMap.vspTestsMap
99             }
100         };
101         let vspValidationResultsView = TestUtils.renderIntoDocument(
102             <SoftwareProductValidationResultsView {...obj} />
103         );
104         expect(vspValidationResultsView).toBeTruthy();
105     });
106 });