blob: 8bd3779ea296a4a2235c679a0ad3b30bef1220c5 [file] [log] [blame]
Vodafone804ec682019-03-18 15:46:53 +05301/*
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
17import React from 'react';
18import { mapStateToProps } from 'sdc-app/onboarding/softwareProduct/validationResults/SoftwareProductValidationResults.js';
19import SoftwareProductValidationResultsView from 'sdc-app/onboarding/softwareProduct/validationResults/SoftwareProductValidationResultsView.jsx';
20import { VSPTestResultsSuccessFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationResultsFactory.js';
atulpurohit8b346842019-11-05 14:31:56 +053021import { VSPTestResultKeysFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationResultsFactory.js';
Vodafone804ec682019-03-18 15:46:53 +053022import { VSPTestResultsFailureFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationResultsFactory.js';
Vodafone18750932019-04-05 15:49:06 +053023import { VSPTestsMapFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js';
atulpurohit8b346842019-11-05 14:31:56 +053024import { VSPChecksFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js';
Vodafone18750932019-04-05 15:49:06 +053025
Vodafone804ec682019-03-18 15:46:53 +053026import TestUtils from 'react-dom/test-utils';
27
28describe('SoftwareProductValidationResults Mapper and View Classes', () => {
atulpurohit8b346842019-11-05 14:31:56 +053029 it('mapStateToProps mapper exists', () => {
Vodafone804ec682019-03-18 15:46:53 +053030 expect(mapStateToProps).toBeTruthy();
31 });
32
33 it('mapStateToProps fail data test', () => {
34 const vspTestResults = VSPTestResultsFailureFactory.build();
Vodafone18750932019-04-05 15:49:06 +053035 const vspTestsMap = VSPTestsMapFactory.build();
atulpurohit8b346842019-11-05 14:31:56 +053036 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;
Vodafone804ec682019-03-18 15:46:53 +053046 var obj = {
47 softwareProduct: {
48 softwareProductValidation: {
atulpurohit8b346842019-11-05 14:31:56 +053049 testResultKeys: testResultKeys.testResultKeys
50 },
51 softwareProductValidationResult: {
52 testResultToDisplay: testResultToDisplay,
Vodafone804ec682019-03-18 15:46:53 +053053 }
54 }
55 };
56 var results = mapStateToProps(obj);
atulpurohit8b346842019-11-05 14:31:56 +053057 expect(results.softwareProductValidationResult.testResultToDisplay[vspIdAndVer]).toBeTruthy();
Vodafone804ec682019-03-18 15:46:53 +053058 });
59
atulpurohit8b346842019-11-05 14:31:56 +053060 it('mapStateToProps success data test', () => {
Vodafone804ec682019-03-18 15:46:53 +053061 const vspTestResults = VSPTestResultsSuccessFactory.build();
Vodafone18750932019-04-05 15:49:06 +053062 const vspTestsMap = VSPTestsMapFactory.build();
atulpurohit8b346842019-11-05 14:31:56 +053063 const vspChecksList = VSPChecksFactory.build();
Vodafone804ec682019-03-18 15:46:53 +053064 var obj = {
65 softwareProduct: {
66 softwareProductValidation: {
atulpurohit8b346842019-11-05 14:31:56 +053067 },
68 softwareProductValidationResult: {
Vodafone18750932019-04-05 15:49:06 +053069 vspTestResults: vspTestResults.vspTestResults,
atulpurohit8b346842019-11-05 14:31:56 +053070 vspChecks: vspChecksList,
71 refreshValidationResults: []
Vodafone804ec682019-03-18 15:46:53 +053072 }
73 }
74 };
75 var results = mapStateToProps(obj);
atulpurohit8b346842019-11-05 14:31:56 +053076 expect(results.softwareProductValidationResult.vspTestResults).toBeTruthy();
Vodafone804ec682019-03-18 15:46:53 +053077 });
78
79 it('SoftwareProductValidationResultsView test fail render test', () => {
80 const vspTestResults = VSPTestResultsFailureFactory.build();
Vodafone18750932019-04-05 15:49:06 +053081 const vspTestsMap = VSPTestsMapFactory.build();
atulpurohit8b346842019-11-05 14:31:56 +053082 const testResultKeys = VSPTestResultKeysFactory.build();
83 const vspChecksList = VSPChecksFactory.build();
Vodafone804ec682019-03-18 15:46:53 +053084
85 const version = {
86 name: 1
87 };
88 const softwareProductId = '1234';
atulpurohit8b346842019-11-05 14:31:56 +053089 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
Vodafone804ec682019-03-18 15:46:53 +0530108 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();
atulpurohit8b346842019-11-05 14:31:56 +0530116 const testResultKeys = VSPTestResultKeysFactory.build();
Vodafone18750932019-04-05 15:49:06 +0530117 const vspTestsMap = VSPTestsMapFactory.build();
atulpurohit8b346842019-11-05 14:31:56 +0530118 const vspChecksList = VSPChecksFactory.build();
Vodafone804ec682019-03-18 15:46:53 +0530119 let version = {
120 name: 1
121 };
atulpurohit8b346842019-11-05 14:31:56 +0530122
Vodafone804ec682019-03-18 15:46:53 +0530123 const softwareProductId = '1234';
atulpurohit8b346842019-11-05 14:31:56 +0530124 var testResultToDisplay = {};
125 var vspIdAndVer = softwareProductId+version.name;
126 testResultToDisplay[vspIdAndVer] = vspTestResults.vspTestResults;
127 var testResultKeyByVspId = {};
128 testResultKeyByVspId[vspIdAndVer] = testResultKeys.testResultKeys;
129
Vodafone804ec682019-03-18 15:46:53 +0530130 var obj = {
131 softwareProductId: softwareProductId,
132 version: version,
atulpurohit8b346842019-11-05 14:31:56 +0530133 softwareProductValidation:{
134 testResultKeys: testResultKeys.testResultKeys
135 },
136 softwareProductValidationResult: {
137 testResultToDisplay: testResultToDisplay,
138 vspChecks: vspChecksList
Vodafone804ec682019-03-18 15:46:53 +0530139 }
140 };
141 let vspValidationResultsView = TestUtils.renderIntoDocument(
142 <SoftwareProductValidationResultsView {...obj} />
143 );
144 expect(vspValidationResultsView).toBeTruthy();
145 });
146});