2 * Copyright © 2019 Vodafone Group
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 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';
26 import TestUtils from 'react-dom/test-utils';
28 describe('SoftwareProductValidationResults Mapper and View Classes', () => {
29 it('mapStateToProps mapper exists', () => {
30 expect(mapStateToProps).toBeTruthy();
33 it('mapStateToProps fail data test', () => {
34 const vspTestResults = VSPTestResultsFailureFactory.build();
35 const vspTestsMap = VSPTestsMapFactory.build();
36 const testResultKeys = VSPTestResultKeysFactory.build();
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;
48 softwareProductValidation: {
49 testResultKeys: testResultKeys.testResultKeys
51 softwareProductValidationResult: {
52 testResultToDisplay: testResultToDisplay,
56 var results = mapStateToProps(obj);
57 expect(results.softwareProductValidationResult.testResultToDisplay[vspIdAndVer]).toBeTruthy();
60 it('mapStateToProps success data test', () => {
61 const vspTestResults = VSPTestResultsSuccessFactory.build();
62 const vspTestsMap = VSPTestsMapFactory.build();
63 const vspChecksList = VSPChecksFactory.build();
66 softwareProductValidation: {
68 softwareProductValidationResult: {
69 vspTestResults: vspTestResults.vspTestResults,
70 vspChecks: vspChecksList,
71 refreshValidationResults: []
75 var results = mapStateToProps(obj);
76 expect(results.softwareProductValidationResult.vspTestResults).toBeTruthy();
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();
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;
95 softwareProductId: softwareProductId,
97 softwareProductValidation:{
98 testResultKeys: testResultKeys.testResultKeys
100 softwareProductValidationResult: {
101 testResultToDisplay: testResultToDisplay,
102 vspChecks: vspChecksList,
103 refreshValidationResults: [],
104 testResultKeys: testResultKeyByVspId
108 let vspValidationResultsView = TestUtils.renderIntoDocument(
109 <SoftwareProductValidationResultsView {...obj} />
111 expect(vspValidationResultsView).toBeTruthy();
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();
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;
131 softwareProductId: softwareProductId,
133 softwareProductValidation:{
134 testResultKeys: testResultKeys.testResultKeys
136 softwareProductValidationResult: {
137 testResultToDisplay: testResultToDisplay,
138 vspChecks: vspChecksList
141 let vspValidationResultsView = TestUtils.renderIntoDocument(
142 <SoftwareProductValidationResultsView {...obj} />
144 expect(vspValidationResultsView).toBeTruthy();