svishnev | 1eb66b7 | 2018-01-11 14:39:45 +0200 | [diff] [blame] | 1 | /* |
Einav Weiss Keidar | d2f5794 | 2018-02-14 14:00:07 +0200 | [diff] [blame] | 2 | * Copyright © 2016-2018 European Support Limited |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 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 |
Einav Weiss Keidar | d2f5794 | 2018-02-14 14:00:07 +0200 | [diff] [blame] | 7 | * |
svishnev | 1eb66b7 | 2018-01-11 14:39:45 +0200 | [diff] [blame] | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
Einav Weiss Keidar | d2f5794 | 2018-02-14 14:00:07 +0200 | [diff] [blame] | 9 | * |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
svishnev | 1eb66b7 | 2018-01-11 14:39:45 +0200 | [diff] [blame] | 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. |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | import React from 'react'; |
Einav Weiss Keidar | d2f5794 | 2018-02-14 14:00:07 +0200 | [diff] [blame] | 18 | import ShallowRenderer from 'react-test-renderer/shallow'; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 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: [], |
svishnev | 091edfd | 2018-03-19 12:15:19 +0200 | [diff] [blame] | 31 | archivedLicenseModelList: [], |
| 32 | finalizedLicenseModelList: [], |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 33 | licenseModel: { |
| 34 | licenseModelCreation: { |
| 35 | data: {} |
| 36 | } |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 37 | }, |
| 38 | users: { |
| 39 | usersList: [] |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 40 | } |
| 41 | }; |
| 42 | let props = mapStateToProps(state); |
| 43 | expect(props.data).toEqual({}); |
| 44 | }); |
| 45 | |
| 46 | it ('should return vlm names list', () => { |
| 47 | let state = { |
svishnev | 091edfd | 2018-03-19 12:15:19 +0200 | [diff] [blame] | 48 | archivedLicenseModelList: [], |
| 49 | finalizedLicenseModelList: [], |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 50 | licenseModelList: [{ |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 51 | name: 'vlm1', |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 52 | id: 'vlm1_id' |
| 53 | }, { |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 54 | name: 'vlm2', |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 55 | id: 'vlm2_id' |
| 56 | }], |
| 57 | licenseModel: { |
| 58 | licenseModelCreation: { |
| 59 | data: {} |
| 60 | } |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 61 | }, |
| 62 | users: { |
| 63 | usersList: [] |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 64 | } |
| 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 Keidar | d2f5794 | 2018-02-14 14:00:07 +0200 | [diff] [blame] | 73 | const renderer = new ShallowRenderer(); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 74 | 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 | }); |