@shopgate/engage 6.22.0-beta.3 → 6.22.0-beta.4

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 (125) hide show
  1. package/back-in-stock/reducers/index.js +2 -2
  2. package/back-in-stock/selectors/index.js +22 -6
  3. package/back-in-stock/subscriptions/index.js +10 -2
  4. package/core/action-creators/appPermissions.js +9 -0
  5. package/core/action-creators/index.js +1 -0
  6. package/core/actions/getGeolocation.js +1 -1
  7. package/core/actions/grantCameraPermissions.js +1 -1
  8. package/core/actions/grantGeolocationPermissions.js +1 -1
  9. package/core/actions/grantPermissions.js +4 -4
  10. package/core/actions/grantPushPermissions.js +1 -1
  11. package/core/actions/index.js +1 -0
  12. package/core/actions/requestAppPermission.js +7 -0
  13. package/core/actions/requestAppPermissionStatus.js +7 -0
  14. package/core/collections/AppInitialization.js +49 -0
  15. package/core/collections/index.js +1 -0
  16. package/core/constants/actionTypes.js +1 -0
  17. package/core/constants/index.js +6 -0
  18. package/core/index.js +8 -12
  19. package/core/initialization/index.js +7 -0
  20. package/core/streams/appPermissions.js +19 -0
  21. package/core/streams/index.js +1 -0
  22. package/package.json +7 -7
  23. package/push-opt-in/components/PushOptInModal/push-opt-in.svg +62 -0
  24. package/push-opt-in/subscriptions/optInTrigger.js +3 -3
  25. package/a11y/components/LiveMessage/__tests__/index.spec.js +0 -1
  26. package/a11y/components/LiveMessenger/__tests__/helpers.spec.js +0 -1
  27. package/a11y/components/LiveMessenger/__tests__/index.spec.js +0 -1
  28. package/a11y/components/Navigation/__tests__/index.spec.js +0 -1
  29. package/a11y/components/Section/__tests__/index.spec.js +0 -1
  30. package/a11y/index.spec.js +0 -1
  31. package/cart/index.spec.js +0 -1
  32. package/category/index.spec.js +0 -1
  33. package/checkout/index.spec.js +0 -1
  34. package/components/Footer/__tests__/Footer.spec.js +0 -8
  35. package/components/Form/Builder/Builder.spec.js +0 -19
  36. package/components/Form/Builder/classes/ActionListener.spec.js +0 -21
  37. package/components/Form/Builder/helpers/buildCountryList.spec.js +0 -1
  38. package/components/Form/Builder/helpers/buildFormDefaults.spec.js +0 -1
  39. package/components/Form/Builder/helpers/buildFormElements.spec.js +0 -3
  40. package/components/Form/Builder/helpers/buildProvinceList.spec.js +0 -1
  41. package/components/IntersectionVisibility/__tests__/index.js +0 -1
  42. package/components/View/__mocks__/context.js +0 -1
  43. package/components/View/__mocks__/index.js +0 -5
  44. package/components/View/__tests__/index.spec.js +0 -1
  45. package/components/View/__tests__/provider.spec.js +0 -1
  46. package/components/View/components/Above/__tests__/index.spec.js +0 -1
  47. package/components/View/components/Below/__tests__/index.spec.js +0 -1
  48. package/components/View/components/Content/__tests__/index.spec.js +0 -2
  49. package/components/__mocks__/index.js +0 -4
  50. package/components/index.spec.js +0 -1
  51. package/core/actions/__tests__/getGeolocation.spec.js +0 -2
  52. package/core/actions/__tests__/grantCameraPermissions.spec.js +0 -1
  53. package/core/actions/__tests__/grantGeolocationPermissions.spec.js +0 -1
  54. package/core/actions/__tests__/grantPermissions.spec.js +0 -9
  55. package/core/actions/__tests__/updateStatusBarBackground.spec.js +0 -1
  56. package/core/classes/__tests__/GeolocationRequest.spec.js +0 -5
  57. package/core/config/__tests__/getPageConfig.spec.js +0 -1
  58. package/core/config/__tests__/getPageSettings.spec.js +0 -2
  59. package/core/config/__tests__/getThemeAssets.spec.js +0 -1
  60. package/core/config/__tests__/getThemeColors.spec.js +0 -1
  61. package/core/config/__tests__/getThemeConfig.spec.js +0 -2
  62. package/core/config/__tests__/getThemeSettings.spec.js +0 -1
  63. package/core/config/__tests__/getThemeStyles.spec.js +0 -1
  64. package/core/config/__tests__/getWidgetConfig.spec.js +0 -1
  65. package/core/config/__tests__/getWidgetSettings.spec.js +0 -3
  66. package/core/helpers/__mocks__/i18n.js +0 -1
  67. package/core/helpers/__tests__/i18n.spec.js +0 -1
  68. package/core/helpers/__tests__/updateLegacyNavigationBar.spec.js +0 -1
  69. package/core/hocs/__mocks__/withWidgetSettings.js +0 -5
  70. package/core/hocs/__tests__/withApp.spec.js +0 -2
  71. package/core/hocs/__tests__/withCurrentProduct.spec.js +0 -2
  72. package/core/hocs/__tests__/withForwardedRef.spec.js +0 -1
  73. package/core/hocs/__tests__/withNavigation.spec.js +0 -2
  74. package/core/hocs/__tests__/withRoute.spec.js +0 -2
  75. package/core/hocs/__tests__/withTheme.spec.js +0 -2
  76. package/core/hocs/__tests__/withWidgetSettings.spec.js +0 -2
  77. package/core/hocs/__tests__/withWidgetStyles.spec.js +0 -2
  78. package/core/hooks/__tests__/useApp.spec.js +0 -1
  79. package/core/hooks/__tests__/useNavigation.spec.js +0 -1
  80. package/core/hooks/__tests__/usePageConfig.spec.js +0 -1
  81. package/core/hooks/__tests__/usePageSettings.spec.js +0 -1
  82. package/core/hooks/__tests__/useTheme.spec.js +0 -1
  83. package/core/hooks/__tests__/useWidgetConfig.spec.js +0 -1
  84. package/core/hooks/__tests__/useWidgetSettings.spec.js +0 -1
  85. package/core/hooks/__tests__/useWidgetStyles.spec.js +0 -1
  86. package/core/index.spec.js +0 -1
  87. package/core/providers/__tests__/AppProvider.spec.js +0 -2
  88. package/core/router/__tests__/helpers.spec.js +0 -1
  89. package/favorites/index.spec.js +0 -1
  90. package/filter/helpers/__tests__/buildUpdatedFilters.spec.js +0 -1
  91. package/filter/index.spec.js +0 -1
  92. package/index.spec.js +0 -1
  93. package/market/index.spec.js +0 -1
  94. package/orders/index.spec.js +0 -1
  95. package/page/index.spec.js +0 -1
  96. package/product/components/Description/__tests__/Description.spec.js +0 -1
  97. package/product/components/Media/helpers.spec.js +0 -3
  98. package/product/components/ProductCharacteristics/helpers/index.spec.js +0 -12
  99. package/product/components/ProductGridPrice/index.spec.js +0 -1
  100. package/product/components/ProductProperties/__tests__/Content.spec.js +0 -1
  101. package/product/components/ProductProperties/__tests__/Group.spec.js +0 -1
  102. package/product/components/ProductProperties/__tests__/GroupedProperties.spec.js +0 -1
  103. package/product/components/ProductProperties/__tests__/Lists.spec.js +0 -1
  104. package/product/components/ProductProperties/__tests__/ProductProperties.spec.js +0 -1
  105. package/product/components/ProductProperties/__tests__/Row.spec.js +0 -1
  106. package/product/components/ProductProperties/__tests__/Rows.spec.js +0 -1
  107. package/product/components/ProductProperties/__tests__/helpers/getGroupsFromProperties.spec.js +0 -1
  108. package/product/components/ProductProperties/__tests__/helpers/getSubgroupsFromProperties.spec.js +0 -1
  109. package/product/components/QuantityPicker/helpers.spec.js +0 -1
  110. package/product/components/__mocks__/context.js +0 -1
  111. package/product/hocs/withMapPricing.spec.js +0 -4
  112. package/product/hocs/withPriceCalculation.spec.js +0 -1
  113. package/product/index.spec.js +0 -1
  114. package/product/selectors/__tests__/media.spec.js +0 -1
  115. package/product/selectors/__tests__/price.spec.js +0 -1
  116. package/product/selectors/__tests__/product.spec.js +0 -2
  117. package/product/selectors/__tests__/relations.spec.js +0 -1
  118. package/product/selectors/__tests__/variants.spec.js +0 -1
  119. package/product/selectors/mocks/productProperties.mock.js +0 -1
  120. package/push-opt-in/subscriptions/optInTrigger.spec.js +0 -41
  121. package/reviews/index.spec.js +0 -1
  122. package/scanner/index.spec.js +0 -1
  123. package/search/index.spec.js +0 -1
  124. package/user/index.spec.js +0 -1
  125. package/user/selectors/__tests__/login.spec.js +0 -1
