@blaze-cms/react-page-builder 0.129.0 → 0.130.0-structured-data.0

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 (67) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/lib/components/Card/CardsContainer.js +15 -10
  3. package/lib/components/Card/CardsContainer.js.map +1 -1
  4. package/lib/components/CarouselWrapper/CarouselWrapper.js +29 -0
  5. package/lib/components/CarouselWrapper/CarouselWrapper.js.map +1 -0
  6. package/lib/components/{CarouselWrapper.js → CarouselWrapper/DefaultCarousel.js} +8 -11
  7. package/lib/components/CarouselWrapper/DefaultCarousel.js.map +1 -0
  8. package/lib/components/CarouselWrapper/SmoothScrollCarousel.js +51 -0
  9. package/lib/components/CarouselWrapper/SmoothScrollCarousel.js.map +1 -0
  10. package/lib/components/CarouselWrapper/index.js +12 -0
  11. package/lib/components/CarouselWrapper/index.js.map +1 -0
  12. package/lib/components/List/ListBuilder.js +1 -7
  13. package/lib/components/List/ListBuilder.js.map +1 -1
  14. package/lib/components/List/ListFactory.js +4 -2
  15. package/lib/components/List/ListFactory.js.map +1 -1
  16. package/lib/components/List/components/Cards/CardsRender.js.map +1 -1
  17. package/lib/components/List/helpers/get-list-component.js +17 -0
  18. package/lib/components/List/helpers/get-list-component.js.map +1 -0
  19. package/lib/components/List/helpers/index.js +7 -0
  20. package/lib/components/List/helpers/index.js.map +1 -1
  21. package/lib/components/SearchContent/SearchContentItems.js +1 -1
  22. package/lib/components/SearchContent/SearchContentItems.js.map +1 -1
  23. package/lib/helpers/get-entities-with-banner.js +26 -1
  24. package/lib/helpers/get-entities-with-banner.js.map +1 -1
  25. package/lib-es/components/Card/CardsContainer.js +15 -10
  26. package/lib-es/components/Card/CardsContainer.js.map +1 -1
  27. package/lib-es/components/CarouselWrapper/CarouselWrapper.js +22 -0
  28. package/lib-es/components/CarouselWrapper/CarouselWrapper.js.map +1 -0
  29. package/lib-es/components/{CarouselWrapper.js → CarouselWrapper/DefaultCarousel.js} +8 -11
  30. package/lib-es/components/CarouselWrapper/DefaultCarousel.js.map +1 -0
  31. package/lib-es/components/CarouselWrapper/SmoothScrollCarousel.js +43 -0
  32. package/lib-es/components/CarouselWrapper/SmoothScrollCarousel.js.map +1 -0
  33. package/lib-es/components/CarouselWrapper/index.js +3 -0
  34. package/lib-es/components/CarouselWrapper/index.js.map +1 -0
  35. package/lib-es/components/List/ListBuilder.js +2 -8
  36. package/lib-es/components/List/ListBuilder.js.map +1 -1
  37. package/lib-es/components/List/ListFactory.js +2 -2
  38. package/lib-es/components/List/ListFactory.js.map +1 -1
  39. package/lib-es/components/List/components/Cards/CardsRender.js.map +1 -1
  40. package/lib-es/components/List/helpers/get-list-component.js +9 -0
  41. package/lib-es/components/List/helpers/get-list-component.js.map +1 -0
  42. package/lib-es/components/List/helpers/index.js +1 -0
  43. package/lib-es/components/List/helpers/index.js.map +1 -1
  44. package/lib-es/components/SearchContent/SearchContentItems.js +1 -1
  45. package/lib-es/components/SearchContent/SearchContentItems.js.map +1 -1
  46. package/lib-es/helpers/get-entities-with-banner.js +18 -1
  47. package/lib-es/helpers/get-entities-with-banner.js.map +1 -1
  48. package/package.json +4 -4
  49. package/src/components/Card/CardsContainer.js +17 -8
  50. package/src/components/CarouselWrapper/CarouselWrapper.js +19 -0
  51. package/src/components/{CarouselWrapper.js → CarouselWrapper/DefaultCarousel.js} +9 -10
  52. package/src/components/CarouselWrapper/SmoothScrollCarousel.js +44 -0
  53. package/src/components/CarouselWrapper/index.js +3 -0
  54. package/src/components/List/ListBuilder.js +2 -15
  55. package/src/components/List/ListFactory.js +2 -2
  56. package/src/components/List/components/Cards/CardsRender.js +0 -1
  57. package/src/components/List/helpers/get-list-component.js +15 -0
  58. package/src/components/List/helpers/index.js +1 -0
  59. package/src/helpers/get-entities-with-banner.js +7 -2
  60. package/tests/unit/src/components/Card/__snapshots__/CardContainer.test.js.snap +1 -0
  61. package/tests/unit/src/components/CarouselWrapper.test.js +9 -0
  62. package/tests/unit/src/components/List/helpers/get-list-component.test.js +21 -0
  63. package/tests/unit/src/components/__snapshots__/CarouselWrapper.test.js.snap +53 -0
  64. package/lib/components/CarouselWrapper.js.map +0 -1
  65. package/lib-es/components/CarouselWrapper.js.map +0 -1
  66. package/tests/unit/src/components/List/components/Cards/CardRenderWithInfiniteScroll.test.js +0 -12
  67. package/tests/unit/src/components/List/components/Full/FullRenderWithInfiniteScroll.test.js +0 -12
