blob: 59ac267b0427e9194378814680c63a0da3959c5c [file] [log] [blame]
svishnev1eb66b72018-01-11 14:39:45 +02001/*
Einav Weiss Keidard2f57942018-02-14 14:00:07 +02002 * Copyright © 2016-2018 European Support Limited
AviZi280f8012017-06-09 02:39:56 +03003 *
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
Einav Weiss Keidard2f57942018-02-14 14:00:07 +02007 *
svishnev1eb66b72018-01-11 14:39:45 +02008 * http://www.apache.org/licenses/LICENSE-2.0
Einav Weiss Keidard2f57942018-02-14 14:00:07 +02009 *
AviZi280f8012017-06-09 02:39:56 +030010 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
svishnev1eb66b72018-01-11 14:39:45 +020012 * 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.
AviZi280f8012017-06-09 02:39:56 +030015 */
16
17import React from 'react';
Einav Weiss Keidard2f57942018-02-14 14:00:07 +020018import ShallowRenderer from 'react-test-renderer/shallow';
AviZi280f8012017-06-09 02:39:56 +030019import {mapStateToProps } from 'sdc-app/onboarding/licenseModel/creation/LicenseModelCreation.js';
20import LicenseModelCreationView from 'sdc-app/onboarding/licenseModel/creation/LicenseModelCreationView.jsx';
21import {LicenseModelCreationFactory} from 'test-utils/factories/licenseModel/LicenseModelFactories.js';
22
23describe('License Model Creation Module Tests', function() {
24 it ('mapStateToProps mapper exists', () => {
25 expect(mapStateToProps).toBeTruthy();
26 });
27
28 it ('should return empty data', () => {
29 let state = {
30 licenseModelList: [],
svishnev091edfd2018-03-19 12:15:19 +020031 archivedLicenseModelList: [],
32 finalizedLicenseModelList: [],
AviZi280f8012017-06-09 02:39:56 +030033 licenseModel: {
34 licenseModelCreation: {
35 data: {}
36 }
talig8e9c0652017-12-20 14:30:43 +020037 },
38 users: {
39 usersList: []
AviZi280f8012017-06-09 02:39:56 +030040 }
41 };
42 let props = mapStateToProps(state);
43 expect(props.data).toEqual({});
44 });
45
46 it ('should return vlm names list', () => {
47 let state = {
svishnev091edfd2018-03-19 12:15:19 +020048 archivedLicenseModelList: [],
49 finalizedLicenseModelList: [],
AviZi280f8012017-06-09 02:39:56 +030050 licenseModelList: [{
talig8e9c0652017-12-20 14:30:43 +020051 name: 'vlm1',
AviZi280f8012017-06-09 02:39:56 +030052 id: 'vlm1_id'
53 }, {
talig8e9c0652017-12-20 14:30:43 +020054 name: 'vlm2',
AviZi280f8012017-06-09 02:39:56 +030055 id: 'vlm2_id'
56 }],
57 licenseModel: {
58 licenseModelCreation: {
59 data: {}
60 }
talig8e9c0652017-12-20 14:30:43 +020061 },
62 users: {
63 usersList: []
AviZi280f8012017-06-09 02:39:56 +030064 }
65 };
66 let props = mapStateToProps(state);
67 expect(props.data).toEqual({});
68 expect(props.VLMNames).toEqual({vlm1: 'vlm1_id', vlm2: 'vlm2_id'});
69 });
70
71 it('simple jsx test', () => {
72 let data = LicenseModelCreationFactory.build();
Einav Weiss Keidard2f57942018-02-14 14:00:07 +020073 const renderer = new ShallowRenderer();
AviZi280f8012017-06-09 02:39:56 +030074 renderer.render(
75 <LicenseModelCreationView
76 data={data}
77 onDataChanged={() => {}}
78 onValidateForm={() => {}}
79 onSubmit={() => {}}
80 onCancel={() => {}}/>
81 );
82 var renderedOutput = renderer.getRenderOutput();
83 expect(renderedOutput).toBeTruthy();
84 });
85});