@shopgate/engage 6.22.0-beta.1 → 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 (165) 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/components/BackInStockButton/index.js +2 -2
  10. package/back-in-stock/components/BackInStockButton/style.js +1 -1
  11. package/back-in-stock/components/CharacteristicsButton/index.js +1 -1
  12. package/back-in-stock/components/ProductInfoBackInStockButton/connector.js +1 -1
  13. package/back-in-stock/components/Subscriptions/components/List/index.js +2 -2
  14. package/back-in-stock/components/Subscriptions/components/Subscription/index.js +3 -3
  15. package/back-in-stock/providers/BackInStockSubscriptionsProvider.connector.js +2 -2
  16. package/back-in-stock/providers/BackInStockSubscriptionsProvider.js +2 -2
  17. package/back-in-stock/reducers/index.js +2 -2
  18. package/back-in-stock/selectors/index.js +32 -14
  19. package/back-in-stock/subscriptions/index.js +10 -2
  20. package/core/action-creators/appPermissions.js +9 -0
  21. package/core/action-creators/index.js +1 -0
  22. package/core/actions/getGeolocation.js +1 -1
  23. package/core/actions/grantCameraPermissions.js +1 -1
  24. package/core/actions/grantGeolocationPermissions.js +1 -1
  25. package/core/actions/grantPermissions.js +4 -4
  26. package/core/actions/grantPushPermissions.js +2 -2
  27. package/core/actions/index.js +1 -0
  28. package/core/actions/requestAppPermission.js +7 -0
  29. package/core/actions/requestAppPermissionStatus.js +7 -0
  30. package/core/collections/AppInitialization.js +49 -0
  31. package/core/collections/index.js +1 -0
  32. package/core/constants/actionTypes.js +1 -0
  33. package/core/constants/appFeatures.js +1 -0
  34. package/core/constants/index.js +6 -0
  35. package/core/helpers/appFeatures.js +7 -0
  36. package/core/helpers/index.js +1 -0
  37. package/core/index.js +8 -12
  38. package/core/initialization/index.js +7 -0
  39. package/core/streams/appPermissions.js +19 -0
  40. package/core/streams/index.js +1 -0
  41. package/package.json +7 -7
  42. package/product/components/Characteristics/Characteristic/components/SheetItem/index.js +3 -3
  43. package/product/components/Characteristics/Characteristic/components/SheetItem/style.js +1 -1
  44. package/push-opt-in/action-creators/index.js +1 -0
  45. package/push-opt-in/action-creators/optInTrigger.js +23 -0
  46. package/push-opt-in/action-creators/pushOptIn.js +7 -0
  47. package/push-opt-in/actions/index.js +1 -0
  48. package/push-opt-in/actions/pushOptInModal.js +8 -0
  49. package/push-opt-in/components/PushOptInModal/connector.js +9 -0
  50. package/push-opt-in/components/PushOptInModal/index.js +10 -0
  51. package/push-opt-in/components/PushOptInModal/push-opt-in.svg +62 -0
  52. package/push-opt-in/components/PushOptInModal/style.js +1 -0
  53. package/push-opt-in/components/index.js +1 -0
  54. package/push-opt-in/constants/index.js +1 -0
  55. package/push-opt-in/constants/optInModal.js +1 -0
  56. package/push-opt-in/constants/optInTrigger.js +1 -0
  57. package/push-opt-in/reducers/index.js +1 -0
  58. package/push-opt-in/reducers/optInModal.js +6 -0
  59. package/push-opt-in/reducers/optInTrigger.js +6 -0
  60. package/push-opt-in/selectors/index.js +1 -0
  61. package/push-opt-in/selectors/optInModal.js +8 -0
  62. package/push-opt-in/selectors/optInTrigger.js +5 -0
  63. package/push-opt-in/subscriptions/index.js +1 -0
  64. package/push-opt-in/subscriptions/optInTrigger.js +12 -0
  65. package/a11y/components/LiveMessage/__tests__/index.spec.js +0 -1
  66. package/a11y/components/LiveMessenger/__tests__/helpers.spec.js +0 -1
  67. package/a11y/components/LiveMessenger/__tests__/index.spec.js +0 -1
  68. package/a11y/components/Navigation/__tests__/index.spec.js +0 -1
  69. package/a11y/components/Section/__tests__/index.spec.js +0 -1
  70. package/a11y/index.spec.js +0 -1
  71. package/back-in-stock/components/Subscriptions/components/Subscription/connector.js +0 -3
  72. package/cart/index.spec.js +0 -1
  73. package/category/index.spec.js +0 -1
  74. package/checkout/index.spec.js +0 -1
  75. package/components/Footer/__tests__/Footer.spec.js +0 -8
  76. package/components/Form/Builder/Builder.spec.js +0 -19
  77. package/components/Form/Builder/classes/ActionListener.spec.js +0 -21
  78. package/components/Form/Builder/helpers/buildCountryList.spec.js +0 -1
  79. package/components/Form/Builder/helpers/buildFormDefaults.spec.js +0 -1
  80. package/components/Form/Builder/helpers/buildFormElements.spec.js +0 -3
  81. package/components/Form/Builder/helpers/buildProvinceList.spec.js +0 -1
  82. package/components/IntersectionVisibility/__tests__/index.js +0 -1
  83. package/components/View/__mocks__/context.js +0 -1
  84. package/components/View/__mocks__/index.js +0 -5
  85. package/components/View/__tests__/index.spec.js +0 -1
  86. package/components/View/__tests__/provider.spec.js +0 -1
  87. package/components/View/components/Above/__tests__/index.spec.js +0 -1
  88. package/components/View/components/Below/__tests__/index.spec.js +0 -1
  89. package/components/View/components/Content/__tests__/index.spec.js +0 -2
  90. package/components/__mocks__/index.js +0 -4
  91. package/components/index.spec.js +0 -1
  92. package/core/actions/__tests__/getGeolocation.spec.js +0 -2
  93. package/core/actions/__tests__/grantCameraPermissions.spec.js +0 -1
  94. package/core/actions/__tests__/grantGeolocationPermissions.spec.js +0 -1
  95. package/core/actions/__tests__/grantPermissions.spec.js +0 -9
  96. package/core/actions/__tests__/updateStatusBarBackground.spec.js +0 -1
  97. package/core/classes/__tests__/GeolocationRequest.spec.js +0 -5
  98. package/core/config/__tests__/getPageConfig.spec.js +0 -1
  99. package/core/config/__tests__/getPageSettings.spec.js +0 -2
  100. package/core/config/__tests__/getThemeAssets.spec.js +0 -1
  101. package/core/config/__tests__/getThemeColors.spec.js +0 -1
  102. package/core/config/__tests__/getThemeConfig.spec.js +0 -2
  103. package/core/config/__tests__/getThemeSettings.spec.js +0 -1
  104. package/core/config/__tests__/getThemeStyles.spec.js +0 -1
  105. package/core/config/__tests__/getWidgetConfig.spec.js +0 -1
  106. package/core/config/__tests__/getWidgetSettings.spec.js +0 -3
  107. package/core/helpers/__mocks__/i18n.js +0 -1
  108. package/core/helpers/__tests__/i18n.spec.js +0 -1
  109. package/core/helpers/__tests__/updateLegacyNavigationBar.spec.js +0 -1
  110. package/core/hocs/__mocks__/withWidgetSettings.js +0 -5
  111. package/core/hocs/__tests__/withApp.spec.js +0 -2
  112. package/core/hocs/__tests__/withCurrentProduct.spec.js +0 -2
  113. package/core/hocs/__tests__/withForwardedRef.spec.js +0 -1
  114. package/core/hocs/__tests__/withNavigation.spec.js +0 -2
  115. package/core/hocs/__tests__/withRoute.spec.js +0 -2
  116. package/core/hocs/__tests__/withTheme.spec.js +0 -2
  117. package/core/hocs/__tests__/withWidgetSettings.spec.js +0 -2
  118. package/core/hocs/__tests__/withWidgetStyles.spec.js +0 -2
  119. package/core/hooks/__tests__/useApp.spec.js +0 -1
  120. package/core/hooks/__tests__/useNavigation.spec.js +0 -1
  121. package/core/hooks/__tests__/usePageConfig.spec.js +0 -1
  122. package/core/hooks/__tests__/usePageSettings.spec.js +0 -1
  123. package/core/hooks/__tests__/useTheme.spec.js +0 -1
  124. package/core/hooks/__tests__/useWidgetConfig.spec.js +0 -1
  125. package/core/hooks/__tests__/useWidgetSettings.spec.js +0 -1
  126. package/core/hooks/__tests__/useWidgetStyles.spec.js +0 -1
  127. package/core/index.spec.js +0 -1
  128. package/core/providers/__tests__/AppProvider.spec.js +0 -2
  129. package/core/router/__tests__/helpers.spec.js +0 -1
  130. package/favorites/index.spec.js +0 -1
  131. package/filter/helpers/__tests__/buildUpdatedFilters.spec.js +0 -1
  132. package/filter/index.spec.js +0 -1
  133. package/index.spec.js +0 -1
  134. package/market/index.spec.js +0 -1
  135. package/orders/index.spec.js +0 -1
  136. package/page/index.spec.js +0 -1
  137. package/product/components/Description/__tests__/Description.spec.js +0 -1
  138. package/product/components/Media/helpers.spec.js +0 -3
  139. package/product/components/ProductCharacteristics/helpers/index.spec.js +0 -12
  140. package/product/components/ProductGridPrice/index.spec.js +0 -1
  141. package/product/components/ProductProperties/__tests__/Content.spec.js +0 -1
  142. package/product/components/ProductProperties/__tests__/Group.spec.js +0 -1
  143. package/product/components/ProductProperties/__tests__/GroupedProperties.spec.js +0 -1
  144. package/product/components/ProductProperties/__tests__/Lists.spec.js +0 -1
  145. package/product/components/ProductProperties/__tests__/ProductProperties.spec.js +0 -1
  146. package/product/components/ProductProperties/__tests__/Row.spec.js +0 -1
  147. package/product/components/ProductProperties/__tests__/Rows.spec.js +0 -1
  148. package/product/components/ProductProperties/__tests__/helpers/getGroupsFromProperties.spec.js +0 -1
  149. package/product/components/ProductProperties/__tests__/helpers/getSubgroupsFromProperties.spec.js +0 -1
  150. package/product/components/QuantityPicker/helpers.spec.js +0 -1
  151. package/product/components/__mocks__/context.js +0 -1
  152. package/product/hocs/withMapPricing.spec.js +0 -4
  153. package/product/hocs/withPriceCalculation.spec.js +0 -1
  154. package/product/index.spec.js +0 -1
  155. package/product/selectors/__tests__/media.spec.js +0 -1
  156. package/product/selectors/__tests__/price.spec.js +0 -1
  157. package/product/selectors/__tests__/product.spec.js +0 -2
  158. package/product/selectors/__tests__/relations.spec.js +0 -1
  159. package/product/selectors/__tests__/variants.spec.js +0 -1
  160. package/product/selectors/mocks/productProperties.mock.js +0 -1
  161. package/reviews/index.spec.js +0 -1
  162. package/scanner/index.spec.js +0 -1
  163. package/search/index.spec.js +0 -1
  164. package/user/index.spec.js +0 -1
  165. package/user/selectors/__tests__/login.spec.js +0 -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 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);});});});