AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 1 | /*! |
| 2 | * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. |
| 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 |
| 13 | * or implied. See the License for the specific language governing |
| 14 | * permissions and 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 | } |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 35 | }, |
| 36 | users: { |
| 37 | usersList: [] |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 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: [{ |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 47 | name: 'vlm1', |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 48 | id: 'vlm1_id' |
| 49 | }, { |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 50 | name: 'vlm2', |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 51 | id: 'vlm2_id' |
| 52 | }], |
| 53 | licenseModel: { |
| 54 | licenseModelCreation: { |
| 55 | data: {} |
| 56 | } |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 57 | }, |
| 58 | users: { |
| 59 | usersList: [] |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 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 | }); |