@shopgate/engage 6.21.0 → 6.22.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (184) hide show
  1. package/app-rating/action-creators/appStart.js +3 -3
  2. package/app-rating/action-creators/ordersPlaced.js +3 -3
  3. package/app-rating/action-creators/popup.js +4 -4
  4. package/app-rating/action-creators/timer.js +3 -3
  5. package/app-rating/actions/showModal.js +2 -2
  6. package/app-rating/constants/index.js +2 -2
  7. package/app-rating/reducers/index.js +2 -2
  8. package/app-rating/subscriptions/index.js +2 -2
  9. package/back-in-stock/actions/index.js +14 -0
  10. package/back-in-stock/components/BackInStockButton/connector.js +1 -0
  11. package/back-in-stock/components/BackInStockButton/index.js +13 -0
  12. package/back-in-stock/components/BackInStockButton/style.js +1 -0
  13. package/back-in-stock/components/CharacteristicsButton/connector.js +3 -0
  14. package/back-in-stock/components/CharacteristicsButton/index.js +8 -0
  15. package/back-in-stock/components/ProductInfoBackInStockButton/connector.js +3 -0
  16. package/back-in-stock/components/ProductInfoBackInStockButton/index.js +10 -0
  17. package/back-in-stock/components/Subscriptions/components/List/index.js +4 -0
  18. package/back-in-stock/components/Subscriptions/components/Subscription/index.js +7 -0
  19. package/back-in-stock/components/Subscriptions/index.js +4 -0
  20. package/back-in-stock/components/index.js +1 -0
  21. package/back-in-stock/constants/Actions.js +1 -0
  22. package/back-in-stock/constants/Common.js +1 -0
  23. package/back-in-stock/constants/Pipelines.js +1 -0
  24. package/back-in-stock/constants/Portals.js +9 -0
  25. package/back-in-stock/constants/index.js +1 -0
  26. package/back-in-stock/hooks/index.js +4 -0
  27. package/back-in-stock/providers/BackInStockSubscriptionsProvider.connector.js +7 -0
  28. package/back-in-stock/providers/BackInStockSubscriptionsProvider.context.js +1 -0
  29. package/back-in-stock/providers/BackInStockSubscriptionsProvider.js +5 -0
  30. package/back-in-stock/providers/index.js +1 -0
  31. package/back-in-stock/reducers/index.js +5 -0
  32. package/back-in-stock/selectors/index.js +42 -0
  33. package/back-in-stock/streams/index.js +1 -0
  34. package/back-in-stock/subscriptions/index.js +11 -0
  35. package/components/index.js +1 -1
  36. package/core/action-creators/appPermissions.js +9 -0
  37. package/core/action-creators/index.js +1 -0
  38. package/core/actions/getGeolocation.js +1 -1
  39. package/core/actions/grantCameraPermissions.js +1 -1
  40. package/core/actions/grantGeolocationPermissions.js +1 -1
  41. package/core/actions/grantPermissions.js +11 -4
  42. package/core/actions/grantPushPermissions.js +22 -0
  43. package/core/actions/index.js +1 -0
  44. package/core/actions/requestAppPermission.js +7 -0
  45. package/core/actions/requestAppPermissionStatus.js +7 -0
  46. package/core/collections/AppInitialization.js +49 -0
  47. package/core/collections/index.js +1 -0
  48. package/core/constants/actionTypes.js +1 -0
  49. package/core/constants/appFeatures.js +1 -0
  50. package/core/constants/index.js +6 -0
  51. package/core/helpers/appFeatures.js +7 -0
  52. package/core/helpers/index.js +1 -0
  53. package/core/index.js +8 -12
  54. package/core/initialization/index.js +7 -0
  55. package/core/streams/appPermissions.js +19 -0
  56. package/core/streams/index.js +1 -0
  57. package/package.json +7 -7
  58. package/product/components/Characteristics/Characteristic/components/Sheet/index.js +2 -2
  59. package/product/components/Characteristics/Characteristic/components/SheetItem/index.js +3 -3
  60. package/product/components/Characteristics/Characteristic/components/SheetItem/style.js +1 -1
  61. package/product/index.js +1 -1
  62. package/product/selectors/product.js +5 -1
  63. package/product/selectors/variants.js +2 -2
  64. package/push-opt-in/action-creators/index.js +1 -0
  65. package/push-opt-in/action-creators/optInTrigger.js +23 -0
  66. package/push-opt-in/action-creators/pushOptIn.js +7 -0
  67. package/push-opt-in/actions/index.js +1 -0
  68. package/push-opt-in/actions/pushOptInModal.js +8 -0
  69. package/push-opt-in/components/PushOptInModal/connector.js +9 -0
  70. package/push-opt-in/components/PushOptInModal/index.js +10 -0
  71. package/push-opt-in/components/PushOptInModal/push-opt-in.svg +62 -0
  72. package/push-opt-in/components/PushOptInModal/style.js +1 -0
  73. package/push-opt-in/components/index.js +1 -0
  74. package/push-opt-in/constants/index.js +1 -0
  75. package/push-opt-in/constants/optInModal.js +1 -0
  76. package/push-opt-in/constants/optInTrigger.js +1 -0
  77. package/push-opt-in/reducers/index.js +1 -0
  78. package/push-opt-in/reducers/optInModal.js +6 -0
  79. package/push-opt-in/reducers/optInTrigger.js +6 -0
  80. package/push-opt-in/selectors/index.js +1 -0
  81. package/push-opt-in/selectors/optInModal.js +8 -0
  82. package/push-opt-in/selectors/optInTrigger.js +5 -0
  83. package/push-opt-in/subscriptions/index.js +1 -0
  84. package/push-opt-in/subscriptions/optInTrigger.js +12 -0
  85. package/a11y/components/LiveMessage/__tests__/index.spec.js +0 -1
  86. package/a11y/components/LiveMessenger/__tests__/helpers.spec.js +0 -1
  87. package/a11y/components/LiveMessenger/__tests__/index.spec.js +0 -1
  88. package/a11y/components/Navigation/__tests__/index.spec.js +0 -1
  89. package/a11y/components/Section/__tests__/index.spec.js +0 -1
  90. package/a11y/index.spec.js +0 -1
  91. package/cart/index.spec.js +0 -1
  92. package/category/index.spec.js +0 -1
  93. package/checkout/index.spec.js +0 -1
  94. package/components/Footer/__tests__/Footer.spec.js +0 -8
  95. package/components/Form/Builder/Builder.spec.js +0 -19
  96. package/components/Form/Builder/classes/ActionListener.spec.js +0 -21
  97. package/components/Form/Builder/helpers/buildCountryList.spec.js +0 -1
  98. package/components/Form/Builder/helpers/buildFormDefaults.spec.js +0 -1
  99. package/components/Form/Builder/helpers/buildFormElements.spec.js +0 -3
  100. package/components/Form/Builder/helpers/buildProvinceList.spec.js +0 -1
  101. package/components/IntersectionVisibility/__tests__/index.js +0 -1
  102. package/components/View/__mocks__/context.js +0 -1
  103. package/components/View/__mocks__/index.js +0 -5
  104. package/components/View/__tests__/index.spec.js +0 -1
  105. package/components/View/__tests__/provider.spec.js +0 -1
  106. package/components/View/components/Above/__tests__/index.spec.js +0 -1
  107. package/components/View/components/Below/__tests__/index.spec.js +0 -1
  108. package/components/View/components/Content/__tests__/index.spec.js +0 -2
  109. package/components/__mocks__/index.js +0 -4
  110. package/components/index.spec.js +0 -1
  111. package/core/actions/__tests__/getGeolocation.spec.js +0 -2
  112. package/core/actions/__tests__/grantCameraPermissions.spec.js +0 -1
  113. package/core/actions/__tests__/grantGeolocationPermissions.spec.js +0 -1
  114. package/core/actions/__tests__/grantPermissions.spec.js +0 -9
  115. package/core/actions/__tests__/updateStatusBarBackground.spec.js +0 -1
  116. package/core/classes/__tests__/GeolocationRequest.spec.js +0 -5
  117. package/core/config/__tests__/getPageConfig.spec.js +0 -1
  118. package/core/config/__tests__/getPageSettings.spec.js +0 -2
  119. package/core/config/__tests__/getThemeAssets.spec.js +0 -1
  120. package/core/config/__tests__/getThemeColors.spec.js +0 -1
  121. package/core/config/__tests__/getThemeConfig.spec.js +0 -2
  122. package/core/config/__tests__/getThemeSettings.spec.js +0 -1
  123. package/core/config/__tests__/getThemeStyles.spec.js +0 -1
  124. package/core/config/__tests__/getWidgetConfig.spec.js +0 -1
  125. package/core/config/__tests__/getWidgetSettings.spec.js +0 -3
  126. package/core/helpers/__mocks__/i18n.js +0 -1
  127. package/core/helpers/__tests__/i18n.spec.js +0 -1
  128. package/core/helpers/__tests__/updateLegacyNavigationBar.spec.js +0 -1
  129. package/core/hocs/__mocks__/withWidgetSettings.js +0 -5
  130. package/core/hocs/__tests__/withApp.spec.js +0 -2
  131. package/core/hocs/__tests__/withCurrentProduct.spec.js +0 -2
  132. package/core/hocs/__tests__/withForwardedRef.spec.js +0 -1
  133. package/core/hocs/__tests__/withNavigation.spec.js +0 -2
  134. package/core/hocs/__tests__/withRoute.spec.js +0 -2
  135. package/core/hocs/__tests__/withTheme.spec.js +0 -2
  136. package/core/hocs/__tests__/withWidgetSettings.spec.js +0 -2
  137. package/core/hocs/__tests__/withWidgetStyles.spec.js +0 -2
  138. package/core/hooks/__tests__/useApp.spec.js +0 -1
  139. package/core/hooks/__tests__/useNavigation.spec.js +0 -1
  140. package/core/hooks/__tests__/usePageConfig.spec.js +0 -1
  141. package/core/hooks/__tests__/usePageSettings.spec.js +0 -1
  142. package/core/hooks/__tests__/useTheme.spec.js +0 -1
  143. package/core/hooks/__tests__/useWidgetConfig.spec.js +0 -1
  144. package/core/hooks/__tests__/useWidgetSettings.spec.js +0 -1
  145. package/core/hooks/__tests__/useWidgetStyles.spec.js +0 -1
  146. package/core/index.spec.js +0 -1
  147. package/core/providers/__tests__/AppProvider.spec.js +0 -2
  148. package/core/router/__tests__/helpers.spec.js +0 -1
  149. package/favorites/index.spec.js +0 -1
  150. package/filter/helpers/__tests__/buildUpdatedFilters.spec.js +0 -1
  151. package/filter/index.spec.js +0 -1
  152. package/index.spec.js +0 -1
  153. package/market/index.spec.js +0 -1
  154. package/orders/index.spec.js +0 -1
  155. package/page/index.spec.js +0 -1
  156. package/product/components/Description/__tests__/Description.spec.js +0 -1
  157. package/product/components/Media/helpers.spec.js +0 -3
  158. package/product/components/ProductCharacteristics/helpers/index.spec.js +0 -12
  159. package/product/components/ProductGridPrice/index.spec.js +0 -1
  160. package/product/components/ProductProperties/__tests__/Content.spec.js +0 -1
  161. package/product/components/ProductProperties/__tests__/Group.spec.js +0 -1
  162. package/product/components/ProductProperties/__tests__/GroupedProperties.spec.js +0 -1
  163. package/product/components/ProductProperties/__tests__/Lists.spec.js +0 -1
  164. package/product/components/ProductProperties/__tests__/ProductProperties.spec.js +0 -1
  165. package/product/components/ProductProperties/__tests__/Row.spec.js +0 -1
  166. package/product/components/ProductProperties/__tests__/Rows.spec.js +0 -1
  167. package/product/components/ProductProperties/__tests__/helpers/getGroupsFromProperties.spec.js +0 -1
  168. package/product/components/ProductProperties/__tests__/helpers/getSubgroupsFromProperties.spec.js +0 -1
  169. package/product/components/QuantityPicker/helpers.spec.js +0 -1
  170. package/product/components/__mocks__/context.js +0 -1
  171. package/product/hocs/withMapPricing.spec.js +0 -4
  172. package/product/hocs/withPriceCalculation.spec.js +0 -1
  173. package/product/index.spec.js +0 -1
  174. package/product/selectors/__tests__/media.spec.js +0 -1
  175. package/product/selectors/__tests__/price.spec.js +0 -1
  176. package/product/selectors/__tests__/product.spec.js +0 -2
  177. package/product/selectors/__tests__/relations.spec.js +0 -1
  178. package/product/selectors/__tests__/variants.spec.js +0 -1
  179. package/product/selectors/mocks/productProperties.mock.js +0 -1
  180. package/reviews/index.spec.js +0 -1
  181. package/scanner/index.spec.js +0 -1
  182. package/search/index.spec.js +0 -1
  183. package/user/index.spec.js +0 -1
  184. package/user/selectors/__tests__/login.spec.js +0 -1
