blob: 9537ea2e2f9a5dbe69b414b90c89504eaf497cb1 [file] [log] [blame]
svishnev1eb66b72018-01-11 14:39:45 +02001/*
2 * Copyright © 2016-2017 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
svishnev1eb66b72018-01-11 14:39:45 +02007 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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';
svishnevaa2eece2018-01-18 17:52:06 +020018import TestUtils from 'react-addons-test-utils';
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: [],
31 licenseModel: {
32 licenseModelCreation: {
33 data: {}
34 }
talig8e9c0652017-12-20 14:30:43 +020035 },
36 users: {
37 usersList: []
AviZi280f8012017-06-09 02:39:56 +030038 }
39 };
40 let props = mapStateToProps(state);
41 expect(props.data).toEqual({});
42 });
43
44 it ('should return vlm names list', () => {
45 let state = {
46 licenseModelList: [{
talig8e9c0652017-12-20 14:30:43 +020047 name: 'vlm1',
AviZi280f8012017-06-09 02:39:56 +030048 id: 'vlm1_id'
49 }, {
talig8e9c0652017-12-20 14:30:43 +020050 name: 'vlm2',
AviZi280f8012017-06-09 02:39:56 +030051 id: 'vlm2_id'
52 }],
53 licenseModel: {
54 licenseModelCreation: {
55 data: {}
56 }
talig8e9c0652017-12-20 14:30:43 +020057 },
58 users: {
59 usersList: []
AviZi280f8012017-06-09 02:39:56 +030060 }
61 };
62 let props = mapStateToProps(state);
63 expect(props.data).toEqual({});
64 expect(props.VLMNames).toEqual({vlm1: 'vlm1_id', vlm2: 'vlm2_id'});
65 });
66
67 it('simple jsx test', () => {
68 let data = LicenseModelCreationFactory.build();
svishnevaa2eece2018-01-18 17:52:06 +020069 var renderer = TestUtils.createRenderer();
AviZi280f8012017-06-09 02:39:56 +030070 renderer.render(
71 <LicenseModelCreationView
72 data={data}
73 onDataChanged={() => {}}
74 onValidateForm={() => {}}
75 onSubmit={() => {}}
76 onCancel={() => {}}/>
77 );
78 var renderedOutput = renderer.getRenderOutput();
79 expect(renderedOutput).toBeTruthy();
80 });
81});