chache result in onboarding
[sdc.git] / openecomp-ui / test / onboard / onboardingCatalog / test.js
1 /*
2  * Copyright © 2016-2018 European Support Limited
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 or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
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';
19 import OnboardingCatalogActionHelper from 'sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogActionHelper.js';
20
21 describe('Onboarding Catalog Module Tests', () => {
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     });
29
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     });
41
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     });
54
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     });
68 });