AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 1 | /*! |
| 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 | */ |
| 16 | import {storeCreator} from 'sdc-app/AppStore.js'; |
| 17 | import {OnboardStoreFactory} from 'test-utils/factories/onboard/OnboardFactories.js'; |
| 18 | import OnboardActionHelper from 'sdc-app/onboarding/onboard/OnboardActionHelper.js'; |
| 19 | import OnboardingCatalogActionHelper from 'sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogActionHelper.js'; |
| 20 | import {tabsMapping as onboardTabsMapping} from 'sdc-app/onboarding/onboard/OnboardConstants.js'; |
| 21 | import {tabsMapping as onboardCatalogTabsMapping} from 'sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogConstants.js'; |
| 22 | |
| 23 | describe('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); |
| 57 | OnboardingCatalogActionHelper.changeActiveTab(store.dispatch, onboardCatalogTabsMapping.ALL); |
| 58 | OnboardActionHelper.resetOnboardStore(store.dispatch, 'hello'); |
| 59 | expect(store.getState().onboard).toEqual(expectedStore); |
| 60 | }); |
| 61 | |
| 62 | }); |