@@ -0,0 +1,15 @@
1
+ import {
2
+ CardRenderWithInfiniteScroll,
3
+ CardsRender,
4
+ FullRender,
5
+ FullRenderWithInfiniteScroll
6
+ } from '../components';
7
+ import { CLASSIC } from '../../../constants';
8
+
9
+ function getListComponent(isCard, paginationType) {
10
+ const isNotClassic = paginationType !== CLASSIC;
11
+ if (isCard) return isNotClassic ? CardRenderWithInfiniteScroll : CardsRender;
12
+ return isNotClassic ? FullRenderWithInfiniteScroll : FullRender;
13
+ }
14
+
15
+ export default getListComponent;
@@ -6,3 +6,4 @@ export { default as sortAggs } from './sort-aggs';
6
6
  export { default as getItemsPerPageToUse } from './get-items-per-page-to-use';
7
7
  export { default as getSortProps } from './get-sort-props';
8
8
  export { default as hasRequiredItemListDetails } from './has-required-item-list-details';
9
+ export { default as getListComponent } from './get-list-component';
@@ -1,8 +1,13 @@
1
1
  import injectBannersToEntities from './inject-banners-to-entities';
2
2
 
3
- export default function getEntitiesWithBanner(entities, options) {
3
+ export default function getEntitiesWithBanner(entities, options, hasNewBannerSettings) {
4
4
  const { hasBanner } = options;
5
-
5
+ if (hasNewBannerSettings) {
6
+ return entities.map(currentEntity => {
7
+ const { parent, transform, limit } = options;
8
+ return { ...currentEntity, parent, limit, transform };
9
+ });
10
+ }
6
11
  if (!hasBanner) return entities;
7
12
 
8
13
  return injectBannersToEntities(entities, options);
@@ -100,6 +100,7 @@ exports[`CardsContainer component should render without throwing error and match
100
100
  bannermodifier=""
101
101
  class="grid grid-cols-1 "
102
102
  itemsperrow="1"
103
+ numberofcards="2"
103
104
  >
104
105
  <div
105
106
  class="card card--portrait"
@@ -42,4 +42,13 @@ describe('CarouselWrapper component', () => {
42
42
  });
43
43
  expect(asFragment()).toMatchSnapshot();
44
44
  });
45
+
46
+ it('should add smooth-scroll class if prop is true', () => {
47
+ const { asFragment } = render(CarouselWrapper, {
48
+ ...mockedProps,
49
+ enableSmoothScroll: true,
50
+ itemsPerRow: 3
51
+ });
52
+ expect(asFragment()).toMatchSnapshot();
53
+ });
45
54
  });
@@ -0,0 +1,21 @@
1
+ import getListComponent from '../../../../../../src/components/List/helpers/get-list-component';
2
+ import {
3
+ CardRenderWithInfiniteScroll,
4
+ CardsRender,
5
+ FullRender,
6
+ FullRenderWithInfiniteScroll
7
+ } from '../../../../../../src/components/List/components';
8
+ import { CLASSIC } from '../../../../../../src/constants';
9
+
10
+ describe('getListComponent helper function', () => {
11
+ it('should correct listComponent based on props', () => {
12
+ const fullAz = getListComponent(false, 'aZ');
13
+ const cardAz = getListComponent(true, 'aZ');
14
+ const cardClassic = getListComponent(true, CLASSIC);
15
+ const fullClassic = getListComponent(false, CLASSIC);
16
+ expect(fullAz).toEqual(FullRenderWithInfiniteScroll);
17
+ expect(cardAz).toEqual(CardRenderWithInfiniteScroll);
18
+ expect(cardClassic).toEqual(CardsRender);
19
+ expect(fullClassic).toEqual(FullRender);
20
+ });
21
+ });
@@ -72,6 +72,59 @@ exports[`CarouselWrapper component should add modifier bassed on itemsPerRow 1`]
72
72
  </DocumentFragment>
73
73
  `;
74
74
 
75
+ exports[`CarouselWrapper component should add smooth-scroll class if prop is true 1`] = `
76
+ <DocumentFragment>
77
+ <div
78
+ class="cards-carousel-smooth"
79
+ >
80
+ <div
81
+ class="cards-carousel--content smooth-scroll items-per-row-3"
82
+ style="animation-duration: 1s;"
83
+ >
84
+ <div>
85
+ <div>
86
+ card 1
87
+ </div>
88
+ <div>
89
+ card 2
90
+ </div>
91
+ <div>
92
+ card 3
93
+ </div>
94
+ <div>
95
+ card 4
96
+ </div>
97
+ <div>
98
+ card 5
99
+ </div>
100
+ </div>
101
+ </div>
102
+ <div
103
+ class="cards-carousel--content smooth-scroll items-per-row-3"
104
+ style="animation-duration: 1s;"
105
+ >
106
+ <div>
107
+ <div>
108
+ card 1
109
+ </div>
110
+ <div>
111
+ card 2
112
+ </div>
113
+ <div>
114
+ card 3
115
+ </div>
116
+ <div>
117
+ card 4
118
+ </div>
119
+ <div>
120
+ card 5
121
+ </div>
122
+ </div>
123
+ </div>
124
+ </div>
125
+ </DocumentFragment>
126
+ `;
127
+
75
128
  exports[`CarouselWrapper component should render without throwing an error and match snapshot 1`] = `
76
129
  <DocumentFragment>
77
130
  <div
@@ -1 +0,0 @@
1
- {"version":3,"file":"CarouselWrapper.js","names":["_react","_interopRequireWildcard","require","_propTypes","_interopRequireDefault","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","_typeof","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","CarouselWrapper","_ref","children","bannerModifier","itemsPerRow","enableAutoScroll","autoScrollTimer","arrowSize","ref","useRef","_useState","useState","displayLeft","displayRight","_useState2","_slicedToArray2","buttonDisplay","setButtonDisplays","_useState3","_useState4","shouldAutoScroll","setShouldAutoScroll","autoScrollRef","useEffect","current","id","setInterval","scrollCheck","clearInterval","handleButtonNavigation","_ref$current","offsetWidth","scrollWidth","handleScroll","_ref$current2","scrollLeft","updatedDisplayLeft","updatedDisplayRight","direction","_ref$current3","wrapperClassName","concat","contentClassName","createElement","className","type","onClick","onScroll","propTypes","PropTypes","string","number","oneOfType","arrayOf","node","bool","defaultProps","_default","exports"],"sources":["../../src/components/CarouselWrapper.js"],"sourcesContent":["import React, { useRef, useState, useEffect } from 'react';\nimport PropTypes from 'prop-types';\n\nconst CarouselWrapper = ({\n children,\n bannerModifier,\n itemsPerRow,\n enableAutoScroll,\n autoScrollTimer,\n arrowSize\n}) => {\n const ref = useRef();\n const [buttonDisplay, setButtonDisplays] = useState({ displayLeft: false, displayRight: true });\n const [shouldAutoScroll, setShouldAutoScroll] = useState(false);\n const autoScrollRef = useRef();\n\n useEffect(\n () => {\n autoScrollRef.current = shouldAutoScroll;\n const id = setInterval(scrollCheck, autoScrollTimer);\n function scrollCheck() {\n if (!autoScrollRef.current) {\n clearInterval(id);\n } else {\n handleButtonNavigation(true);\n }\n }\n\n return () => clearInterval(id);\n },\n [autoScrollTimer, shouldAutoScroll]\n );\n\n useEffect(\n () => {\n const {\n current: { offsetWidth, scrollWidth }\n } = ref;\n if (scrollWidth <= offsetWidth)\n setButtonDisplays({ displayLeft: false, displayRight: false });\n setShouldAutoScroll(enableAutoScroll);\n },\n [enableAutoScroll]\n );\n\n const handleScroll = () => {\n const {\n current: { offsetWidth, scrollLeft, scrollWidth }\n } = ref;\n const updatedDisplayLeft = !!scrollLeft;\n const updatedDisplayRight = scrollLeft + offsetWidth + 1 < scrollWidth;\n setButtonDisplays({ displayLeft: updatedDisplayLeft, displayRight: updatedDisplayRight });\n };\n\n const handleButtonNavigation = direction => {\n if (!ref || !ref.current) return;\n const {\n current: { offsetWidth, scrollLeft, scrollWidth }\n } = ref;\n\n if (autoScrollRef.current && scrollLeft + offsetWidth >= scrollWidth) {\n ref.current.scrollLeft = 0;\n } else {\n ref.current.scrollLeft = direction ? scrollLeft + offsetWidth : scrollLeft - offsetWidth;\n }\n };\n\n const { displayLeft, displayRight } = buttonDisplay;\n const wrapperClassName = `cards-carousel${bannerModifier}`;\n const contentClassName = `cards-carousel--content items-per-row-${itemsPerRow}`;\n\n return (\n <div className={wrapperClassName}>\n <div className=\"cards-carousel--left-button-wrapper\">\n {displayLeft && (\n <button\n type=\"button\"\n className=\"cards-carousel--button-back icon-button icon\"\n onClick={() => {\n setShouldAutoScroll(false);\n handleButtonNavigation();\n }}>\n <i className=\"cards-carousel--arrow cards-carousel--arrow__left\" />\n </button>\n )}\n </div>\n <div className=\"cards-carousel--right-button-wrapper\">\n {displayRight && (\n <button\n type=\"button\"\n className=\"cards-carousel--button-forward icon-button icon\"\n onClick={() => {\n setShouldAutoScroll(false);\n handleButtonNavigation(true);\n }}>\n <i className=\"cards-carousel--arrow cards-carousel--arrow__right\" />\n </button>\n )}\n </div>\n <div className={contentClassName} ref={ref} onScroll={handleScroll}>\n {children}\n </div>\n </div>\n );\n};\n\nCarouselWrapper.propTypes = {\n bannerModifier: PropTypes.string,\n itemsPerRow: PropTypes.number,\n children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),\n enableAutoScroll: PropTypes.bool,\n autoScrollTimer: PropTypes.number,\n arrowSize: PropTypes.number\n};\n\nCarouselWrapper.defaultProps = {\n itemsPerRow: 0,\n bannerModifier: '',\n children: [],\n enableAutoScroll: false,\n autoScrollTimer: 0,\n arrowSize: 14\n};\n\nexport default CarouselWrapper;\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AAAmC,SAAAG,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,yBAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAL,wBAAAS,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,aAAAE,OAAA,CAAAF,GAAA,yBAAAA,GAAA,uCAAAA,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAAAE,GAAA,CAAAL,GAAA,SAAAM,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IA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ffect","PropTypes","CarouselWrapper","children","bannerModifier","itemsPerRow","enableAutoScroll","autoScrollTimer","arrowSize","ref","buttonDisplay","setButtonDisplays","displayLeft","displayRight","shouldAutoScroll","setShouldAutoScroll","autoScrollRef","current","id","setInterval","scrollCheck","clearInterval","handleButtonNavigation","offsetWidth","scrollWidth","handleScroll","scrollLeft","updatedDisplayLeft","updatedDisplayRight","direction","wrapperClassName","contentClassName","createElement","className","type","onClick","onScroll","propTypes","string","number","oneOfType","arrayOf","node","bool","defaultProps"],"sources":["../../src/components/CarouselWrapper.js"],"sourcesContent":["import React, { useRef, useState, useEffect } from 'react';\nimport PropTypes from 'prop-types';\n\nconst CarouselWrapper = ({\n children,\n bannerModifier,\n itemsPerRow,\n enableAutoScroll,\n autoScrollTimer,\n arrowSize\n}) => {\n const ref = useRef();\n const [buttonDisplay, setButtonDisplays] = useState({ displayLeft: false, displayRight: true });\n const [shouldAutoScroll, setShouldAutoScroll] = useState(false);\n const autoScrollRef = useRef();\n\n useEffect(\n () => {\n autoScrollRef.current = shouldAutoScroll;\n const id = setInterval(scrollCheck, autoScrollTimer);\n function scrollCheck() {\n if (!autoScrollRef.current) {\n clearInterval(id);\n } else {\n handleButtonNavigation(true);\n }\n }\n\n return () => clearInterval(id);\n },\n [autoScrollTimer, shouldAutoScroll]\n );\n\n useEffect(\n () => {\n const {\n current: { offsetWidth, scrollWidth }\n } = ref;\n if (scrollWidth <= offsetWidth)\n setButtonDisplays({ displayLeft: false, displayRight: false });\n setShouldAutoScroll(enableAutoScroll);\n },\n [enableAutoScroll]\n );\n\n const handleScroll = () => {\n const {\n current: { offsetWidth, scrollLeft, scrollWidth }\n } = ref;\n const updatedDisplayLeft = !!scrollLeft;\n const updatedDisplayRight = scrollLeft + offsetWidth + 1 < scrollWidth;\n setButtonDisplays({ displayLeft: updatedDisplayLeft, displayRight: updatedDisplayRight });\n };\n\n const handleButtonNavigation = direction => {\n if (!ref || !ref.current) return;\n const {\n current: { offsetWidth, scrollLeft, scrollWidth }\n } = ref;\n\n if (autoScrollRef.current && scrollLeft + offsetWidth >= scrollWidth) {\n ref.current.scrollLeft = 0;\n } else {\n ref.current.scrollLeft = direction ? scrollLeft + offsetWidth : scrollLeft - offsetWidth;\n }\n };\n\n const { displayLeft, displayRight } = buttonDisplay;\n const wrapperClassName = `cards-carousel${bannerModifier}`;\n const contentClassName = `cards-carousel--content items-per-row-${itemsPerRow}`;\n\n return (\n <div className={wrapperClassName}>\n <div className=\"cards-carousel--left-button-wrapper\">\n {displayLeft && (\n <button\n type=\"button\"\n className=\"cards-carousel--button-back icon-button icon\"\n onClick={() => {\n setShouldAutoScroll(false);\n handleButtonNavigation();\n }}>\n <i className=\"cards-carousel--arrow cards-carousel--arrow__left\" />\n </button>\n )}\n </div>\n <div className=\"cards-carousel--right-button-wrapper\">\n {displayRight && (\n <button\n type=\"button\"\n className=\"cards-carousel--button-forward icon-button icon\"\n onClick={() => {\n setShouldAutoScroll(false);\n handleButtonNavigation(true);\n }}>\n <i className=\"cards-carousel--arrow cards-carousel--arrow__right\" />\n </button>\n )}\n </div>\n <div className={contentClassName} ref={ref} onScroll={handleScroll}>\n {children}\n </div>\n </div>\n );\n};\n\nCarouselWrapper.propTypes = {\n bannerModifier: PropTypes.string,\n itemsPerRow: PropTypes.number,\n children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),\n enableAutoScroll: PropTypes.bool,\n autoScrollTimer: PropTypes.number,\n arrowSize: PropTypes.number\n};\n\nCarouselWrapper.defaultProps = {\n itemsPerRow: 0,\n bannerModifier: '',\n children: [],\n enableAutoScroll: false,\n autoScrollTimer: 0,\n arrowSize: 14\n};\n\nexport default CarouselWrapper;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,MAAM,EAAEC,QAAQ,EAAEC,SAAS,QAAQ,OAAO;AAC1D,OAAOC,SAAS,MAAM,YAAY;AAElC,MAAMC,eAAe,GAAGA,CAAC;EACvBC,QAAQ;EACRC,cAAc;EACdC,WA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AAAmC,aAAA;IAAKC,SAAS,EAAC;EAAsC,GAClDpB,YAAY,iBACXhB,KAAA,CAAAmC,aAAA;IACEE,IAAI,EAAC,QAAQ;IACbD,SAAS,EAAC,iDAAiD;IAC3DE,OAAO,EAAEA,CAAA,KAAM;MACbpB,mBAAmB,CAAC,KAAK,CAAC;MAC1BO,sBAAsB,CAAC,IAAI,CAAC;IAC9B;EAAE,gBACFzB,KAAA,CAAAmC,aAAA;IAAGC,SAAS,EAAC;EAAoD,CAAE,CAC7D,CAEP,CAAC,eACNpC,KAAA,CAAAmC,aAAA;IAAKC,SAAS,EAAEF,gBAAiB;IAACtB,GAAG,EAAEA,GAAI;IAAC2B,QAAQ,EAAEX;EAAa,GAChEtB,QACE,CACF,CAAC;AAEV,CAAC;AAEDD,eAAe,CAACmC,SAAS,GAAG;EAC1BjC,cAAc,EAAEH,SAAS,CAACqC,MAAM;EAChCjC,WAAW,EAAEJ,SAAS,CAACsC,MAAM;EAC7BpC,QAAQ,EAAEF,SAAS,CAACuC,SAAS,CAAC,CAACvC,SAAS,CAACwC,OAAO,CAACxC,SAAS,CAACyC,IAAI,CAAC,EAAEzC,SAAS,CAACyC,IAAI,CAAC,CAAC;EAClFpC,gBAAgB,EAAEL,SAAS,CAAC0C,IAAI;EAChCpC,eAAe,EAAEN,SAAS,CAACsC,MAAM;EACjC/B,SAAS,EAAEP,SAAS,CAACsC;AACvB,CAAC;AAEDrC,eAAe,CAAC0C,YAAY,GAAG;EAC7BvC,WAAW,EAAE,CAAC;EACdD,cAAc,EAAE,EAAE;EAClBD,QAAQ,EAAE,EAAE;EACZG,gBAAgB,EAAE,KAAK;EACvBC,eAAe,EAAE,CAAC;EAClBC,SAAS,EAAE;AACb,CAAC;AAED,eAAeN,eAAe"}
@@ -1,12 +0,0 @@
1
- import CardsRender from '../../../../../../../src/components/List/components/Cards';
2
- import withInfiniteScroll from '../../../../../../../src/HOC/withInfiniteScroll';
3
-
4
- jest.mock('../../../../../../../src/HOC/withInfiniteScroll', () => jest.fn(component => component));
5
-
6
- describe('CardRenderWithInfiniteScroll component', () => {
7
- it('should wrap FullRender with infinitieScroll HOC', async () => {
8
- const CardRenderWithInfiniteScroll = await import('../../../../../../../src/components/List/components/Cards/CardRenderWithInfiniteScroll');
9
- expect(CardRenderWithInfiniteScroll.default).toBe(CardsRender);
10
- expect(withInfiniteScroll).toHaveBeenCalledWith(CardsRender);
11
- });
12
- });
@@ -1,12 +0,0 @@
1
- import FullRender from '../../../../../../../src/components/List/components/Full';
2
- import withInfiniteScroll from '../../../../../../../src/HOC/withInfiniteScroll';
3
-
4
- jest.mock('../../../../../../../src/HOC/withInfiniteScroll', () => jest.fn(component => component));
5
-
6
- describe('FullRenderWithInfiniteScroll component', () => {
7
- it('should wrap FullRender with infinitieScroll HOC', async () => {
8
- const FullRenderWithInfiniteScroll = await import('../../../../../../../src/components/List/components/Full/FullRenderWithInfiniteScroll');
9
- expect(FullRenderWithInfiniteScroll.default).toBe(FullRender);
10
- expect(withInfiniteScroll).toHaveBeenCalledWith(FullRender);
11
- });
12
- });