blob: 9cbae40a451857da0aa97d6087b95df907e6c66f [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
Yarin Dekel811fb482018-11-04 15:00:34 +02007 *
svishnev091edfd2018-03-19 12:15:19 +02008 * http://www.apache.org/licenses/LICENSE-2.0
Yarin Dekel811fb482018-11-04 15:00:34 +02009 *
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 */
Yarin Dekel811fb482018-11-04 15:00:34 +020016import { storeCreator } from 'sdc-app/AppStore.js';
17import { OnboardingCatalogStoreFactory } from 'test-utils/factories/onboard/OnboardingCatalogFactories.js';
18import { LicenseModelStoreFactory } from 'test-utils/factories/licenseModel/LicenseModelFactories.js';
AviZi280f8012017-06-09 02:39:56 +030019import OnboardingCatalogActionHelper from 'sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogActionHelper.js';
AviZi280f8012017-06-09 02:39:56 +030020
21describe('Onboarding Catalog Module Tests', () => {
Yarin Dekel811fb482018-11-04 15:00:34 +020022 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 });
AviZi280f8012017-06-09 02:39:56 +030029
Yarin Dekel811fb482018-11-04 15:00:34 +020030 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 });
AviZi280f8012017-06-09 02:39:56 +030041
Yarin Dekel811fb482018-11-04 15:00:34 +020042 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 });
AviZi280f8012017-06-09 02:39:56 +030054
Yarin Dekel811fb482018-11-04 15:00:34 +020055 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 });
AviZi280f8012017-06-09 02:39:56 +030068});