blob: cc54e3199e397d2e88e6e0742aec25633abcaa2a [file] [log] [blame]
AviZi280f8012017-06-09 02:39:56 +03001/*!
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 */
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();
32 const expectedStore = OnboardingCatalogStoreFactory.build({activeTab: tabsMapping.ALL});
33 OnboardingCatalogActionHelper.changeActiveTab(store.dispatch, tabsMapping.ALL);
34 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});