blob: 67e9fcfd8967211a2afea47441c41a3989992579 [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';
21import { VSPTestResultsFailureFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationResultsFactory.js';
Vodafone18750932019-04-05 15:49:06 +053022import { VSPTestsMapFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js';
23
Vodafone804ec682019-03-18 15:46:53 +053024import TestUtils from 'react-dom/test-utils';
25
26describe('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();
Vodafone18750932019-04-05 15:49:06 +053033 const vspTestsMap = VSPTestsMapFactory.build();
Vodafone804ec682019-03-18 15:46:53 +053034
35 var obj = {
36 softwareProduct: {
37 softwareProductValidation: {
Vodafone18750932019-04-05 15:49:06 +053038 vspTestResults: vspTestResults.vspTestResults,
39 vspTestsMap: vspTestsMap.vspTestsMap
Vodafone804ec682019-03-18 15:46:53 +053040 }
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();
Vodafone18750932019-04-05 15:49:06 +053049 const vspTestsMap = VSPTestsMapFactory.build();
Vodafone804ec682019-03-18 15:46:53 +053050
51 var obj = {
52 softwareProduct: {
53 softwareProductValidation: {
Vodafone18750932019-04-05 15:49:06 +053054 vspTestResults: vspTestResults.vspTestResults,
55 vspTestsMap: vspTestsMap.vspTestsMap
Vodafone804ec682019-03-18 15:46:53 +053056 }
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();
Vodafone18750932019-04-05 15:49:06 +053065 const vspTestsMap = VSPTestsMapFactory.build();
Vodafone804ec682019-03-18 15:46:53 +053066
67 const version = {
68 name: 1
69 };
70 const softwareProductId = '1234';
71 var obj = {
72 softwareProductId: softwareProductId,
73 version: version,
74 softwareProductValidation: {
Vodafone18750932019-04-05 15:49:06 +053075 vspTestResults: vspTestResults.vspTestResults,
76 vspTestsMap: vspTestsMap.vspTestsMap
Vodafone804ec682019-03-18 15:46:53 +053077 }
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();
Vodafone18750932019-04-05 15:49:06 +053087 const vspTestsMap = VSPTestsMapFactory.build();
Vodafone804ec682019-03-18 15:46:53 +053088
89 let version = {
90 name: 1
91 };
92 const softwareProductId = '1234';
93 var obj = {
94 softwareProductId: softwareProductId,
95 version: version,
96 softwareProductValidation: {
Vodafone18750932019-04-05 15:49:06 +053097 vspTestResults: vspTestResults.vspTestResults,
98 vspTestsMap: vspTestsMap.vspTestsMap
Vodafone804ec682019-03-18 15:46:53 +053099 }
100 };
101 let vspValidationResultsView = TestUtils.renderIntoDocument(
102 <SoftwareProductValidationResultsView {...obj} />
103 );
104 expect(vspValidationResultsView).toBeTruthy();
105 });
106});