react-version-downgrade
[sdc.git] / openecomp-ui / test / licenseModel / creation / LicenseModelCreation.test.js
1 /*
2  * Copyright © 2016-2017 European Support Limited
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
17 import React from 'react';
18 import TestUtils from 'react-addons-test-utils';
19 import {mapStateToProps } from 'sdc-app/onboarding/licenseModel/creation/LicenseModelCreation.js';
20 import LicenseModelCreationView from 'sdc-app/onboarding/licenseModel/creation/LicenseModelCreationView.jsx';
21 import {LicenseModelCreationFactory} from 'test-utils/factories/licenseModel/LicenseModelFactories.js';
22
23 describe('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                                 }
35                         },
36                         users: {
37                                 usersList: []
38                         }
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: [{
47                                 name: 'vlm1',
48                                 id: 'vlm1_id'
49                         }, {
50                                 name: 'vlm2',
51                                 id: 'vlm2_id'
52                         }],
53                         licenseModel: {
54                                 licenseModelCreation: {
55                                         data: {}
56                                 }
57                         },
58                         users: {
59                                 usersList: []
60                         }
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();
69                 var renderer = TestUtils.createRenderer();
70                 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 });