svishnev | 091edfd | 2018-03-19 12:15:19 +0200 | [diff] [blame] | 1 | /* |
| 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 |
Yarin Dekel | 811fb48 | 2018-11-04 15:00:34 +0200 | [diff] [blame] | 7 | * |
svishnev | 091edfd | 2018-03-19 12:15:19 +0200 | [diff] [blame] | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
Yarin Dekel | 811fb48 | 2018-11-04 15:00:34 +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 | 091edfd | 2018-03-19 12:15:19 +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 | */ |
Yarin Dekel | 811fb48 | 2018-11-04 15:00:34 +0200 | [diff] [blame] | 16 | import { storeCreator } from 'sdc-app/AppStore.js'; |
| 17 | import { OnboardingCatalogStoreFactory } from 'test-utils/factories/onboard/OnboardingCatalogFactories.js'; |
| 18 | import { LicenseModelStoreFactory } from 'test-utils/factories/licenseModel/LicenseModelFactories.js'; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 19 | import OnboardingCatalogActionHelper from 'sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogActionHelper.js'; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 20 | |
| 21 | describe('Onboarding Catalog Module Tests', () => { |
Yarin Dekel | 811fb48 | 2018-11-04 15:00:34 +0200 | [diff] [blame] | 22 | it('should return default state', () => { |
| 23 | const store = storeCreator(); |
| 24 | const expectedStore = OnboardingCatalogStoreFactory.build(); |
| 25 | expect(store.getState().onboard.onboardingCatalog).toEqual( |
| 26 | expectedStore |
| 27 | ); |
| 28 | }); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 29 | |
Yarin Dekel | 811fb48 | 2018-11-04 15:00:34 +0200 | [diff] [blame] | 30 | it('should change VSP Overlay', () => { |
| 31 | const vendor = LicenseModelStoreFactory.build(); |
| 32 | const store = storeCreator(); |
| 33 | const expectedStore = OnboardingCatalogStoreFactory.build({ |
| 34 | vendorCatalog: { vspOverlay: vendor.id } |
| 35 | }); |
| 36 | OnboardingCatalogActionHelper.changeVspOverlay(store.dispatch, vendor); |
| 37 | expect(store.getState().onboard.onboardingCatalog).toEqual( |
| 38 | expectedStore |
| 39 | ); |
| 40 | }); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 41 | |
Yarin Dekel | 811fb48 | 2018-11-04 15:00:34 +0200 | [diff] [blame] | 42 | it('should close VSP Overlay', () => { |
| 43 | const vendor = LicenseModelStoreFactory.build(); |
| 44 | const store = storeCreator(); |
| 45 | const expectedStore = OnboardingCatalogStoreFactory.build({ |
| 46 | vendorCatalog: { vspOverlay: null } |
| 47 | }); |
| 48 | OnboardingCatalogActionHelper.changeVspOverlay(store.dispatch, vendor); |
| 49 | OnboardingCatalogActionHelper.changeVspOverlay(store.dispatch, null); |
| 50 | expect(store.getState().onboard.onboardingCatalog).toEqual( |
| 51 | expectedStore |
| 52 | ); |
| 53 | }); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 54 | |
Yarin Dekel | 811fb48 | 2018-11-04 15:00:34 +0200 | [diff] [blame] | 55 | it('should select vendor', () => { |
| 56 | const vendor = LicenseModelStoreFactory.build(); |
| 57 | const store = storeCreator(); |
| 58 | const expectedStore = OnboardingCatalogStoreFactory.build({ |
| 59 | vendorCatalog: { selectedVendor: vendor } |
| 60 | }); |
| 61 | OnboardingCatalogActionHelper.onVendorSelect(store.dispatch, { |
| 62 | vendor |
| 63 | }); |
| 64 | expect(store.getState().onboard.onboardingCatalog).toEqual( |
| 65 | expectedStore |
| 66 | ); |
| 67 | }); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 68 | }); |