@@ -1,2 +0,0 @@
1
- function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import React from'react';import{mount}from'enzyme';import{push,pop,replace,reset,update}from"../../router/helpers";import{withNavigation}from"../withNavigation";var navigationProps={historyPush:push,historyPop:pop,historyReplace:replace,historyReset:reset,historyUpdate:update};// eslint-disable-next-line require-jsdoc
2
- var MockComponent=function MockComponent(){return null;};describe('engage > core > hocs > withNavigation',function(){beforeEach(function(){jest.clearAllMocks();});it('should inject the navigation properties into the component',function(){var ComposedComponent=withNavigation(MockComponent);var wrapper=mount(/*#__PURE__*/React.createElement(ComposedComponent,{someProp:true}));expect(wrapper).toMatchSnapshot();expect(wrapper.find(MockComponent).props()).toEqual(_extends({someProp:true},navigationProps));});it('should inject a single property with the navigation into the component',function(){var ComposedComponent=withNavigation(MockComponent,{prop:'navigation'});var wrapper=mount(/*#__PURE__*/React.createElement(ComposedComponent,{someProp:true}));expect(wrapper).toMatchSnapshot();expect(wrapper.find(MockComponent).props()).toEqual({someProp:true,navigation:_extends({},navigationProps)});});});
@@ -1,2 +0,0 @@
1
- function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import React from'react';import{mount}from'enzyme';import{withRoute}from"../withRoute";var mockRoute={id:'32d55',pathname:'/',pattern:'/',state:{}};var mockContext=jest.fn().mockReturnValue(mockRoute);jest.mock('@shopgate/pwa-common/context',function(){return{RouteContext:{Consumer:function Consumer(_ref){var children=_ref.children;return children(mockContext());}}};});// eslint-disable-next-line require-jsdoc
2
- var MockComponent=function MockComponent(){return null;};describe('engage > core > hocs > withRoute',function(){beforeEach(function(){jest.clearAllMocks();});it('should inject the context properties into the component',function(){var ComposedComponent=withRoute(MockComponent);var wrapper=mount(/*#__PURE__*/React.createElement(ComposedComponent,{someProp:true}));expect(wrapper).toMatchSnapshot();expect(wrapper.find(MockComponent).props()).toEqual(_extends({someProp:true},mockRoute));});it('should inject a single property with the context into the component',function(){var ComposedComponent=withRoute(MockComponent,{prop:'route'});var wrapper=mount(/*#__PURE__*/React.createElement(ComposedComponent,{someProp:true}));expect(wrapper).toMatchSnapshot();expect(wrapper.find(MockComponent).props()).toEqual({someProp:true,route:_extends({},mockRoute)});});});
@@ -1,2 +0,0 @@
1
- function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import React from'react';import{mount}from'enzyme';import{withTheme}from"../withTheme";var mockTheme={ComponentOne:function ComponentOne(){return/*#__PURE__*/React.createElement("div",null);},ComponentTwo:function ComponentTwo(){return/*#__PURE__*/React.createElement("div",null);}};var mockContext=jest.fn().mockReturnValue(mockTheme);jest.mock('@shopgate/pwa-common/context',function(){return{ThemeContext:{Consumer:function Consumer(_ref){var children=_ref.children;return children(mockContext());}}};});// eslint-disable-next-line require-jsdoc
2
- var MockComponent=function MockComponent(){return null;};describe('engage > core > hocs > withTheme',function(){beforeEach(function(){jest.clearAllMocks();});it('should inject the context properties into the component',function(){var ComposedComponent=withTheme(MockComponent);var wrapper=mount(/*#__PURE__*/React.createElement(ComposedComponent,{someProp:true}));expect(wrapper).toMatchSnapshot();expect(wrapper.find(MockComponent).props()).toEqual(_extends({someProp:true},mockTheme));});it('should inject a single property with the context into the component',function(){var ComposedComponent=withTheme(MockComponent,{prop:'theme'});var wrapper=mount(/*#__PURE__*/React.createElement(ComposedComponent,{someProp:true}));expect(wrapper).toMatchSnapshot();expect(wrapper.find(MockComponent).props()).toEqual({someProp:true,theme:_extends({},mockTheme)});});});
@@ -1,2 +0,0 @@
1
- import React from'react';import{mount}from'enzyme';import{withWidgetSettings}from"../withWidgetSettings";import{useWidgetSettings}from"../../hooks/useWidgetSettings";jest.mock("../../hooks/useWidgetSettings",function(){return{useWidgetSettings:jest.fn()};});// eslint-disable-next-line require-jsdoc
2
- var MockComponent=function MockComponent(){return null;};var widgetSettings={some:'setting'};describe('engage > core > hocs > withWidgetSettings',function(){beforeEach(function(){useWidgetSettings.mockReturnValue(widgetSettings);});it('should merge add the widget settings to a wrapped component',function(){var ComposedComponent=withWidgetSettings(MockComponent);var wrapper=mount(/*#__PURE__*/React.createElement(ComposedComponent,null));expect(wrapper).toMatchSnapshot();expect(wrapper.find(MockComponent).prop('widgetSettings')).toEqual(widgetSettings);});});
@@ -1,2 +0,0 @@
1
- import React from'react';import{mount}from'enzyme';import{withWidgetStyles}from"../withWidgetStyles";import{useWidgetStyles}from"../../hooks/useWidgetStyles";jest.mock("../../hooks/useWidgetStyles",function(){return{useWidgetStyles:jest.fn()};});// eslint-disable-next-line require-jsdoc
2
- var MockComponent=function MockComponent(){return null;};var widgetStyles={some:'style'};describe('engage > core > hocs > withWidgetStyles',function(){beforeEach(function(){useWidgetStyles.mockReturnValue(widgetStyles);});it('should merge add the widget settings to a wrapped component',function(){var ComposedComponent=withWidgetStyles(MockComponent);var wrapper=mount(/*#__PURE__*/React.createElement(ComposedComponent,null));expect(wrapper).toMatchSnapshot();expect(wrapper.find(MockComponent).prop('widgetStyles')).toEqual(widgetStyles);});});
@@ -1 +0,0 @@
1
- import{useContext}from'react';import AppContext from"../../contexts/AppContext";import{useApp}from"../useApp";jest.mock('react',function(){return{useContext:jest.fn(),createContext:jest.fn()};});describe('engage > core > hooks',function(){describe('useApp()',function(){it('should return an empty if no app context is defined.',function(){useContext.mockReturnValueOnce({});var app=useApp();expect(useContext).toHaveBeenCalledWith(AppContext);expect(app).toEqual({});});it('should return object containing app context properties.',function(){useContext.mockReturnValueOnce({some:'prop'});var app=useApp();expect(app).toEqual({some:'prop'});});});});
@@ -1 +0,0 @@
1
- function _typeof(obj){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj;}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;},_typeof(obj);}import{useNavigation}from"../useNavigation";describe('engage > core > hooks',function(){describe('useNavigation()',function(){it('should return the push() function',function(){var result=useNavigation();expect(result.hasOwnProperty('push')).toBe(true);expect(_typeof(result.push)).toBe('function');});it('should return the pop() function',function(){var result=useNavigation();expect(result.hasOwnProperty('pop')).toBe(true);expect(_typeof(result.pop)).toBe('function');});it('should return the replace() function',function(){var result=useNavigation();expect(result.hasOwnProperty('replace')).toBe(true);expect(_typeof(result.replace)).toBe('function');});it('should return the reset() function',function(){var result=useNavigation();expect(result.hasOwnProperty('reset')).toBe(true);expect(_typeof(result.reset)).toBe('function');});it('should return the update() function',function(){var result=useNavigation();expect(result.hasOwnProperty('update')).toBe(true);expect(_typeof(result.update)).toBe('function');});});});
@@ -1 +0,0 @@
1
- import{usePageConfig}from"../usePageConfig";import{useRoute}from"../useRoute";import{getPageConfig}from"../../config/getPageConfig";jest.mock("../useRoute",function(){return{useRoute:jest.fn()};});jest.mock("../../config/getPageConfig",function(){return{getPageConfig:jest.fn()};});describe('engage > core > hooks',function(){describe('usePageConfig()',function(){beforeEach(function(){jest.resetAllMocks();});it('should pass down the page pattern to the lower level helper functions.',function(){useRoute.mockReturnValue({pattern:'/page/pattern'});usePageConfig();expect(getPageConfig).toBeCalledWith('/page/pattern');expect(getPageConfig).toBeCalledTimes(1);expect(useRoute).toBeCalledTimes(1);});it('should return what it got from the helper function without messing with references.',function(){useRoute.mockReturnValue({pattern:'/page/pattern'});var testPageConfig={pattern:'/page/pattern',settings:{custom:'123'},widgets:[]};getPageConfig.mockReturnValue(testPageConfig);var result=usePageConfig();expect(result===testPageConfig).toBeTruthy();});});});
@@ -1 +0,0 @@
1
- import{usePageSettings}from"../usePageSettings";import{useRoute}from"../useRoute";import{getPageSettings}from"../../config/getPageSettings";jest.mock("../useRoute",function(){return{useRoute:jest.fn()};});jest.mock("../../config/getPageSettings",function(){return{getPageSettings:jest.fn()};});describe('engage > core > hooks',function(){describe('usePageSettings()',function(){beforeEach(function(){jest.resetAllMocks();});it('should pass down its given param and the page pattern to the lower level helper functions.',function(){useRoute.mockReturnValue({pattern:'/page/pattern'});usePageSettings('customKey');expect(getPageSettings).toBeCalledWith('/page/pattern','customKey');expect(getPageSettings).toBeCalledTimes(1);expect(useRoute).toBeCalledTimes(1);});it('should return what it got from the helper function without messing with references.',function(){useRoute.mockReturnValue({pattern:'/page/pattern'});var testPageSettings={custom:'setting-123'};getPageSettings.mockReturnValue(testPageSettings);var result=usePageSettings();expect(result===testPageSettings).toBeTruthy();});});});
@@ -1 +0,0 @@
1
- function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import{useContext}from'react';import{useTheme}from"../useTheme";jest.mock('react',function(){return _extends({},jest.requireActual('react'),{useContext:jest.fn()});});describe('engage > core > hooks',function(){describe('useTheme()',function(){it('should return an empty if no theme context is defined.',function(){useContext.mockReturnValueOnce({contexts:{}});var theme=useTheme();expect(theme).toEqual({});});it('should return object containing react components.',function(){useContext.mockReturnValueOnce({contexts:{},Some:function Some(){return null;},Thing:function Thing(){return null;}});var theme=useTheme();expect(theme.Some).toBeTruthy();expect(theme.Thing).toBeTruthy();});});});
@@ -1 +0,0 @@
1
- import{useWidgetConfig}from"../useWidgetConfig";import{useRoute}from"../useRoute";import{getWidgetConfig}from"../../config/getWidgetConfig";jest.mock("../useRoute",function(){return{useRoute:jest.fn()};});jest.mock("../../config/getWidgetConfig",function(){return{getWidgetConfig:jest.fn()};});describe('engage > core > hooks',function(){describe('useWidgetConfig()',function(){beforeEach(function(){jest.resetAllMocks();});it('should pass down its given params and the page pattern to the lower level helper functions.',function(){useRoute.mockReturnValue({pattern:'/test'});useWidgetConfig('widgetId',3);expect(getWidgetConfig).toBeCalledWith('/test','widgetId',3);expect(getWidgetConfig).toBeCalledTimes(1);expect(useRoute).toBeCalledTimes(1);});it('should return what it got from the helper function without messing with references.',function(){useRoute.mockReturnValue({pattern:'/test'});var testWidgetConfig={widgetId:'some/widget/id',settings:{custom:'config'}};getWidgetConfig.mockReturnValue(testWidgetConfig);var result=useWidgetConfig('widgetId',3);expect(result===testWidgetConfig).toBeTruthy();});});});
@@ -1 +0,0 @@
1
- import{useWidgetSettings}from"../useWidgetSettings";import{useRoute}from"../useRoute";import{getWidgetSettings}from"../../config/getWidgetSettings";jest.mock("../useRoute",function(){return{useRoute:jest.fn()};});jest.mock("../../config/getWidgetSettings",function(){return{getWidgetSettings:jest.fn()};});describe('engage > core > hooks',function(){describe('useWidgetSettings()',function(){beforeEach(function(){jest.resetAllMocks();});it('should pass down its given params and the page pattern to the lower level helper functions.',function(){useRoute.mockReturnValue({pattern:'/test'});useWidgetSettings('widgetId',3);expect(getWidgetSettings).toBeCalledWith('/test','widgetId',3);expect(getWidgetSettings).toBeCalledTimes(1);expect(useRoute).toBeCalledTimes(1);});it('should return what it got from the helper function without messing with references.',function(){useRoute.mockReturnValue({pattern:'/test'});var testWidgetSettings={custom:'setting'};getWidgetSettings.mockReturnValue(testWidgetSettings);var result=useWidgetSettings('widgetId',3);expect(result===testWidgetSettings).toBeTruthy();});});});
@@ -1 +0,0 @@
1
- import{useWidgetStyles}from"../useWidgetStyles";import{useWidgetConfig}from"../useWidgetConfig";import{getThemeStyles}from"../../config/getThemeStyles";jest.mock("../useWidgetConfig",function(){return{useWidgetConfig:jest.fn()};});jest.mock("../../config/getThemeStyles",function(){return{getThemeStyles:jest.fn()};});describe('engage > core > hooks',function(){describe('useWidgetStyles()',function(){beforeEach(function(){jest.resetAllMocks();});it('should return an empty object if no styles property exists',function(){useWidgetConfig.mockReturnValueOnce({});getThemeStyles.mockReturnValueOnce({});var styles=useWidgetStyles();expect(styles).toEqual({});});it('should return an empty object if no styles exist',function(){useWidgetConfig.mockReturnValueOnce({style:{}});getThemeStyles.mockReturnValueOnce({});var styles=useWidgetStyles();expect(styles).toEqual({});});it('should return all widget styles.',function(){useWidgetConfig.mockReturnValueOnce({styles:{color:'#ff0000',width:'100%'}});getThemeStyles.mockReturnValueOnce({});var styles=useWidgetStyles();expect(styles).toEqual({color:'#ff0000',width:'100%'});});it('should return all theme styles.',function(){useWidgetConfig.mockReturnValueOnce({styles:{}});getThemeStyles.mockReturnValueOnce({color:'#ff0000',width:'100%'});var styles=useWidgetStyles();expect(styles).toEqual({color:'#ff0000',width:'100%'});});it('should return merged widget/theme styles.',function(){useWidgetConfig.mockReturnValueOnce({styles:{color:'#666666',height:'100%'}});getThemeStyles.mockReturnValueOnce({color:'#ff0000',width:'100%'});var styles=useWidgetStyles();expect(styles).toEqual({color:'#666666',width:'100%',height:'100%'});});it('should pass down its given params to the lower level helper function.',function(){useWidgetConfig.mockReturnValueOnce({});getThemeStyles.mockReturnValueOnce({});useWidgetStyles('widgetId',3);expect(useWidgetConfig).toBeCalledWith('widgetId',3);expect(useWidgetConfig).toBeCalledTimes(1);expect(getThemeStyles).toBeCalledWith('widgetId');expect(getThemeStyles).toBeCalledTimes(1);});});});
@@ -1 +0,0 @@
1
- function _typeof(obj){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj;}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;},_typeof(obj);}import*as core from'.';describe('engage > core',function(){it('should have exports',function(){expect(_typeof(core)).toEqual('object');});it('should not do undefined exports',function(){Object.keys(core).forEach(function(exportKey){expect(typeof core[exportKey]!=='undefined').toBe(true);});});});
@@ -1,2 +0,0 @@
1
- function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen);}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++){arr2[i]=arr[i];}return arr2;}function _iterableToArrayLimit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}import React from'react';import{shallow}from'enzyme';import appConfig from'@shopgate/pwa-common/helpers/config';import event from'@shopgate/pwa-core/classes/Event';import{APP_EVENT_VIEW_WILL_APPEAR,APP_EVENT_VIEW_WILL_DISAPPEAR}from'@shopgate/pwa-core/constants/AppEvents';import AppProvider from"../AppProvider";jest.mock('@shopgate/pwa-common/helpers/config',function(){return{some:'prop'};});jest.mock('@shopgate/pwa-core/classes/Event',function(){return{addCallback:jest.fn(),removeCallback:jest.fn()};});// eslint-disable-next-line require-jsdoc
2
- var MockComponent=function MockComponent(){return null;};describe('engage > core > providers > AppProvider',function(){beforeEach(function(){jest.clearAllMocks();});it('should initialize as expected',function(){var wrapper=shallow(/*#__PURE__*/React.createElement(AppProvider,null,/*#__PURE__*/React.createElement(MockComponent,null)));var instance=wrapper.instance();expect(wrapper).toMatchSnapshot();expect(wrapper.find(MockComponent).length).toEqual(1);expect(wrapper.prop('value')).toEqual({appConfig:appConfig,isVisible:true,setIsVisible:instance.setIsVisible});expect(event.addCallback).toHaveBeenCalledTimes(2);expect(event.addCallback).toHaveBeenCalledWith(APP_EVENT_VIEW_WILL_APPEAR,instance.setVisible);expect(event.addCallback).toHaveBeenCalledWith(APP_EVENT_VIEW_WILL_DISAPPEAR,instance.setHidden);});it('should handle calls of setIsVisible() as expected',function(){var wrapper=shallow(/*#__PURE__*/React.createElement(AppProvider,null,/*#__PURE__*/React.createElement(MockComponent,null)));var instance=wrapper.instance();var _wrapper$prop=wrapper.prop('value'),isVisible=_wrapper$prop.isVisible;expect(isVisible).toBe(true);instance.setIsVisible(false);var _wrapper$prop2=wrapper.prop('value');isVisible=_wrapper$prop2.isVisible;expect(isVisible).toBe(false);instance.setIsVisible(true);var _wrapper$prop3=wrapper.prop('value');isVisible=_wrapper$prop3.isVisible;expect(isVisible).toBe(true);});it('should handle event calls as expected',function(){var wrapper=shallow(/*#__PURE__*/React.createElement(AppProvider,null,/*#__PURE__*/React.createElement(MockComponent,null)));var _event$addCallback$mo=_slicedToArray(event.addCallback.mock.calls,2),_event$addCallback$mo2=_slicedToArray(_event$addCallback$mo[0],2),setVisible=_event$addCallback$mo2[1],_event$addCallback$mo3=_slicedToArray(_event$addCallback$mo[1],2),setHidden=_event$addCallback$mo3[1];var _wrapper$prop4=wrapper.prop('value'),isVisible=_wrapper$prop4.isVisible;expect(isVisible).toBe(true);setHidden();var _wrapper$prop5=wrapper.prop('value');isVisible=_wrapper$prop5.isVisible;expect(isVisible).toBe(false);setVisible();var _wrapper$prop6=wrapper.prop('value');isVisible=_wrapper$prop6.isVisible;expect(isVisible).toBe(true);});it('should remove the event listeners on unmount',function(){var wrapper=shallow(/*#__PURE__*/React.createElement(AppProvider,null,/*#__PURE__*/React.createElement(MockComponent,null)));var instance=wrapper.instance();wrapper.unmount();expect(event.removeCallback).toHaveBeenCalledTimes(2);expect(event.removeCallback).toHaveBeenCalledWith(APP_EVENT_VIEW_WILL_APPEAR,instance.setVisible);expect(event.removeCallback).toHaveBeenCalledWith(APP_EVENT_VIEW_WILL_DISAPPEAR,instance.setHidden);});});
@@ -1 +0,0 @@
1
- import{UIEvents}from'@shopgate/pwa-core';import{router}from'@virtuous/conductor';import{push,pop,replace,reset,update,NAVIGATION_PUSH,NAVIGATION_POP,NAVIGATION_REPLACE,NAVIGATION_RESET}from"../helpers";jest.mock('@shopgate/pwa-core',function(){return{UIEvents:{emit:jest.fn()}};});jest.mock('@virtuous/conductor',function(){return{router:{update:jest.fn(),getCurrentRoute:jest.fn(function(){return{id:'1234'};})}};});describe('Router > helpers',function(){test('push()',function(){push({pathname:'/test1'});expect(UIEvents.emit).toBeCalledWith(NAVIGATION_PUSH,{pathname:'/test1'});});test('pop()',function(){pop();expect(UIEvents.emit).toBeCalledWith(NAVIGATION_POP);});test('replace()',function(){replace({pathname:'/test2'});expect(UIEvents.emit).toBeCalledWith(NAVIGATION_REPLACE,{pathname:'/test2'});});test('reset()',function(){reset();expect(UIEvents.emit).toBeCalledWith(NAVIGATION_RESET);});describe('update()',function(){it('should use the current route\'s ID if no ID is passed',function(){update({foo:'bar'});expect(router.update).toBeCalledWith('1234',{foo:'bar'});});it('should use the custom ID if one is passed',function(){update({foo:'bar'},'345');expect(router.update).toBeCalledWith('345',{foo:'bar'});});});});
@@ -1 +0,0 @@
1
- function _typeof(obj){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj;}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;},_typeof(obj);}import*as favorites from'.';describe('engage > favorites',function(){it('should have exports',function(){expect(_typeof(favorites)).toEqual('object');});it('should not do undefined exports',function(){Object.keys(favorites).forEach(function(exportKey){expect(typeof favorites[exportKey]!=='undefined').toBe(true);});});});
@@ -1 +0,0 @@
1
- var _excluded=["manufacturer"];function _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key];}}return target;}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key];}return target;}import set from'lodash/set';import cloneDeep from'lodash/cloneDeep';import buildUpdatedFilters from"../buildUpdatedFilters";var mockedFilter={display_amount:{id:'display_amount',label:'Price',type:'range',value:[100,2000]},manufacturer:{id:'manufacturer',label:'Manufacturer',type:'multiselect',value:[{id:'wayland_corp',label:'Weyland Corp'},{id:'tyrell_corp',label:'Tyrell Corporation'}]}};describe('buildUpdatedFilters()',function(){it('should update filters as expected',function(){var updated=cloneDeep(mockedFilter);expect(buildUpdatedFilters({},updated)).toEqual(updated);});it('should exclude filters when they do not have values selected',function(){var initial=cloneDeep(mockedFilter);var updated=set(cloneDeep(mockedFilter),'manufacturer.value',[]);var manufacturer=mockedFilter.manufacturer,expected=_objectWithoutProperties(mockedFilter,_excluded);expect(buildUpdatedFilters(initial,updated)).toEqual(expected);});it('should round the values of a display amount filter',function(){var initial=cloneDeep(mockedFilter);var updated=set(cloneDeep(mockedFilter),'display_amount.value',[125,1920]);expect(buildUpdatedFilters(initial,updated)).toEqual(mockedFilter);});it('should return null both parameters are empty objects',function(){expect(buildUpdatedFilters({},{})).toBeNull();});});
@@ -1 +0,0 @@
1
- function _typeof(obj){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj;}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;},_typeof(obj);}import*as filter from'.';describe('engage > filter',function(){it('should have exports',function(){expect(_typeof(filter)).toEqual('object');});it('should not do undefined exports',function(){Object.keys(filter).forEach(function(exportKey){expect(typeof filter[exportKey]!=='undefined').toBe(true);});});});
package/index.spec.js DELETED
@@ -1 +0,0 @@
1
- function _typeof(obj){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj;}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;},_typeof(obj);}import*as engage from'.';describe('engage',function(){it('should have exports',function(){expect(_typeof(engage)).toEqual('object');});it('should not do undefined exports',function(){Object.keys(engage).forEach(function(exportKey){expect(typeof engage[exportKey]!=='undefined').toBe(true);});});});
@@ -1 +0,0 @@
1
- function _typeof(obj){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj;}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;},_typeof(obj);}import*as market from'.';describe('engage > market',function(){it('should have exports',function(){expect(_typeof(market)).toEqual('object');});it('should not do undefined exports',function(){Object.keys(market).forEach(function(exportKey){expect(typeof market[exportKey]!=='undefined').toBe(true);});});});
@@ -1 +0,0 @@
1
- function _typeof(obj){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj;}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;},_typeof(obj);}import*as orders from'.';describe('engage > orders',function(){it('should have exports',function(){expect(_typeof(orders)).toEqual('object');});it('should not do undefined exports',function(){Object.keys(orders).forEach(function(exportKey){expect(typeof orders[exportKey]!=='undefined').toBe(true);});});});
@@ -1 +0,0 @@
1
- function _typeof(obj){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj;}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;},_typeof(obj);}import*as page from'.';describe('engage > page',function(){it('should have exports',function(){expect(_typeof(page)).toEqual('object');});it('should not do undefined exports',function(){Object.keys(page).forEach(function(exportKey){expect(typeof page[exportKey]!=='undefined').toBe(true);});});});
@@ -1 +0,0 @@
1
- import React from'react';import{mount}from'enzyme';import configureStore from'redux-mock-store';import mockRenderOptions from'@shopgate/pwa-common/helpers/mocks/mockRenderOptions';import{PlaceholderParagraph}from'@shopgate/engage/components';import Description from"../index";jest.mock('@shopgate/engage/components');jest.mock("../connector",function(){return function(obj){return obj;};});describe('<Description />',function(){var mockStore=configureStore();it('should not render if no data is available',function(){var store=mockStore({});var wrapper=mount(/*#__PURE__*/React.createElement(Description,{store:store,html:null}),mockRenderOptions);var foundContent=wrapper.findWhere(function(n){return typeof n.prop('dangerouslySetInnerHTML')!=='undefined';});expect(wrapper).toMatchSnapshot();expect(foundContent.length).toEqual(0);expect(wrapper.find(PlaceholderParagraph).length).toEqual(1);expect(wrapper.find(PlaceholderParagraph).prop('ready')).toEqual(false);});});
@@ -1,3 +0,0 @@
1
- import{buildMediaImageUrl}from"./helpers";jest.mock('@shopgate/pwa-common/collections/Configuration',function(){return{get:jest.fn()};});describe('FeaturedMedia/helpers',function(){describe('buildMediaImageUrl',function(){it('should build feature image url default params',function(){var url='https://images.shopgate.services/v2/images/scale/https://gonzo.shopgatepg.com/pub/media/catalog/product/m/j/mj01-yellow_main_1.jpg?Expires=1561244400&Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cHM6Ly9pbWFnZXMuc2hvcGdhdGUuc2VydmljZXMvdjIvaW1hZ2VzL3NjYWxlL2h0dHBzOi8vZ29uem8uc2hvcGdhdGVwZy5jb20vcHViL21lZGlhL2NhdGFsb2cvcHJvZHVjdC9tL2ovbWowMS15ZWxsb3dfbWFpbl8xLmpwZz8qIiwiQ29uZGl0aW9uIjp7IkRhdGVMZXNzVGhhbiI6eyJBV1M6RXBvY2hUaW1lIjoxNTYxMjQ0NDAwfX19XX0_&Signature=e-0ijbS51pnXt6tu6DE22pYu4%7EvP-WCD%7EVtjS1%7ERA-TA-9KXp-vV7BBa06-aPxhCf7ikqlRHlPBxSl1lIepFrKppR5GJ6uUZeUWHWhD0YvQviO8sAQRFRAwCE%7E9NdS8Yi%7EuyKVmk%7E4LwruQQN6eefuDA67yKqWn4VUrItNGtC7RGfNpkvv%7Ekykhh5Z2Ou%7EiQkercpKV0ZDASJ0nZsFMqso2Q0BB7%7ERus9Tg0dIPSoWWqAA8tAKoyXd0eeFwG1WcAFI21MUnaN6k3Xnw0a8Lh2qG3yKNBvmGSZnT-wZrSVDjyiKPqMdra86GT13QYkLdcwAn7CDj01Vr1TIQS14fqhw__&Key-Pair-Id=APKAINMNDAWPE3XM2H7Q&version=1';var expected="".concat(url,"&width=440&height=440&quality=75&fill=fff&format=jpeg");expect(buildMediaImageUrl(url)).toEqual(expected);});it('should build feature image url custom params',function(){var url='https://images.shopgate.services/v2/images/scale/https://gonzo.shopgatepg.com/pub/media/catalog/product/m/j/mj01-yellow_main_1.jpg?Expires=1561244400&Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cHM6Ly9pbWFnZXMuc2hvcGdhdGUuc2VydmljZXMvdjIvaW1hZ2VzL3NjYWxlL2h0dHBzOi8vZ29uem8uc2hvcGdhdGVwZy5jb20vcHViL21lZGlhL2NhdGFsb2cvcHJvZHVjdC9tL2ovbWowMS15ZWxsb3dfbWFpbl8xLmpwZz8qIiwiQ29uZGl0aW9uIjp7IkRhdGVMZXNzVGhhbiI6eyJBV1M6RXBvY2hUaW1lIjoxNTYxMjQ0NDAwfX19XX0_&Signature=e-0ijbS51pnXt6tu6DE22pYu4%7EvP-WCD%7EVtjS1%7ERA-TA-9KXp-vV7BBa06-aPxhCf7ikqlRHlPBxSl1lIepFrKppR5GJ6uUZeUWHWhD0YvQviO8sAQRFRAwCE%7E9NdS8Yi%7EuyKVmk%7E4LwruQQN6eefuDA67yKqWn4VUrItNGtC7RGfNpkvv%7Ekykhh5Z2Ou%7EiQkercpKV0ZDASJ0nZsFMqso2Q0BB7%7ERus9Tg0dIPSoWWqAA8tAKoyXd0eeFwG1WcAFI21MUnaN6k3Xnw0a8Lh2qG3yKNBvmGSZnT-wZrSVDjyiKPqMdra86GT13QYkLdcwAn7CDj01Vr1TIQS14fqhw__&Key-Pair-Id=APKAINMNDAWPE3XM2H7Q&version=1';var expected="".concat(url,"&width=440&height=440&quality=100&fill=fff&format=webp");// eslint-disable-next-line extra-rules/no-single-line-objects
2
- expect(buildMediaImageUrl(url,{quality:100,format:'webp'})).toEqual(expected);});it('should build quality from format',function(){var url='https://images.shopgate.services/v2/images/scale/https://gonzo.shopgatepg.com/pub/media/catalog/product/m/j/mj01-yellow_main_1.jpg?Expires=1561244400&Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cHM6Ly9pbWFnZXMuc2hvcGdhdGUuc2VydmljZXMvdjIvaW1hZ2VzL3NjYWxlL2h0dHBzOi8vZ29uem8uc2hvcGdhdGVwZy5jb20vcHViL21lZGlhL2NhdGFsb2cvcHJvZHVjdC9tL2ovbWowMS15ZWxsb3dfbWFpbl8xLmpwZz8qIiwiQ29uZGl0aW9uIjp7IkRhdGVMZXNzVGhhbiI6eyJBV1M6RXBvY2hUaW1lIjoxNTYxMjQ0NDAwfX19XX0_&Signature=e-0ijbS51pnXt6tu6DE22pYu4%7EvP-WCD%7EVtjS1%7ERA-TA-9KXp-vV7BBa06-aPxhCf7ikqlRHlPBxSl1lIepFrKppR5GJ6uUZeUWHWhD0YvQviO8sAQRFRAwCE%7E9NdS8Yi%7EuyKVmk%7E4LwruQQN6eefuDA67yKqWn4VUrItNGtC7RGfNpkvv%7Ekykhh5Z2Ou%7EiQkercpKV0ZDASJ0nZsFMqso2Q0BB7%7ERus9Tg0dIPSoWWqAA8tAKoyXd0eeFwG1WcAFI21MUnaN6k3Xnw0a8Lh2qG3yKNBvmGSZnT-wZrSVDjyiKPqMdra86GT13QYkLdcwAn7CDj01Vr1TIQS14fqhw__&Key-Pair-Id=APKAINMNDAWPE3XM2H7Q&version=1';var expected="".concat(url,"&width=440&height=440&quality=100&fill=fff&format=png");// eslint-disable-next-line extra-rules/no-single-line-objects
3
- expect(buildMediaImageUrl(url,{quality:100,format:'png'})).toEqual(expected);});});});
@@ -1,12 +0,0 @@
1
- /* eslint-disable extra-rules/no-single-line-objects,global-require */var products=[{id:'007-001',characteristics:{1:'1',2:'1',3:'1'// equals L, Black, None
2
- }},{id:'007-002',characteristics:{1:'1',2:'2',3:'1'// equals L, Blue, None
3
- }},{id:'007-003',characteristics:{1:'1',2:'2',3:'3'// equals L, Blue, Stripes
4
- }},{id:'007-004',characteristics:{1:'2',2:'2',3:'3'// equals XL, Blue, Stripes
5
- }}];var characteristics=[{id:'1',label:'Size',values:[{id:'0',label:'Resilient'},{id:'1',label:'L'},{id:'2',label:'XL'}]},{id:'2',label:'Color',values:[{id:'0',label:'Transparent'},{id:'1',label:'Black'},{id:'2',label:'Blue'}]},{id:'3',label:'Pattern',values:[{id:'0',label:'No pattern'},{id:'1',label:'None'},{id:'2',label:'Checked'},{id:'3',label:'Stripes'}]}];describe('ProductCharacteristics helpers',function(){afterEach(function(){jest.resetModules();});describe('findSelectionIndex()',function(){var _require=require("./index"),findSelectionIndex=_require.findSelectionIndex;it('should return the index',function(){expect(findSelectionIndex(characteristics,'2')).toBe(1);});it('should return -1 when the the characteristic was not found',function(){expect(findSelectionIndex(characteristics,'5')).toBe(-1);});});describe('prepareState()',function(){var _require2=require("./index"),prepareState=_require2.prepareState;it('should return the current selections, when the selected ID is not found',function(){var selections={1:'1',2:'1',3:'1'};var result=prepareState('4','2',selections,characteristics,products);expect(result).toEqual(selections);});it('should return partial states when a full selection was not selected yet',function(){var selections={};// L
6
- var result=prepareState('1','1',selections,characteristics,products);expect(result).toEqual({1:'1'});// equals L, Blue
7
- result=prepareState('2','2',result,characteristics,products);expect(result).toEqual({1:'1',2:'2'});// equals L, Blue, Stripes
8
- result=prepareState('3','3',result,characteristics,products);expect(result).toEqual({1:'1',2:'2',3:'3'});});it('should return a full selections object when the middle selection was changed, but there is a product for the resulting selections',function(){// L, Black, None => L, Blue, None
9
- var selections={1:'1',2:'1',3:'1'};var result=prepareState('2','2',selections,characteristics,products);expect(result).toEqual({1:'1',2:'2',3:'1'});});it('should return a full selections object when there is only one product that matches the selected characteristics',function(){// XL => XL, Blue, Stripes
10
- var selections={};var result=prepareState('1','2',selections,characteristics,products);expect(result).toEqual({1:'2',2:'2',3:'3'});});it('should not reset when a value of the last selection is changed',function(){// L, Blue, None => L, Blue, Stripes
11
- var selections={1:'1',2:'2',3:'1'};var result=prepareState('3','3',selections,characteristics,products);expect(result).toEqual({1:'1',2:'2',3:'3'});});it('should reset the last selection when the middle selection was changed, but there is no matching product',function(){// L, Black, Checked => L, Blue
12
- var selections={1:'1',2:'1',3:'2'};var result=prepareState('2','2',selections,characteristics,products);expect(result).toEqual({1:'1',2:'2'});});});describe('selectCharacteristics()',function(){describe('default config',function(){var _require3=require("./index"),selectCharacteristics=_require3.selectCharacteristics;it('should return empty characteristics',function(){expect(selectCharacteristics({})).toEqual({});});it('should return characteristics for selected variant',function(){expect(selectCharacteristics({variantId:'007-001',variants:{products:products}})).toEqual(products[0].characteristics);});it('should preselect characteristics for only 1 variant',function(){expect(selectCharacteristics({variants:{products:[products[0]]}})).toEqual(products[0].characteristics);});it('should not preselect characteristics by config',function(){expect(selectCharacteristics({variants:{products:products}})).toEqual({});});});describe('preselect config',function(){jest.doMock('@shopgate/pwa-common/helpers/config',function(){return{product:{variantPreselect:true}};});it('should preselect characteristics for selectable product',function(){var _require4=require("./index"),selectCharacteristicsPreselect=_require4.selectCharacteristics;expect(selectCharacteristicsPreselect({variants:{characteristics:characteristics,products:products}})).toEqual(products[0].characteristics);});});});});/* eslint-enable extra-rules/no-single-line-objects,global-require */
@@ -1 +0,0 @@
1
- import React from'react';import PropTypes from'prop-types';import{mount}from'enzyme';import ProductGridPrice from"./index";jest.mock('@shopgate/engage/core/helpers/i18n',function(){return{i18n:{text:function text(input){return input;},price:function price(input){return input;},ready:true}};});var mockRenderOptions={context:{i18n:function i18n(){return{__:function __(input){return input;},_p:function _p(input){return input;}};}},childContextTypes:{i18n:PropTypes.func}};var mockPrice={currency:'EUR',msrp:0,discount:0,unitPrice:22.95,unitPriceMin:22.95,unitPriceStriked:0,info:'PriceInfoString'};var mockPriceStriked={currency:'EUR',msrp:0,discount:52,unitPrice:10.95,unitPriceMin:10.95,unitPriceStriked:22.95,info:''};var mockPriceMsrp={currency:'EUR',msrp:22.95,discount:52,unitPrice:10.95,unitPriceMin:10.95,unitPriceStriked:0,info:'PriceInfoString'};describe('<ProductGridPrice />',function(){it('should render without discounts',function(){var component=mount(/*#__PURE__*/React.createElement(ProductGridPrice,{price:mockPrice}),mockRenderOptions);var price=component.find('Price');var priceStriked=component.find('PriceStriked');var priceInfo=component.find('PriceInfo');expect(component).toMatchSnapshot();expect(price.exists()).toBe(true);expect(price.prop('currency')).toBe(mockPrice.currency);expect(price.prop('unitPrice')).toBe(mockPrice.unitPrice);expect(price.prop('unitPriceMin')).toBe(mockPrice.unitPriceMin);expect(price.prop('discounted')).toBe(false);expect(priceStriked.exists()).toBe(false);expect(priceInfo.exists()).toBe(true);expect(priceInfo.prop('text')).toBe(mockPrice.info);});it('should render with strike price',function(){var component=mount(/*#__PURE__*/React.createElement(ProductGridPrice,{price:mockPriceStriked}),mockRenderOptions);var price=component.find('Price');var priceStriked=component.find('PriceStriked');var priceInfo=component.find('PriceInfo');expect(component).toMatchSnapshot();expect(price.exists()).toBe(true);expect(price.prop('currency')).toBe(mockPriceStriked.currency);expect(price.prop('unitPrice')).toBe(mockPriceStriked.unitPrice);expect(price.prop('unitPriceMin')).toBe(mockPriceStriked.unitPriceMin);expect(price.prop('discounted')).toBe(true);expect(priceStriked.exists()).toBe(true);expect(priceStriked.prop('currency')).toBe(mockPriceStriked.currency);expect(priceStriked.prop('value')).toBe(mockPriceStriked.unitPriceStriked);expect(priceInfo.exists()).toBe(false);});it('should render with msrp',function(){var component=mount(/*#__PURE__*/React.createElement(ProductGridPrice,{price:mockPriceMsrp}),mockRenderOptions);var price=component.find('Price');var priceStriked=component.find('PriceStriked');var priceInfo=component.find('PriceInfo');expect(component).toMatchSnapshot();expect(price.exists()).toBe(true);expect(price.prop('currency')).toBe(mockPriceMsrp.currency);expect(price.prop('unitPrice')).toBe(mockPriceMsrp.unitPrice);expect(price.prop('unitPriceMin')).toBe(mockPriceMsrp.unitPriceMin);expect(price.prop('discounted')).toBe(true);expect(priceStriked.exists()).toBe(true);expect(priceStriked.prop('currency')).toBe(mockPriceMsrp.currency);expect(priceStriked.prop('value')).toBe(mockPriceMsrp.msrp);expect(priceInfo.exists()).toBe(true);expect(priceInfo.prop('text')).toBe(mockPriceMsrp.info);});});
@@ -1 +0,0 @@
1
- import React from'react';import{shallow}from'enzyme';import{isBeta}from"../../../../core";import Content from"../Content";jest.mock("../../../../core",function(){return{isBeta:jest.fn()};});jest.mock("../GroupedProperties",function(){return function GroupedProperties(){return'GroupedProperties';};});var properties=[{name:'test1',label:'Test 1',displayGroup:'Group 1'},{name:'test2',label:'Test 2',displayGroup:'Group 1'},{name:'test3',label:'Test 3',displayGroup:'Group 2'},{name:'test4',label:'Test 4',displayGroup:'Group 2'}];var propertiesSimple=[{name:'test1',label:'Test 1'}];describe('<Content />',function(){it('should not render if no props are passed',function(){var wrapper=shallow(/*#__PURE__*/React.createElement(Content,null));expect(wrapper.instance()).toEqual(null);expect(wrapper).toMatchSnapshot();});it('should render simple rows if not in beta',function(){isBeta.mockReturnValueOnce(false);var wrapper=shallow(/*#__PURE__*/React.createElement(Content,{properties:properties}));expect(wrapper.find('Wrapper').length).toEqual(1);expect(wrapper.find('Rows').length).toEqual(1);expect(wrapper).toMatchSnapshot();});it('should render simple rows of no groups could be found',function(){isBeta.mockReturnValueOnce(true);var wrapper=shallow(/*#__PURE__*/React.createElement(Content,{properties:propertiesSimple}));expect(wrapper.find('Wrapper').length).toEqual(1);expect(wrapper.find('Rows').length).toEqual(1);expect(wrapper).toMatchSnapshot();});it('should render grouped properties',function(){isBeta.mockReturnValueOnce(true);var wrapper=shallow(/*#__PURE__*/React.createElement(Content,{properties:properties}));expect(wrapper.find('GroupedProperties').length).toEqual(1);expect(wrapper.find('GroupedProperties').prop('groups')).toEqual(['Group 1','Group 2']);expect(wrapper).toMatchSnapshot();});});
@@ -1 +0,0 @@
1
- import React from'react';import{shallow}from'enzyme';import Group from"../Group";describe('<Group />',function(){it('should render a group title row',function(){var wrapper=shallow(/*#__PURE__*/React.createElement(Group,{group:"Test"}));expect(wrapper.find('tr').length).toEqual(1);expect(wrapper.find('td').length).toEqual(1);expect(wrapper.find('td').text()).toEqual('Test');expect(wrapper).toMatchSnapshot();});});
@@ -1 +0,0 @@
1
- import React from'react';import{shallow}from'enzyme';import GroupedProperties from"../GroupedProperties";var properties=[{name:'test1',label:'Test 1',displayGroup:'Group 1'},{name:'test2',label:'Test 2',displayGroup:'Group 1'},{name:'test3',label:'Test 3',displayGroup:'Group 2'},{name:'test4',label:'Test 4',displayGroup:'Group 2'}];var groups=['Group 1','Group 2'];describe('<GroupedProperties />',function(){it('should render as expected',function(){var wrapper=shallow(/*#__PURE__*/React.createElement(GroupedProperties,{properties:properties,groups:groups}));expect(wrapper.find('Wrapper').length).toEqual(2);expect(wrapper.find('Wrapper').at(0).prop('dense')).toEqual(true);expect(wrapper.find('Accordion').length).toEqual(2);expect(wrapper.find('Lists').length).toEqual(2);expect(wrapper).toMatchSnapshot();});});
@@ -1 +0,0 @@
1
- import React from'react';import{shallow}from'enzyme';import Lists from"../Lists";var propertiesNoSubs=[{name:'test1',label:'Test 1'},{name:'test2',label:'Test 2'}];var propertiesSubs=[{name:'test1',label:'Test 1',subDisplayGroup:'Test 1'},{name:'test2',label:'Test 2',subDisplayGroup:'Test 2'}];describe('<Lists />',function(){it('should only render simple rows',function(){var wrapper=shallow(/*#__PURE__*/React.createElement(Lists,{key:"1",properties:propertiesNoSubs}));expect(wrapper.find('Rows').length).toEqual(1);expect(wrapper.find('Group').length).toEqual(0);expect(wrapper).toMatchSnapshot();});it('should render groups only',function(){var wrapper=shallow(/*#__PURE__*/React.createElement(Lists,{key:"2",properties:propertiesSubs}));expect(wrapper.find('Rows').length).toEqual(3);expect(wrapper.find('Rows').at(0).prop('properties')).toEqual([]);expect(wrapper.find('Rows').at(1).prop('properties')).toEqual([{name:'test1',label:'Test 1',subDisplayGroup:'Test 1'}]);expect(wrapper.find('Rows').at(2).prop('properties')).toEqual([{name:'test2',label:'Test 2',subDisplayGroup:'Test 2'}]);expect(wrapper.find('Group').length).toEqual(2);expect(wrapper.find('Group').at(0).prop('group')).toEqual('Test 1');expect(wrapper.find('Group').at(1).prop('group')).toEqual('Test 2');});});
@@ -1 +0,0 @@
1
- import React from'react';import{mount}from'enzyme';import configureStore from'redux-mock-store';import mockConsole from'jest-mock-console';import ProductProperties from"../ProductProperties";import{makeGetProductProperties}from"../../../selectors/product";var mockStore=configureStore();var store=mockStore({});jest.mock("../../../selectors/product",function(){return{makeGetProductProperties:jest.fn(function(){return jest.fn();})};});var properties=[{displayGroup:'test'}];describe('<ProductProperties />',function(){var restoreConsole;beforeEach(function(){restoreConsole=mockConsole();});afterEach(function(){restoreConsole();});it('should not render if no properties where passed',function(){makeGetProductProperties.mockReturnValueOnce(function(){return null;});var wrapper=mount(/*#__PURE__*/React.createElement(ProductProperties,{key:"1",store:store}));expect(wrapper.find('ProductProperties').instance()).toEqual(null);expect(wrapper).toMatchSnapshot();});it('should render if properties are passed',function(){makeGetProductProperties.mockReturnValueOnce(function(){return properties;});var wrapper=mount(/*#__PURE__*/React.createElement(ProductProperties,{key:"2",store:store}));expect(wrapper.find('Content').length).toEqual(1);expect(wrapper).toMatchSnapshot();});});
@@ -1 +0,0 @@
1
- import React from'react';import{shallow}from'enzyme';import Row from"../Row";describe('<Row />',function(){it('should render as expected',function(){var wrapper=shallow(/*#__PURE__*/React.createElement(Row,{label:"TestLabel",value:"TestValue"}));expect(wrapper.find('td').at(0).text()).toEqual('TestLabel');expect(wrapper.find('td').at(1).text()).toEqual('TestValue');expect(wrapper).toMatchSnapshot();});});
@@ -1 +0,0 @@
1
- import React from'react';import{shallow}from'enzyme';import Rows from"../Rows";var properties=[{label:'test1',value:'123'},{label:'test2',value:'456'},{label:'test3',value:'789'}];describe('<Rows />',function(){it('should render three rows of properties',function(){var wrapper=shallow(/*#__PURE__*/React.createElement(Rows,{properties:properties}));expect(wrapper.find('Row').length).toEqual(3);expect(wrapper).toMatchSnapshot();});});
@@ -1 +0,0 @@
1
- import{getGroupsFromProperties}from"../../helpers/getGroupsFromProperties";describe('engage > product > ProductProperties',function(){describe('getGroupsFromProperties()',function(){it('should return an empty array of no properties are passed',function(){var result=getGroupsFromProperties();expect(result.length).toBe(0);});it('should return an empty array if there are no groups included',function(){var result=getGroupsFromProperties([{label:'test1',value:'Test 1'},{label:'test2',value:'Test 2'}]);expect(result.length).toBe(0);});it('should return an array including 1 group',function(){var result=getGroupsFromProperties([{label:'test1',value:'Test 1',displayGroup:'TestGroup'},{label:'test2',value:'Test 2',displayGroup:'TestGroup'}]);expect(result.length).toBe(1);expect(result).toEqual(['TestGroup']);});});});
@@ -1 +0,0 @@
1
- import{getSubgroupsFromProperties}from"../../helpers/getSubgroupsFromProperties";describe('engage > product > ProductProperties',function(){describe('getSubgroupsFromProperties()',function(){it('should return an empty array of no properties are passed',function(){var result=getSubgroupsFromProperties();expect(result.length).toBe(0);});it('should return an empty array if there are no groups included',function(){var result=getSubgroupsFromProperties([{label:'test1',value:'Test 1'},{label:'test2',value:'Test 2'}]);expect(result.length).toBe(0);});it('should return an array including 1 group',function(){var result=getSubgroupsFromProperties([{label:'test1',value:'Test 1',subDisplayGroup:'TestSubgroup'},{label:'test2',value:'Test 2',subDisplayGroup:'TestSubgroup'}]);expect(result.length).toBe(1);expect(result).toEqual(['TestSubgroup']);});});});
@@ -1 +0,0 @@
1
- /* eslint-disable extra-rules/no-single-line-objects */import{getQuantityRange}from"./helpers";jest.mock("../../../core",function(){return{useWidgetSettings:jest.fn().mockReturnValue({minOrderQuantity:3,maxOrderQuantity:10})};});describe('QuantityPicker/helpers',function(){describe('should return correct min',function(){it('should return 3 from settings with empty stock',function(){expect(getQuantityRange()).toEqual({min:3,max:10});});it('should return 1 from stock',function(){expect(getQuantityRange({minOrderQuantity:1})).toEqual({min:1,max:10});});it('should return 5 from stock',function(){expect(getQuantityRange({minOrderQuantity:5})).toEqual({min:5,max:10});});});describe('should return correct max',function(){it('should return 10 from settings with empty stock',function(){expect(getQuantityRange()).toEqual({min:3,max:10});});it('should return 5 from stock',function(){expect(getQuantityRange({minOrderQuantity:1,maxOrderQuantity:5})).toEqual({min:1,max:5});});it('should return 5 from stock',function(){expect(getQuantityRange({minOrderQuantity:5,maxOrderQuantity:8})).toEqual({min:5,max:8});});it('should return 2 as max based on 2 as min from stock',function(){expect(getQuantityRange({maxOrderQuantity:2})).toEqual({min:2,max:2});});});});/* eslint-enable extra-rules/no-single-line-objects */
@@ -1 +0,0 @@
1
- import React from'react';import{Conditioner}from'@shopgate/pwa-core';export var defaultContext={productId:null,variantId:null,options:{},characteristics:{},setCharacteristic:jest.fn(),conditioner:new Conditioner()};var context;export var ProductContext={Provider:function Provider(props){/* eslint-disable react/prop-types */context=props.value||defaultContext;return/*#__PURE__*/React.createElement('div',null,props.children);/* eslint-enable react/prop-types */},Consumer:function Consumer(props){return props.children(context||defaultContext);}};
@@ -1,4 +0,0 @@
1
- function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import{useWidgetSettings}from"../../core";import withMapPricing from"./withMapPricing";jest.mock('@shopgate/engage/components',function(){return{TimeBoundary:jest.fn()};});jest.mock("../../core",function(){return{useWidgetSettings:jest.fn()};});describe('withMapPricing',function(){var price={unitPrice:100.0,unitPriceStriked:150.0};var mapPricing={price:120.0};var mockComponent;beforeEach(function(){mockComponent=jest.fn();jest.resetAllMocks();});describe('should keep origin price',function(){it('should return origin when settings is off',function(){useWidgetSettings.mockReturnValue({show:false});expect(withMapPricing(mockComponent)({}).props).toEqual({});});it('should return empty props',function(){useWidgetSettings.mockReturnValue({show:true});expect(withMapPricing(mockComponent)({}).props).toEqual({});});it('should return original price',function(){useWidgetSettings.mockReturnValue({show:true});expect(withMapPricing(mockComponent)({price:price}).props).toEqual({price:price});});it('should return origin with lesser mapPrice',function(){useWidgetSettings.mockReturnValue({show:true});var component=withMapPricing(mockComponent)({price:_extends({},price,{mapPricing:[_extends({},mapPricing,{price:90})]})});expect(component.props).toEqual({price:_extends({},price,{mapPricing:[_extends({},mapPricing,{price:90})]})});});it('should not mutate when mapPrice out of time boundary',function(){useWidgetSettings.mockReturnValue({show:true});var component=withMapPricing(mockComponent)({price:_extends({},price,{mapPricing:[_extends({},mapPricing)]})});expect(component.props.children).toBeInstanceOf(Function);// Simulate time boundary
2
- var children=component.props.children({between:false});expect(children.props).toEqual({price:_extends({},price,{mapPricing:[_extends({},mapPricing)]})});});});describe('should mutate',function(){it('should mutate strike price',function(){useWidgetSettings.mockReturnValue({show:true});var component=withMapPricing(mockComponent)({price:_extends({},price,{mapPricing:[_extends({},mapPricing)]})});expect(component.props.children).toBeInstanceOf(Function);// Simulate time boundary
3
- var children=component.props.children({between:true});expect(children.props).toEqual({price:_extends({},price,{unitPriceStriked:120,// mutated
4
- mapPricing:[_extends({},mapPricing)]})});});});});
@@ -1 +0,0 @@
1
- function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import withPriceCalculation from"./withPriceCalculation";import withMapPricing from"./withMapPricing";jest.mock("../../core",function(){return{isBeta:jest.fn().mockReturnValue(true)};});jest.mock("./withMapPricing");describe('withPriceCalculation',function(){var price={unitPrice:100.0,unitPriceStriked:150.0};var mapPricing={price:120.0};var mockComponent;beforeEach(function(){mockComponent=jest.fn();});it('should return empty props',function(){var component=withPriceCalculation(mockComponent)({});expect(component.props).toEqual({});});it('should return original price',function(){var component=withPriceCalculation(mockComponent)({price:price});expect(component.props).toEqual({price:price});});it('should invoke withMapPricing hoc',function(){var thunk=jest.fn();withMapPricing.mockReturnValue(thunk);withPriceCalculation(mockComponent)({price:_extends({},price,{mapPricing:mapPricing})});expect(withMapPricing).toBeCalledTimes(1);expect(thunk).toBeCalledWith({price:_extends({},price,{mapPricing:mapPricing})});});});
@@ -1 +0,0 @@
1
- function _typeof(obj){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj;}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;},_typeof(obj);}import*as product from'.';describe('engage > product',function(){it('should have exports',function(){expect(_typeof(product)).toEqual('object');});it('should not do undefined exports',function(){Object.keys(product).forEach(function(exportKey){expect(typeof product[exportKey]!=='undefined').toBe(true);});});});
@@ -1 +0,0 @@
1
- import{getProductState,getProductId}from'@shopgate/pwa-common-commerce/product/selectors/product';import{MEDIA_TYPE_IMAGE,MEDIA_TYPE_VIDEO}from"../../constants";import{getProductMediaState,makeGetProductMedia}from"../media";jest.mock('@shopgate/pwa-common-commerce/product/selectors/product',function(){return{getProductState:jest.fn(),getProductId:jest.fn()};});var mockedState={mediaByProductId:{ABC:{isFetching:false,media:[{code:null,type:MEDIA_TYPE_IMAGE,url:'http://www.abc.de',altText:null,title:null,sequenceId:1},{code:null,type:MEDIA_TYPE_VIDEO,url:'http://www.abc.de',altText:null,title:null,sequenceId:2}]},XYZ:{isFetching:true,media:[]}}};describe('engage > product > selectors > media',function(){beforeAll(function(){getProductState.mockReturnValue(mockedState);getProductId.mockImplementation(function(_){var props=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};return props.productId;});});describe('getProductMediaState()',function(){it('should return the state',function(){var result=getProductMediaState({});expect(result).toEqual(mockedState.mediaByProductId);});});describe('getProductMedia()',function(){var getProductMedia;beforeEach(function(){getProductMedia=makeGetProductMedia();});it('should return different selector instances',function(){expect(getProductMedia).not.toBe(makeGetProductMedia());});it('should return NULL when no product media was found',function(){var result=getProductMedia({},{productId:'123'});expect(result).toBeNull();});it('should return NULL when product media is fetching',function(){var result=getProductMedia({},{productId:'XYZ'});expect(result).toBeNull();});it('should return media when no types are passed',function(){var result=getProductMedia({},{productId:'ABC'});expect(result).toEqual(mockedState.mediaByProductId.ABC.media);});it('should return filtered media when a type is passed',function(){var result=getProductMedia({},{productId:'ABC',types:[MEDIA_TYPE_VIDEO]});expect(result).toEqual([mockedState.mediaByProductId.ABC.media[1]]);});});});
@@ -1 +0,0 @@
1
- import{getProductPriceData}from'@shopgate/pwa-common-commerce/product';import{makeGetProductPriceData,makeGetProductMapPrice}from"../price";import{wrapMemoizedSelector}from"../helpers";jest.mock('@shopgate/pwa-common-commerce/product',function(){return{getProductPriceData:jest.fn()};});describe('engage > product > selectors > price',function(){describe('makeGetProductPriceData()',function(){var getProductPriceDataWrapped;beforeEach(function(){getProductPriceDataWrapped=wrapMemoizedSelector(makeGetProductPriceData());});it('should return null',function(){getProductPriceData.mockReturnValueOnce(null);expect(getProductPriceDataWrapped()).toEqual(null);});it('should return price data',function(){getProductPriceData.mockReturnValueOnce({unitAmount:10});expect(getProductPriceDataWrapped({},{})).toEqual({unitAmount:10});});});describe('makeGetProductMapPrice()',function(){var getProductMapPricing;beforeEach(function(){getProductMapPricing=wrapMemoizedSelector(makeGetProductMapPrice());});it('should return null when price is null',function(){getProductPriceData.mockReturnValueOnce(null);expect(getProductMapPricing({},{productId:'456'})).toBeNull();});it('should return null when mapPricing is null',function(){getProductPriceData.mockReturnValueOnce({unitAmount:10});expect(getProductMapPricing({},{productId:'456'})).toBeNull();});it('should return from pojo',function(){getProductPriceData.mockReturnValueOnce({mapPricing:{price:10}});expect(getProductMapPricing({},{productId:'456'})).toEqual({price:10});});it('should return from array',function(){getProductPriceData.mockReturnValueOnce({mapPricing:[{price:10}]});expect(getProductMapPricing({},{productId:'456'})).toEqual({price:10});});});});
@@ -1,2 +0,0 @@
1
- import{getProductPropertiesState,getProductId,getProduct,getProductDataById}from'@shopgate/pwa-common-commerce/product/selectors/product';import{makeGetProductProperties,makeGetProductEffectivityDates,makeGetProductCharacteristics,makeGetProductFeaturedMedia}from"../product";import{wrapMemoizedSelector}from"../helpers";jest.mock('@shopgate/pwa-common-commerce/product/selectors/product',function(){return{getProduct:jest.fn(),getProductPropertiesState:jest.fn(),getProductId:jest.fn(),getProductDataById:jest.fn(),getProductPropertiesUnfiltered:jest.fn()};});var mockState={123:{properties:[{label:'Test',value:'123'}],startDate:'2019-04-01T10:00:00.000Z',endDate:'2019-04-10T10:00:00.000Z',characteristics:[{id:'01-color',label:'Color'// more properties available but of no interest for tests
2
- }],featuredMedia:{code:null,type:'image',url:'https://example.com/image',altText:null,title:null,sequenceId:1}},456:{properties:null,characteristics:null}};describe('engage > product > selectors',function(){describe('getProductProperties()',function(){var getProductProperties;beforeEach(function(){getProductProperties=wrapMemoizedSelector(makeGetProductProperties());});it('should return null if a properties state can not be found',function(){getProductPropertiesState.mockReturnValueOnce(mockState);getProductId.mockReturnValueOnce('012');var result=getProductProperties(mockState,{productId:'012'});expect(result).toEqual(null);});it('should return null of no properties have been received for the product',function(){getProductPropertiesState.mockReturnValueOnce(mockState);getProductId.mockReturnValueOnce('456');var result=getProductProperties(mockState,{productId:'456'});expect(result).toEqual(null);});it('should return properties if they are set for the product',function(){getProductPropertiesState.mockReturnValueOnce(mockState);getProductId.mockReturnValueOnce('123');var result=getProductProperties(mockState,{productId:'123'});expect(result).toEqual([{label:'Test',value:'123'}]);});});describe('getProductEffectivityDates()',function(){var getProductEffectivityDates;beforeEach(function(){getProductEffectivityDates=wrapMemoizedSelector(makeGetProductEffectivityDates());});it('should return null',function(){getProduct.mockReturnValueOnce(null);expect(getProductEffectivityDates(mockState,{productId:'456'})).toBeNull();});it('should return dates',function(){getProduct.mockReturnValueOnce(mockState[123]);expect(getProductEffectivityDates(mockState,{productId:'123'})).toEqual({startDate:'2019-04-01T10:00:00.000Z',endDate:'2019-04-10T10:00:00.000Z'});});});describe('getProductCharacteristics()',function(){var getProductCharacteristics;beforeEach(function(){getProductCharacteristics=wrapMemoizedSelector(makeGetProductCharacteristics());});it('should return null if a product state can not be found',function(){getProductDataById.mockReturnValueOnce(null);var result=getProductCharacteristics(mockState,{productId:'012'});expect(result).toEqual(null);});it('should return null of no characteristics are available for the product',function(){getProductDataById.mockReturnValueOnce(mockState[456]);var result=getProductCharacteristics(mockState,{productId:'456'});expect(result).toEqual(null);});it('should return all characteristics if available for the product',function(){getProductDataById.mockReturnValueOnce(mockState[123]);var result=getProductCharacteristics(mockState,{productId:'123'});expect(result).toEqual([{id:'01-color',label:'Color'}]);});});describe('getProductFeaturedMedia',function(){var getProductFeaturedMedia;beforeEach(function(){getProductFeaturedMedia=makeGetProductFeaturedMedia();});it('should return null if a product state can not be found',function(){getProduct.mockReturnValueOnce(null);var result=getProductFeaturedMedia(mockState,{productId:'012'});expect(result).toEqual(null);});it('should return null of no featured media is available for the product',function(){getProduct.mockReturnValueOnce(mockState[456]);var result=getProductFeaturedMedia(mockState,{productId:'456'});expect(result).toEqual(null);});it('should return featured media if available for the product',function(){getProduct.mockReturnValueOnce(mockState[123]);var result=getProductFeaturedMedia(mockState,{productId:'123'});expect(result).toEqual(mockState[123].featuredMedia);});});});
@@ -1 +0,0 @@
1
- import{generateProductRelationsHash}from'@shopgate/pwa-common-commerce/product';import{wrapMemoizedSelector}from"../helpers";import{makeGetMaximumRelatedProducts,makeGetRelatedProducts}from"../relations";jest.mock('@shopgate/pwa-common-commerce/product',function(){var _jest$requireActual=jest.requireActual('@shopgate/pwa-common-commerce/product'),getProductState=_jest$requireActual.getProductState,getProducts=_jest$requireActual.getProducts;return{getProductState:getProductState,generateProductRelationsHash:jest.fn(),getProducts:getProducts};});var mockState={product:{productRelationsByHash:{somehashhere:[],somehashthere:{productIds:['123','456']}},productsById:{123:{productData:{name:'foo'}},456:{productData:{name:'bar'}}}}};describe('engage > product > selectors > relations',function(){describe('makeGetRelatedProducts()',function(){var getRelatedProducts;beforeEach(function(){getRelatedProducts=wrapMemoizedSelector(makeGetRelatedProducts());});it('should return empty array',function(){generateProductRelationsHash.mockReturnValueOnce('somehashhere');expect(getRelatedProducts(mockState,{productId:'789',type:'upselling',limit:100})).toEqual([]);});it('should return two products',function(){generateProductRelationsHash.mockReturnValueOnce('somehashthere');expect(getRelatedProducts(mockState,{productId:'789',type:'upselling',limit:100})).toEqual([{name:'foo'},{name:'bar'}]);});});describe('makeGetMaximumRelatedProducts()',function(){var getMaximumRelatedProducts;beforeEach(function(){getMaximumRelatedProducts=wrapMemoizedSelector(makeGetMaximumRelatedProducts());});it('should return an empty array',function(){generateProductRelationsHash.mockReturnValueOnce('somehashhere');expect(getMaximumRelatedProducts(mockState,{productId:'789',type:'upselling',limit:100,max:1})).toEqual({products:[],productsCount:0});});it('should return an array with one product',function(){generateProductRelationsHash.mockReturnValueOnce('somehashthere');expect(getMaximumRelatedProducts(mockState,{productId:'789',type:'upselling',limit:100,max:1})).toEqual({products:[{name:'foo'}],productsCount:2});});it('should return an array with two products',function(){generateProductRelationsHash.mockReturnValueOnce('somehashthere');expect(getMaximumRelatedProducts(mockState,{productId:'789',type:'upselling',limit:100,max:2})).toEqual({products:[{name:'foo'},{name:'bar'}],productsCount:2});});});});
@@ -1 +0,0 @@
1
- import{getProductVariants}from'@shopgate/pwa-common-commerce/product';import{makeGetProductByCharacteristics,makeGetCharacteristicsFeaturedImage,makeGetCharacteristicsFeaturedMedia}from"../variants";import{MEDIA_TYPE_IMAGE,MEDIA_TYPE_VIDEO}from"../../constants";jest.mock('@shopgate/pwa-common-commerce/product',function(){return{getProductVariants:jest.fn()};});var mockedState={products:[{id:'123',characteristics:{size:'XL',color:'red'},featuredImageBaseUrl:'http://www.abc.de',featuredImageUrl:'http://www.abc.de',featuredMedia:{code:null,type:MEDIA_TYPE_IMAGE,url:'http://www.abc.de',altText:null,title:null,sequenceId:1}},{id:'456',characteristics:{size:'XL',color:'blue'},featuredImageUrl:'http://www.xyz.de',featuredImageBaseUrl:'http://www.xyz.de',featuredMedia:{code:null,type:MEDIA_TYPE_IMAGE,url:'http://www.xyz.de',altText:null,title:null,sequenceId:1}}]};describe('engage > product > selectors > variants',function(){describe('makeGetProductByCharacteristics()',function(){var getProductByCharacteristic;beforeEach(function(){getProductByCharacteristic=makeGetProductByCharacteristics();});it('should return different selector instances',function(){expect(getProductByCharacteristic).not.toBe(makeGetProductByCharacteristics());});it('should return null',function(){getProductVariants.mockReturnValueOnce(null);expect(getProductByCharacteristic({},{characteristics:null})).toEqual(null);});it('should return a product with one selected characteristic',function(){getProductVariants.mockReturnValueOnce(mockedState);expect(getProductByCharacteristic({},{characteristics:{size:'XL'}})).toEqual(mockedState.products[0]);});it('should return a product with all selected characteristics',function(){getProductVariants.mockReturnValueOnce(mockedState);expect(getProductByCharacteristic({},{characteristics:{size:'XL',color:'blue'}})).toEqual(mockedState.products[1]);});});describe('makeGetCharacteristicsFeaturedImage()',function(){var getCharacteristicFeaturedImage;beforeEach(function(){getCharacteristicFeaturedImage=makeGetCharacteristicsFeaturedImage();});it('should return different selector instances',function(){expect(getCharacteristicFeaturedImage).not.toBe(makeGetCharacteristicsFeaturedImage());});it('should return null',function(){getProductVariants.mockReturnValueOnce(null);expect(getCharacteristicFeaturedImage({},{characteristics:null})).toEqual(null);});it('should return a featured image URL',function(){getProductVariants.mockReturnValueOnce(mockedState);expect(getCharacteristicFeaturedImage({},{characteristics:{size:'XL',color:'blue'}})).toEqual('http://www.xyz.de');});});describe('makeGetCharacteristicsFeaturedMedia()',function(){var getCharacteristicsFeaturedMedia;beforeEach(function(){getCharacteristicsFeaturedMedia=makeGetCharacteristicsFeaturedMedia();});it('should return different selector instances',function(){expect(getCharacteristicsFeaturedMedia).not.toBe(makeGetCharacteristicsFeaturedMedia());});it('should return null',function(){getProductVariants.mockReturnValueOnce(null);expect(getCharacteristicsFeaturedMedia({},{characteristics:null})).toEqual(null);});it('should return featured media',function(){getProductVariants.mockReturnValueOnce(mockedState);expect(getCharacteristicsFeaturedMedia({},{characteristics:{size:'XL',color:'blue'}})).toEqual({code:null,type:MEDIA_TYPE_IMAGE,url:'http://www.xyz.de',altText:null,title:null,sequenceId:1});});it('should return featured media when the media types matches',function(){getProductVariants.mockReturnValueOnce(mockedState);expect(getCharacteristicsFeaturedMedia({},{characteristics:{size:'XL',color:'blue'},type:MEDIA_TYPE_IMAGE})).toEqual({code:null,type:MEDIA_TYPE_IMAGE,url:'http://www.xyz.de',altText:null,title:null,sequenceId:1});});it('should return null when the media type does not match',function(){getProductVariants.mockReturnValueOnce(mockedState);expect(getCharacteristicsFeaturedMedia({},{characteristics:{size:'XL',color:'blue'},type:MEDIA_TYPE_VIDEO})).toBeNull();});});});
@@ -1 +0,0 @@
1
- export default[{label:'TestProperty1',value:'15kg',displayGroup:'Weights'},{label:'TestProperty2',value:'120kg',displayGroup:'Weights'},{label:'TestProperty3',value:'kg = lbs',displayGroup:'Weights',subDisplayGroup:'Units'},{label:'TestProperty4',value:'sep = sup',displayGroup:'Weights',subDisplayGroup:'Units'},{label:'TestProperty5',value:'Foo',displayGroup:'Weights',subDisplayGroup:'Something'},{label:'TestProperty6',value:'Bar',displayGroup:'Weights',subDisplayGroup:'Something'},{label:'TestProperty3',value:'kg = lbs',displayGroup:'Something Else',subDisplayGroup:'Units'},{label:'TestProperty4',value:'sep = sup',displayGroup:'Something Else',subDisplayGroup:'Units'},{label:'TestProperty5',value:'Foo',displayGroup:'Something Else',subDisplayGroup:'Something'},{label:'TestProperty6',value:'Bar',displayGroup:'Something Else',subDisplayGroup:'Something'}];
@@ -1 +0,0 @@
1
- function _typeof(obj){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj;}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;},_typeof(obj);}import*as reviews from'.';describe('engage > reviews',function(){it('should have exports',function(){expect(_typeof(reviews)).toEqual('object');});it('should not do undefined exports',function(){Object.keys(reviews).forEach(function(exportKey){expect(typeof reviews[exportKey]!=='undefined').toBe(true);});});});
@@ -1 +0,0 @@
1
- function _typeof(obj){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj;}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;},_typeof(obj);}import*as scanner from'.';jest.mock('@shopgate/pwa-core/classes/AppCommand');describe('engage > scanner',function(){it('should have exports',function(){expect(_typeof(scanner)).toEqual('object');});it('should not do undefined exports',function(){Object.keys(scanner).forEach(function(exportKey){expect(typeof scanner[exportKey]!=='undefined').toBe(true);});});});
@@ -1 +0,0 @@
1
- function _typeof(obj){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj;}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;},_typeof(obj);}import*as search from'.';describe('engage > search',function(){it('should have exports',function(){expect(_typeof(search)).toEqual('object');});it('should not do undefined exports',function(){Object.keys(search).forEach(function(exportKey){expect(typeof search[exportKey]!=='undefined').toBe(true);});});});
@@ -1 +0,0 @@
1
- function _typeof(obj){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj;}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;},_typeof(obj);}import*as user from'.';describe('engage > user',function(){it('should have exports',function(){expect(_typeof(user)).toEqual('object');});it('should not do undefined exports',function(){Object.keys(user).forEach(function(exportKey){expect(typeof user[exportKey]!=='undefined').toBe(true);});});});
@@ -1 +0,0 @@
1
- function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import{makeGetLoginStrategy}from"../login";var mockedState={user:{login:{isFetching:false,disabled:false,isLoggedIn:true,errors:null,strategy:'default'}}};describe('engage > user > selectors > login',function(){describe('getProductMedia()',function(){var getLoginStrategy;beforeEach(function(){getLoginStrategy=makeGetLoginStrategy();});it('should return different selector instances',function(){expect(getLoginStrategy).not.toBe(makeGetLoginStrategy());});it('should return NULL when the store is empty',function(){var result=getLoginStrategy({});expect(result).toBeNull();});it('should return NULL when the login state does not contain a strategy',function(){var result=getLoginStrategy({user:{login:_extends({},mockedState.user.login,{strategy:null})}});expect(result).toBeNull();});it('should return a login strategy',function(){var result=getLoginStrategy(mockedState);expect(result).toBe(mockedState.user.login.strategy);});});});