blob: 232c5615c90f07f0682cbc49de07aba3f97cd7d6 [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 {OnboardStoreFactory} from 'test-utils/factories/onboard/OnboardFactories.js';
18import OnboardActionHelper from 'sdc-app/onboarding/onboard/OnboardActionHelper.js';
19import OnboardingCatalogActionHelper from 'sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogActionHelper.js';
20import {tabsMapping as onboardTabsMapping} from 'sdc-app/onboarding/onboard/OnboardConstants.js';
21import {tabsMapping as onboardCatalogTabsMapping} from 'sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogConstants.js';
22
23describe('Onboard Module Tests', () => {
24 it('should return default state', () => {
25 const store = storeCreator();
26 const expectedStore = OnboardStoreFactory.build();
27 expect(store.getState().onboard).toEqual(expectedStore);
28 });
29
30 it('should change active tab to Catalog', () => {
31 const store = storeCreator();
32 const expectedStore = OnboardStoreFactory.build({activeTab: onboardTabsMapping.CATALOG});
33 OnboardActionHelper.changeActiveTab(store.dispatch, onboardTabsMapping.CATALOG);
34 expect(store.getState().onboard).toEqual(expectedStore);
35 });
36
37 it('should change searchValue', () => {
38 const store = storeCreator();
39 const expectedStore = OnboardStoreFactory.build({searchValue: 'hello'});
40 OnboardActionHelper.changeSearchValue(store.dispatch, 'hello');
41 expect(store.getState().onboard).toEqual(expectedStore);
42 });
43
44 it('should clear searchValue', () => {
45 const store = storeCreator();
46 const expectedStore = OnboardStoreFactory.build();
47 OnboardActionHelper.changeSearchValue(store.dispatch, 'hello');
48 OnboardActionHelper.clearSearchValue(store.dispatch);
49 expect(store.getState().onboard).toEqual(expectedStore);
50 });
51
52 it('should reset store', () => {
53 const store = storeCreator();
54 const expectedStore = OnboardStoreFactory.build();
55 OnboardActionHelper.changeSearchValue(store.dispatch, 'hello');
56 OnboardActionHelper.changeActiveTab(store.dispatch, onboardTabsMapping.CATALOG);
svishnev091edfd2018-03-19 12:15:19 +020057 OnboardingCatalogActionHelper.changeActiveTab(store.dispatch, onboardCatalogTabsMapping.ACTIVE);
AviZi280f8012017-06-09 02:39:56 +030058 OnboardActionHelper.resetOnboardStore(store.dispatch, 'hello');
59 expect(store.getState().onboard).toEqual(expectedStore);
60 });
61
62});