@shopgate/pwa-common
Version:
Common library for the Shopgate Connect PWA.
1 lines • 2.45 kB
JavaScript
import{APP_WILL_START,APP_DID_START,PWA_DID_APPEAR,PWA_DID_DISAPPEAR,WILL_REGISTER_LINK_EVENTS,DID_REGISTER_LINK_EVENTS,OPEN_DEEP_LINK,OPEN_PUSH_NOTIFICATION,OPEN_UNIVERSAL_LINK}from"../../constants/ActionTypes";import{appWillStart,appDidStart,pwaDidAppear,pwaDidDisappear,willRegisterLinkEvents,didRegisterLinkEvents,openDeepLink,openPushNotification,openUniversalLink}from"./index";var dataMock={some:'data'};describe('Action Creators: app',function(){describe('appWillStart()',function(){it('should work as expected',function(){var expected={type:APP_WILL_START,location:dataMock};expect(appWillStart(dataMock)).toEqual(expected);});});describe('appDidStart()',function(){it('should work as expected',function(){var expected={type:APP_DID_START};expect(appDidStart()).toEqual(expected);});});describe('pwaDidAppear()',function(){it('should work as expected',function(){var expected={type:PWA_DID_APPEAR};expect(pwaDidAppear()).toEqual(expected);});});describe('pwaDidDisappear()',function(){it('should work as expected',function(){var expected={type:PWA_DID_DISAPPEAR};expect(pwaDidDisappear()).toEqual(expected);});});describe('willRegisterLinkEvents()',function(){it('should work as expected',function(){var expected={type:WILL_REGISTER_LINK_EVENTS};expect(willRegisterLinkEvents()).toEqual(expected);});});describe('didRegisterLinkEvents()',function(){it('should work as expected',function(){var expected={type:DID_REGISTER_LINK_EVENTS};expect(didRegisterLinkEvents()).toEqual(expected);});});describe('openDeepLink()',function(){it('should work as expected',function(){var expected={type:OPEN_DEEP_LINK,payload:dataMock};expect(openDeepLink(dataMock)).toEqual(expected);});});describe('openPushNotification()',function(){var notificationId='abc123';var link='/link/to/somewhere';it('should work as expected',function(){var expected={type:OPEN_PUSH_NOTIFICATION,notificationId:notificationId,link:link};expect(openPushNotification(notificationId,link)).toEqual(expected);});it('should work as expected when the link is empty',function(){var expected={type:OPEN_PUSH_NOTIFICATION,notificationId:notificationId,link:''};expect(openPushNotification(notificationId)).toEqual(expected);});});describe('openUniversalLink()',function(){var expected={type:OPEN_UNIVERSAL_LINK,payload:{link:'https://testshop.shopgate.com/item/313131313132',wasOpenedFromSearchIndex:true,linkSerial:1003}};expect(openUniversalLink(expected.payload)).toEqual(expected);});});