blob: 4e38675fb77f168ff1b00510a90cd3276dbaf3f7 [file] [log] [blame]
svishnev091edfd2018-03-19 12:15:19 +02001/*
2 * Copyright © 2016-2018 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
svishnev091edfd2018-03-19 12:15:19 +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,
svishnev091edfd2018-03-19 12:15:19 +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 */
16import {storeCreator} from 'sdc-app/AppStore.js';
17import {OnboardingCatalogStoreFactory} from 'test-utils/factories/onboard/OnboardingCatalogFactories.js';
18import {LicenseModelStoreFactory} from 'test-utils/factories/licenseModel/LicenseModelFactories.js';
19import OnboardingCatalogActionHelper from 'sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogActionHelper.js';
20import {tabsMapping} from 'sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogConstants.js';
21
22
23describe('Onboarding Catalog Module Tests', () => {
24 it('should return default state', () => {
25 const store = storeCreator();
26 const expectedStore = OnboardingCatalogStoreFactory.build();
27 expect(store.getState().onboard.onboardingCatalog).toEqual(expectedStore);
28 });
29
30 it('should change active tab to All', () => {
31 const store = storeCreator();
svishnev091edfd2018-03-19 12:15:19 +020032 const expectedStore = OnboardingCatalogStoreFactory.build({activeTab: tabsMapping.ACTIVE});
33 OnboardingCatalogActionHelper.changeActiveTab(store.dispatch, tabsMapping.ACTIVE);
AviZi280f8012017-06-09 02:39:56 +030034 expect(store.getState().onboard.onboardingCatalog).toEqual(expectedStore);
35 });
36
37
38 it('should change VSP Overlay', () => {
39 const vendor = LicenseModelStoreFactory.build();
40 const store = storeCreator();
41 const expectedStore = OnboardingCatalogStoreFactory.build({vendorCatalog: {vspOverlay: vendor.id}});
42 OnboardingCatalogActionHelper.changeVspOverlay(store.dispatch, vendor);
43 expect(store.getState().onboard.onboardingCatalog).toEqual(expectedStore);
44 });
45
46 it('should close VSP Overlay', () => {
47 const vendor = LicenseModelStoreFactory.build();
48 const store = storeCreator();
49 const expectedStore = OnboardingCatalogStoreFactory.build({vendorCatalog: {vspOverlay: null}});
50 OnboardingCatalogActionHelper.changeVspOverlay(store.dispatch, vendor);
51 OnboardingCatalogActionHelper.changeVspOverlay(store.dispatch, null);
52 expect(store.getState().onboard.onboardingCatalog).toEqual(expectedStore);
53 });
54
55 it('should select vendor', () => {
56 const vendor = LicenseModelStoreFactory.build();
57 const store = storeCreator();
58 const expectedStore = OnboardingCatalogStoreFactory.build({vendorCatalog: {selectedVendor: vendor}});
59 OnboardingCatalogActionHelper.onVendorSelect(store.dispatch, {vendor});
60 expect(store.getState().onboard.onboardingCatalog).toEqual(expectedStore);
61 });
62
63});