@@ -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,41 +0,0 @@
1
- function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import _regeneratorRuntime from"@babel/runtime/regenerator";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;}function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}import{combineReducers}from'redux';import merge from'lodash/merge';import{createMockStore}from'@shopgate/pwa-common/store';import{event,getAppPermissions,PERMISSION_ID_PUSH,PERMISSION_STATUS_DENIED,APP_DID_START}from'@shopgate/engage/core';import{increaseAppStartCount,setLastPopupTimestamp,resetAppStartCount,increaseRejectionCount,increaseOrdersPlacedCount,resetOrdersPlacedCount,optInPostponed,showPushOptInModal}from"../action-creators";import pushReducers from"../reducers";import subscriptions from"./optInTrigger";/**
2
- * @typedef {Object} MockedConfigSetting
3
- * @property {number} value
4
- * @property {number|null} repeats
5
- */ /**
6
- * @typedef {Object} MockedConfig
7
- * @property {MockedConfigSetting} appStarts
8
- * @property {MockedConfigSetting} ordersPlaced
9
- * @property {number} rejectionMaxCount
10
- * @property {number} minDaysBetweenOptIns
11
- */var mockedPushOptInConfig;/**
12
- * Updates the mocked pushOptIn config with custom values.
13
- * @param {MockedConfig} update The custom config values
14
- */var setMockedConfig=function setMockedConfig(){var update=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};mockedPushOptInConfig=merge({appStarts:{value:1,repeats:null},ordersPlaced:{value:1,repeats:null},rejectionMaxCount:2,minDaysBetweenOptIns:1},update);};jest.mock("../action-creators/pushOptIn.js",function(){return{showPushOptInModal:jest.fn()};});jest.mock('@shopgate/engage',function(){return{appConfig:{get pushOptIn(){return mockedPushOptInConfig;}}};});jest.mock('@shopgate/engage/core',function(){/* eslint-disable no-shadow */var _jest$requireActual=jest.requireActual('@shopgate/engage/core'),appDidStart$=_jest$requireActual.appDidStart$,main$=_jest$requireActual.main$,PERMISSION_ID_PUSH=_jest$requireActual.PERMISSION_ID_PUSH,PERMISSION_STATUS_NOT_DETERMINED=_jest$requireActual.PERMISSION_STATUS_NOT_DETERMINED,PERMISSION_STATUS_GRANTED=_jest$requireActual.PERMISSION_STATUS_GRANTED,PERMISSION_STATUS_DENIED=_jest$requireActual.PERMISSION_STATUS_DENIED,APP_DID_START=_jest$requireActual.APP_DID_START;/* eslint-enable no-shadow */return{main$:main$,appDidStart$:appDidStart$,PERMISSION_ID_PUSH:PERMISSION_ID_PUSH,PERMISSION_STATUS_NOT_DETERMINED:PERMISSION_STATUS_NOT_DETERMINED,PERMISSION_STATUS_GRANTED:PERMISSION_STATUS_GRANTED,PERMISSION_STATUS_DENIED:PERMISSION_STATUS_DENIED,APP_DID_START:APP_DID_START,getAppPermissions:jest.fn().mockResolvedValue([{status:PERMISSION_STATUS_NOT_DETERMINED}]),event:{addCallback:jest.fn()}};});describe('Push OptIn Subscriptions',function(){var subscribe=jest.fn();var dispatch;var getState;var callbackParams;var mockedTS=new Date('2024-01-31T12:00:00.000Z').getTime();var dateMock;beforeEach(function(){setMockedConfig();jest.clearAllMocks();var store=createMockStore(combineReducers({pushOptIn:pushReducers}),subscriptions);jest.spyOn(store,'dispatch');jest.spyOn(store,'getState');dateMock=jest.spyOn(Date,'now').mockImplementation(function(){return mockedTS;});dispatch=store.dispatch;getState=store.getState;callbackParams={dispatch:dispatch,getState:getState};subscriptions(subscribe);// By default dispatching the showPushOptInModal action results
15
- // into dispatching the optInPostponed action
16
- showPushOptInModal.mockImplementation(function(){return function(thunkDispatch){thunkDispatch(optInPostponed());};});});/**
17
- * Since subscriptions for handling appStarts and ordersPlaced settings share the same logic and
18
- * just operate on different properties of the related app config, both test blocks are equal
19
- * can can be executed in a loop.
20
- */describe.each(['appStarts','ordersPlaced'])('Counter tests',function(configType){describe("Logic for ".concat(configType),function(){var callback;var eventName;var increaseCountAction;var resetCountAction;beforeEach(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(){var _subscribe$mock$calls,_subscribe$mock$calls2,_subscribe$mock$calls3,_subscribe$mock$calls4,subscribeCallback,_event$addCallback$mo,_event$addCallback$mo2;return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:if(!(configType==='appStarts')){_context.next=8;break;}// Pick the callback of the subscriptions for handling of the appStarts setting
21
- _subscribe$mock$calls=_slicedToArray(subscribe.mock.calls,1);_subscribe$mock$calls2=_slicedToArray(_subscribe$mock$calls[0],2);callback=_subscribe$mock$calls2[1];increaseCountAction=increaseAppStartCount;resetCountAction=resetAppStartCount;_context.next=18;break;case 8:if(!(configType==='ordersPlaced')){_context.next=18;break;}// Pick the callback of the subscriptions for handling of the ordersPlaced setting
22
- _subscribe$mock$calls3=_slicedToArray(subscribe.mock.calls,2),_subscribe$mock$calls4=_slicedToArray(_subscribe$mock$calls3[1],2),subscribeCallback=_subscribe$mock$calls4[1];// Invoke the callback, so that an event handler for "checkoutSuccess" is registered
23
- _context.next=12;return subscribeCallback(callbackParams);case 12:_event$addCallback$mo=_slicedToArray(event.addCallback.mock.calls,1);_event$addCallback$mo2=_slicedToArray(_event$addCallback$mo[0],2);eventName=_event$addCallback$mo2[0];callback=_event$addCallback$mo2[1];increaseCountAction=increaseOrdersPlacedCount;resetCountAction=resetOrdersPlacedCount;case 18:case"end":return _context.stop();}}},_callee);})));if(configType==='ordersPlaced'){it('should register for the expected event',function(){expect(eventName).toBe('checkoutSuccess');});}it('should not trigger opt-in when push permission has not status "notDetermined" anymore',/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(){return _regeneratorRuntime.wrap(function _callee2$(_context2){while(1){switch(_context2.prev=_context2.next){case 0:setMockedConfig(_defineProperty({},configType,{value:1}));getAppPermissions.mockResolvedValueOnce([{status:PERMISSION_STATUS_DENIED}]);_context2.next=4;return callback(callbackParams);case 4:expect(getAppPermissions).toHaveBeenCalled();expect(getAppPermissions).toHaveBeenCalledWith([PERMISSION_ID_PUSH]);expect(dispatch).not.toHaveBeenCalled();case 7:case"end":return _context2.stop();}}},_callee2);})));it('should not trigger opt-in when config key is set to 0',/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(){return _regeneratorRuntime.wrap(function _callee3$(_context3){while(1){switch(_context3.prev=_context3.next){case 0:setMockedConfig(_defineProperty({},configType,{value:0}));_context3.next=3;return callback(callbackParams);case 3:expect(getAppPermissions).toHaveBeenCalled();expect(getAppPermissions).toHaveBeenCalledWith([PERMISSION_ID_PUSH]);expect(dispatch).toHaveBeenCalledTimes(1);expect(dispatch).toHaveBeenCalledWith(increaseCountAction());expect(showPushOptInModal).not.toHaveBeenCalled();case 8:case"end":return _context3.stop();}}},_callee3);})));it('should trigger opt-in at the first counter increase',/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(){return _regeneratorRuntime.wrap(function _callee4$(_context4){while(1){switch(_context4.prev=_context4.next){case 0:setMockedConfig(_defineProperty({},configType,{value:1}));_context4.next=3;return callback(callbackParams);case 3:expect(getAppPermissions).toHaveBeenCalled();expect(getAppPermissions).toHaveBeenCalledWith([PERMISSION_ID_PUSH]);expect(dispatch).toHaveBeenCalledTimes(4);expect(dispatch).toHaveBeenCalledWith(increaseCountAction());expect(dispatch).toHaveBeenCalledWith(setLastPopupTimestamp());expect(dispatch).toHaveBeenCalledWith(resetCountAction());expect(showPushOptInModal).toHaveBeenCalledTimes(1);case 10:case"end":return _context4.stop();}}},_callee4);})));it('should trigger opt-in at the 3rd counter increase',/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(){return _regeneratorRuntime.wrap(function _callee5$(_context5){while(1){switch(_context5.prev=_context5.next){case 0:setMockedConfig(_defineProperty({},configType,{value:3}));// 1st counter increase -> do not show opt-in
24
- _context5.next=3;return callback(callbackParams);case 3:expect(dispatch).toHaveBeenCalledTimes(1);expect(showPushOptInModal).not.toHaveBeenCalled();// 2nd counter increase -> do not show opt-in
25
- _context5.next=7;return callback(callbackParams);case 7:expect(dispatch).toHaveBeenCalledTimes(2);expect(showPushOptInModal).not.toHaveBeenCalled();// 3rd counter increase -> show opt-in
26
- _context5.next=11;return callback(callbackParams);case 11:expect(dispatch).toHaveBeenCalledTimes(6);expect(showPushOptInModal).toHaveBeenCalledTimes(1);case 13:case"end":return _context5.stop();}}},_callee5);})));it('should not trigger opt-in again till "minDaysBetweenOptIns" elapsed',/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(){var _setMockedConfig5;return _regeneratorRuntime.wrap(function _callee6$(_context6){while(1){switch(_context6.prev=_context6.next){case 0:setMockedConfig((_setMockedConfig5={},_defineProperty(_setMockedConfig5,configType,{value:1}),_defineProperty(_setMockedConfig5,"minDaysBetweenOptIns",1),_setMockedConfig5));// 1st counter increase -> show opt-in
27
- _context6.next=3;return callback(callbackParams);case 3:expect(showPushOptInModal).toHaveBeenCalledTimes(1);// fast forward time by 1/2 day
28
- dateMock.mockImplementation(function(){return mockedTS+1000*60*60*12;});// 2nd counter increase -> do not show opt due to min days setting
29
- _context6.next=7;return callback(callbackParams);case 7:expect(showPushOptInModal).toHaveBeenCalledTimes(1);// 3rd counter increase -> do not show opt due to min days setting
30
- _context6.next=10;return callback(callbackParams);case 10:expect(showPushOptInModal).toHaveBeenCalledTimes(1);// fast forward time by 1 day
31
- dateMock.mockImplementation(function(){return mockedTS+1000*60*60*24;});// 4th counter increase -> show opt-in again
32
- _context6.next=14;return callback(callbackParams);case 14:expect(showPushOptInModal).toHaveBeenCalledTimes(2);case 15:case"end":return _context6.stop();}}},_callee6);})));it('should not trigger opt-in when max rejection count is reached',/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7(){var _setMockedConfig6;return _regeneratorRuntime.wrap(function _callee7$(_context7){while(1){switch(_context7.prev=_context7.next){case 0:setMockedConfig((_setMockedConfig6={},_defineProperty(_setMockedConfig6,configType,{value:1}),_defineProperty(_setMockedConfig6,"minDaysBetweenOptIns",0),_defineProperty(_setMockedConfig6,"rejectionMaxCount",2),_setMockedConfig6));// 1st counter increase -> show opt-in
33
- _context7.next=3;return callback(callbackParams);case 3:expect(showPushOptInModal).toHaveBeenCalledTimes(1);// 2nd counter increase -> show opt-in
34
- _context7.next=6;return callback(callbackParams);case 6:expect(showPushOptInModal).toHaveBeenCalledTimes(2);// 3rd counter increase -> no opt-in due to rejection count
35
- _context7.next=9;return callback(callbackParams);case 9:expect(showPushOptInModal).toHaveBeenCalledTimes(2);case 10:case"end":return _context7.stop();}}},_callee7);})));it('should not trigger opt-in when max repeats are reached',/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8(){var _setMockedConfig7;return _regeneratorRuntime.wrap(function _callee8$(_context8){while(1){switch(_context8.prev=_context8.next){case 0:setMockedConfig((_setMockedConfig7={},_defineProperty(_setMockedConfig7,configType,{value:2,repeats:2}),_defineProperty(_setMockedConfig7,"minDaysBetweenOptIns",0),_defineProperty(_setMockedConfig7,"rejectionMaxCount",4),_setMockedConfig7));_context8.next=3;return callback(callbackParams);case 3:_context8.next=5;return callback(callbackParams);case 5:expect(showPushOptInModal).toHaveBeenCalledTimes(1);_context8.next=8;return callback(callbackParams);case 8:_context8.next=10;return callback(callbackParams);case 10:expect(showPushOptInModal).toHaveBeenCalledTimes(2);_context8.next=13;return callback(callbackParams);case 13:_context8.next=15;return callback(callbackParams);case 15:expect(showPushOptInModal).toHaveBeenCalledTimes(3);_context8.next=18;return callback(callbackParams);case 18:_context8.next=20;return callback(callbackParams);case 20:expect(showPushOptInModal).toHaveBeenCalledTimes(3);case 21:case"end":return _context8.stop();}}},_callee8);})));});});describe('Combined counter tests',function(){var appStartsSubscriberCallback;var ordersPlacedSubscriberCallback;beforeEach(function(){var _subscribe$mock$calls5=_slicedToArray(subscribe.mock.calls,2);var _subscribe$mock$calls6=_slicedToArray(_subscribe$mock$calls5[0],2);appStartsSubscriberCallback=_subscribe$mock$calls6[1];var _subscribe$mock$calls7=_slicedToArray(_subscribe$mock$calls5[1],2);ordersPlacedSubscriberCallback=_subscribe$mock$calls7[1];});it('should trigger opt-in for ordersPlaced when max views for appStarts already exceeded',/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee9(){var _event$addCallback$mo3,_event$addCallback$mo4,checkoutSuccessCallback;return _regeneratorRuntime.wrap(function _callee9$(_context9){while(1){switch(_context9.prev=_context9.next){case 0:setMockedConfig({appStarts:{value:1,repeats:2},ordersPlaced:{value:1,repeats:1},minDaysBetweenOptIns:0,rejectionMaxCount:4});// 3 opt-ins can be triggered before opt-in by appStart is exceeded (initial + 2 repeats)
36
- _context9.next=3;return appStartsSubscriberCallback(callbackParams);case 3:expect(showPushOptInModal).toHaveBeenCalledTimes(1);_context9.next=6;return appStartsSubscriberCallback(callbackParams);case 6:expect(showPushOptInModal).toHaveBeenCalledTimes(2);_context9.next=9;return appStartsSubscriberCallback(callbackParams);case 9:expect(showPushOptInModal).toHaveBeenCalledTimes(3);// Opt-in does't show anymore for 4th app start since repeats exceeded
37
- _context9.next=12;return appStartsSubscriberCallback(callbackParams);case 12:expect(showPushOptInModal).toHaveBeenCalledTimes(3);ordersPlacedSubscriberCallback(callbackParams);_event$addCallback$mo3=_slicedToArray(event.addCallback.mock.calls,1),_event$addCallback$mo4=_slicedToArray(_event$addCallback$mo3[0],2),checkoutSuccessCallback=_event$addCallback$mo4[1];// Opt-in shows again since max rejection count is not reached yet
38
- _context9.next=17;return checkoutSuccessCallback();case 17:expect(showPushOptInModal).toHaveBeenCalledTimes(4);// Opt-in doesn't show anymore for the 2nd order placement, since max rejection count exceeded
39
- _context9.next=20;return checkoutSuccessCallback();case 20:expect(showPushOptInModal).toHaveBeenCalledTimes(4);case 21:case"end":return _context9.stop();}}},_callee9);})));});describe('appDidStart$',function(){it('should run expected logic when appDidStart$ stream emits',function(){setMockedConfig({appStarts:{value:1,repeats:1},ordersPlaced:{value:1,repeats:1},minDaysBetweenOptIns:0});dispatch({type:APP_DID_START});// getAppPermissions should have been called 1st time for appDidStart
40
- expect(getAppPermissions).toHaveBeenCalledTimes(1);var _event$addCallback$mo5=_slicedToArray(event.addCallback.mock.calls,1),_event$addCallback$mo6=_slicedToArray(_event$addCallback$mo5[0],2),eventName=_event$addCallback$mo6[0],eventCallback=_event$addCallback$mo6[1];expect(eventName).toBe('checkoutSuccess');eventCallback();// getAppPermissions should have been called 2nd time for checkoutSuccess event
41
- expect(getAppPermissions).toHaveBeenCalledTimes(2);});});describe('increaseRejectionCount$',function(){var callback;beforeEach(function(){var _subscribe$mock$calls8=_slicedToArray(subscribe.mock.calls,3);var _subscribe$mock$calls9=_slicedToArray(_subscribe$mock$calls8[2],2);callback=_subscribe$mock$calls9[1];});it('should dispatch the increaseRejectionCount action when subscription emits',function(){callback(callbackParams);expect(dispatch).toHaveBeenCalledTimes(1);expect(dispatch).toHaveBeenCalledWith(increaseRejectionCount());});});});
@@ -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);});});});