@blaze-cms/react-page-builder 0.124.0-alpha.9 → 0.124.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.
- package/CHANGELOG.md +303 -0
- package/README.md +8 -0
- package/lib/application/query/index.js +8 -2
- package/lib/application/query/index.js.map +1 -1
- package/lib/components/Button.js +18 -5
- package/lib/components/Button.js.map +1 -1
- package/lib/components/Card/CardContainer.js +3 -7
- package/lib/components/Card/CardContainer.js.map +1 -1
- package/lib/components/Card/CardFactory.js +6 -3
- package/lib/components/Card/CardFactory.js.map +1 -1
- package/lib/components/CarouselWrapper.js +2 -2
- package/lib/components/CarouselWrapper.js.map +1 -1
- package/lib/components/Image/ImageRender.js +5 -1
- package/lib/components/Image/ImageRender.js.map +1 -1
- package/lib/components/ItemList/ItemListButton/ItemListButton.js +161 -0
- package/lib/components/ItemList/ItemListButton/ItemListButton.js.map +1 -0
- package/lib/components/ItemList/ItemListButton/index.js +16 -0
- package/lib/components/ItemList/ItemListButton/index.js.map +1 -0
- package/lib/components/ItemList/ItemListCounter/ItemListCounter.js +83 -0
- package/lib/components/ItemList/ItemListCounter/ItemListCounter.js.map +1 -0
- package/lib/components/ItemList/ItemListCounter/index.js +16 -0
- package/lib/components/ItemList/ItemListCounter/index.js.map +1 -0
- package/lib/components/ItemList/ItemListNew/ItemListNew.js +87 -0
- package/lib/components/ItemList/ItemListNew/ItemListNew.js.map +1 -0
- package/lib/components/ItemList/ItemListNew/index.js +16 -0
- package/lib/components/ItemList/ItemListNew/index.js.map +1 -0
- package/lib/components/ItemList/constants.js +19 -0
- package/lib/components/ItemList/constants.js.map +1 -0
- package/lib/components/ItemList/helpers/get-item-list-data.js +17 -0
- package/lib/components/ItemList/helpers/get-item-list-data.js.map +1 -0
- package/lib/components/ItemList/helpers/get-item-list-id.js +23 -0
- package/lib/components/ItemList/helpers/get-item-list-id.js.map +1 -0
- package/lib/components/ItemList/helpers/get-item-list-ids.js +28 -0
- package/lib/components/ItemList/helpers/get-item-list-ids.js.map +1 -0
- package/lib/components/ItemList/helpers/index.js +50 -0
- package/lib/components/ItemList/helpers/index.js.map +1 -0
- package/lib/components/ItemList/helpers/set-item-list-id.js +22 -0
- package/lib/components/ItemList/helpers/set-item-list-id.js.map +1 -0
- package/lib/components/ItemList/helpers/set-param-and-redirect.js +51 -0
- package/lib/components/ItemList/helpers/set-param-and-redirect.js.map +1 -0
- package/lib/components/ItemList/hooks/index.js +18 -0
- package/lib/components/ItemList/hooks/index.js.map +1 -0
- package/lib/components/ItemList/hooks/use-item-list-id.js +45 -0
- package/lib/components/ItemList/hooks/use-item-list-id.js.map +1 -0
- package/lib/components/LazyImage/LazyImage.js +5 -1
- package/lib/components/LazyImage/LazyImage.js.map +1 -1
- package/lib/components/List/ListBuilder.js +12 -6
- package/lib/components/List/ListBuilder.js.map +1 -1
- package/lib/components/List/ListFactory.js +34 -7
- package/lib/components/List/ListFactory.js.map +1 -1
- package/lib/components/List/helpers/has-required-item-list-details.js +29 -0
- package/lib/components/List/helpers/has-required-item-list-details.js.map +1 -0
- package/lib/components/List/helpers/index.js +8 -0
- package/lib/components/List/helpers/index.js.map +1 -1
- package/lib/components/Menu/Menu.js +41 -28
- package/lib/components/Menu/Menu.js.map +1 -1
- package/lib/components/Menu/MenuContext.js +20 -0
- package/lib/components/Menu/MenuContext.js.map +1 -0
- package/lib/components/MenuItem/MenuItem.js +26 -7
- package/lib/components/MenuItem/MenuItem.js.map +1 -1
- package/lib/components/SearchContent/SearchContent.js +183 -0
- package/lib/components/SearchContent/SearchContent.js.map +1 -0
- package/lib/components/SearchContent/SearchContentItems.js +51 -0
- package/lib/components/SearchContent/SearchContentItems.js.map +1 -0
- package/lib/components/SearchContent/SearchContentResults.js +45 -0
- package/lib/components/SearchContent/SearchContentResults.js.map +1 -0
- package/lib/components/SearchContent/SearchContentToggleIcon.js +42 -0
- package/lib/components/SearchContent/SearchContentToggleIcon.js.map +1 -0
- package/lib/components/SearchContent/index.js +2 -301
- package/lib/components/SearchContent/index.js.map +1 -1
- package/lib/components/SearchFilter/SearchFilter/FiltersList.js +2 -4
- package/lib/components/SearchFilter/SearchFilter/FiltersList.js.map +1 -1
- package/lib/components/SearchFilter/SearchFilter/SearchFilter.js +16 -66
- package/lib/components/SearchFilter/SearchFilter/SearchFilter.js.map +1 -1
- package/lib/components/SearchFilter/SearchFilterContainer.js +87 -23
- package/lib/components/SearchFilter/SearchFilterContainer.js.map +1 -1
- package/lib/components/SearchFilter/components/Checkbox.js +19 -9
- package/lib/components/SearchFilter/components/Checkbox.js.map +1 -1
- package/lib/components/SearchFilter/components/Select.js +27 -11
- package/lib/components/SearchFilter/components/Select.js.map +1 -1
- package/lib/components/SearchFilter/components/TextSearch.js +1 -5
- package/lib/components/SearchFilter/components/TextSearch.js.map +1 -1
- package/lib/components/SearchFilter/helpers/build-filters-query.js +87 -0
- package/lib/components/SearchFilter/helpers/build-filters-query.js.map +1 -0
- package/lib/components/SearchFilter/helpers/build-query.js +1 -1
- package/lib/components/SearchFilter/helpers/build-query.js.map +1 -1
- package/lib/components/SearchFilter/helpers/build-raw-query-stringified.js +2 -1
- package/lib/components/SearchFilter/helpers/build-raw-query-stringified.js.map +1 -1
- package/lib/components/SearchFilter/helpers/get-initial-filter-values.js +18 -3
- package/lib/components/SearchFilter/helpers/get-initial-filter-values.js.map +1 -1
- package/lib/components/SearchFilter/helpers/index.js +8 -0
- package/lib/components/SearchFilter/helpers/index.js.map +1 -1
- package/lib/components/SearchFilter/helpers/parse-filter-value.js +3 -7
- package/lib/components/SearchFilter/helpers/parse-filter-value.js.map +1 -1
- package/lib/components/index.js +16 -1
- package/lib/components/index.js.map +1 -1
- package/lib/constants/index.js +3 -1
- package/lib/constants/index.js.map +1 -1
- package/lib/helpers/build-raw-query.js.map +1 -1
- package/lib/hooks/helpers/append-gtm-classname.js +1 -0
- package/lib/hooks/helpers/append-gtm-classname.js.map +1 -1
- package/lib-es/application/query/index.js +45 -1
- package/lib-es/application/query/index.js.map +1 -1
- package/lib-es/components/Button.js +18 -6
- package/lib-es/components/Button.js.map +1 -1
- package/lib-es/components/Card/CardContainer.js +3 -7
- package/lib-es/components/Card/CardContainer.js.map +1 -1
- package/lib-es/components/Card/CardFactory.js +7 -4
- package/lib-es/components/Card/CardFactory.js.map +1 -1
- package/lib-es/components/CarouselWrapper.js +2 -2
- package/lib-es/components/CarouselWrapper.js.map +1 -1
- package/lib-es/components/Image/ImageRender.js +4 -1
- package/lib-es/components/Image/ImageRender.js.map +1 -1
- package/lib-es/components/ItemList/ItemListButton/ItemListButton.js +111 -0
- package/lib-es/components/ItemList/ItemListButton/ItemListButton.js.map +1 -0
- package/lib-es/components/ItemList/ItemListButton/index.js +3 -0
- package/lib-es/components/ItemList/ItemListButton/index.js.map +1 -0
- package/lib-es/components/ItemList/ItemListCounter/ItemListCounter.js +60 -0
- package/lib-es/components/ItemList/ItemListCounter/ItemListCounter.js.map +1 -0
- package/lib-es/components/ItemList/ItemListCounter/index.js +3 -0
- package/lib-es/components/ItemList/ItemListCounter/index.js.map +1 -0
- package/lib-es/components/ItemList/ItemListNew/ItemListNew.js +64 -0
- package/lib-es/components/ItemList/ItemListNew/ItemListNew.js.map +1 -0
- package/lib-es/components/ItemList/ItemListNew/index.js +3 -0
- package/lib-es/components/ItemList/ItemListNew/index.js.map +1 -0
- package/lib-es/components/ItemList/constants.js +6 -0
- package/lib-es/components/ItemList/constants.js.map +1 -0
- package/lib-es/components/ItemList/helpers/get-item-list-data.js +7 -0
- package/lib-es/components/ItemList/helpers/get-item-list-data.js.map +1 -0
- package/lib-es/components/ItemList/helpers/get-item-list-id.js +11 -0
- package/lib-es/components/ItemList/helpers/get-item-list-id.js.map +1 -0
- package/lib-es/components/ItemList/helpers/get-item-list-ids.js +13 -0
- package/lib-es/components/ItemList/helpers/get-item-list-ids.js.map +1 -0
- package/lib-es/components/ItemList/helpers/index.js +6 -0
- package/lib-es/components/ItemList/helpers/index.js.map +1 -0
- package/lib-es/components/ItemList/helpers/set-item-list-id.js +10 -0
- package/lib-es/components/ItemList/helpers/set-item-list-id.js.map +1 -0
- package/lib-es/components/ItemList/helpers/set-param-and-redirect.js +20 -0
- package/lib-es/components/ItemList/helpers/set-param-and-redirect.js.map +1 -0
- package/lib-es/components/ItemList/hooks/index.js +2 -0
- package/lib-es/components/ItemList/hooks/index.js.map +1 -0
- package/lib-es/components/ItemList/hooks/use-item-list-id.js +26 -0
- package/lib-es/components/ItemList/hooks/use-item-list-id.js.map +1 -0
- package/lib-es/components/LazyImage/LazyImage.js +4 -1
- package/lib-es/components/LazyImage/LazyImage.js.map +1 -1
- package/lib-es/components/List/ListBuilder.js +12 -6
- package/lib-es/components/List/ListBuilder.js.map +1 -1
- package/lib-es/components/List/ListFactory.js +33 -9
- package/lib-es/components/List/ListFactory.js.map +1 -1
- package/lib-es/components/List/helpers/has-required-item-list-details.js +20 -0
- package/lib-es/components/List/helpers/has-required-item-list-details.js.map +1 -0
- package/lib-es/components/List/helpers/index.js +1 -0
- package/lib-es/components/List/helpers/index.js.map +1 -1
- package/lib-es/components/Menu/Menu.js +54 -46
- package/lib-es/components/Menu/Menu.js.map +1 -1
- package/lib-es/components/Menu/MenuContext.js +6 -0
- package/lib-es/components/Menu/MenuContext.js.map +1 -0
- package/lib-es/components/MenuItem/MenuItem.js +24 -9
- package/lib-es/components/MenuItem/MenuItem.js.map +1 -1
- package/lib-es/components/SearchContent/SearchContent.js +129 -0
- package/lib-es/components/SearchContent/SearchContent.js.map +1 -0
- package/lib-es/components/SearchContent/SearchContentItems.js +33 -0
- package/lib-es/components/SearchContent/SearchContentItems.js.map +1 -0
- package/lib-es/components/SearchContent/SearchContentResults.js +31 -0
- package/lib-es/components/SearchContent/SearchContentResults.js.map +1 -0
- package/lib-es/components/SearchContent/SearchContentToggleIcon.js +30 -0
- package/lib-es/components/SearchContent/SearchContentToggleIcon.js.map +1 -0
- package/lib-es/components/SearchContent/index.js +1 -205
- package/lib-es/components/SearchContent/index.js.map +1 -1
- package/lib-es/components/SearchFilter/SearchFilter/FiltersList.js +2 -4
- package/lib-es/components/SearchFilter/SearchFilter/FiltersList.js.map +1 -1
- package/lib-es/components/SearchFilter/SearchFilter/SearchFilter.js +10 -43
- package/lib-es/components/SearchFilter/SearchFilter/SearchFilter.js.map +1 -1
- package/lib-es/components/SearchFilter/SearchFilterContainer.js +70 -15
- package/lib-es/components/SearchFilter/SearchFilterContainer.js.map +1 -1
- package/lib-es/components/SearchFilter/components/Checkbox.js +18 -9
- package/lib-es/components/SearchFilter/components/Checkbox.js.map +1 -1
- package/lib-es/components/SearchFilter/components/Select.js +23 -8
- package/lib-es/components/SearchFilter/components/Select.js.map +1 -1
- package/lib-es/components/SearchFilter/components/TextSearch.js +1 -5
- package/lib-es/components/SearchFilter/components/TextSearch.js.map +1 -1
- package/lib-es/components/SearchFilter/helpers/build-filters-query.js +54 -0
- package/lib-es/components/SearchFilter/helpers/build-filters-query.js.map +1 -0
- package/lib-es/components/SearchFilter/helpers/build-query.js +1 -1
- package/lib-es/components/SearchFilter/helpers/build-query.js.map +1 -1
- package/lib-es/components/SearchFilter/helpers/build-raw-query-stringified.js +2 -1
- package/lib-es/components/SearchFilter/helpers/build-raw-query-stringified.js.map +1 -1
- package/lib-es/components/SearchFilter/helpers/get-initial-filter-values.js +13 -1
- package/lib-es/components/SearchFilter/helpers/get-initial-filter-values.js.map +1 -1
- package/lib-es/components/SearchFilter/helpers/index.js +2 -1
- package/lib-es/components/SearchFilter/helpers/index.js.map +1 -1
- package/lib-es/components/SearchFilter/helpers/parse-filter-value.js +3 -3
- package/lib-es/components/SearchFilter/helpers/parse-filter-value.js.map +1 -1
- package/lib-es/components/index.js +10 -1
- package/lib-es/components/index.js.map +1 -1
- package/lib-es/constants/index.js +2 -1
- package/lib-es/constants/index.js.map +1 -1
- package/lib-es/helpers/build-raw-query.js.map +1 -1
- package/lib-es/hooks/helpers/append-gtm-classname.js +1 -0
- package/lib-es/hooks/helpers/append-gtm-classname.js.map +1 -1
- package/package.json +5 -4
- package/src/application/query/index.js +51 -1
- package/src/components/Button.js +27 -5
- package/src/components/Card/CardContainer.js +2 -6
- package/src/components/Card/CardFactory.js +5 -3
- package/src/components/CarouselWrapper.js +2 -2
- package/src/components/Image/ImageRender.js +3 -0
- package/src/components/ItemList/ItemListButton/ItemListButton.js +94 -0
- package/src/components/ItemList/ItemListButton/index.js +3 -0
- package/src/components/ItemList/ItemListCounter/ItemListCounter.js +52 -0
- package/src/components/ItemList/ItemListCounter/index.js +3 -0
- package/src/components/ItemList/ItemListNew/ItemListNew.js +51 -0
- package/src/components/ItemList/ItemListNew/index.js +3 -0
- package/src/components/ItemList/constants.js +5 -0
- package/src/components/ItemList/helpers/get-item-list-data.js +6 -0
- package/src/components/ItemList/helpers/get-item-list-id.js +11 -0
- package/src/components/ItemList/helpers/get-item-list-ids.js +10 -0
- package/src/components/ItemList/helpers/index.js +5 -0
- package/src/components/ItemList/helpers/set-item-list-id.js +9 -0
- package/src/components/ItemList/helpers/set-param-and-redirect.js +20 -0
- package/src/components/ItemList/hooks/index.js +1 -0
- package/src/components/ItemList/hooks/use-item-list-id.js +27 -0
- package/src/components/LazyImage/LazyImage.js +11 -1
- package/src/components/List/ListBuilder.js +10 -5
- package/src/components/List/ListFactory.js +48 -12
- package/src/components/List/helpers/has-required-item-list-details.js +14 -0
- package/src/components/List/helpers/index.js +1 -0
- package/src/components/Menu/Menu.js +61 -54
- package/src/components/Menu/MenuContext.js +5 -0
- package/src/components/MenuItem/MenuItem.js +39 -14
- package/src/components/SearchContent/SearchContent.js +136 -0
- package/src/components/SearchContent/SearchContentItems.js +28 -0
- package/src/components/SearchContent/SearchContentResults.js +27 -0
- package/src/components/SearchContent/SearchContentToggleIcon.js +27 -0
- package/src/components/SearchContent/index.js +1 -217
- package/src/components/SearchFilter/SearchFilter/FiltersList.js +30 -37
- package/src/components/SearchFilter/SearchFilter/SearchFilter.js +10 -25
- package/src/components/SearchFilter/SearchFilterContainer.js +61 -16
- package/src/components/SearchFilter/components/Checkbox.js +23 -8
- package/src/components/SearchFilter/components/Select.js +18 -11
- package/src/components/SearchFilter/components/TextSearch.js +1 -3
- package/src/components/SearchFilter/helpers/build-filters-query.js +40 -0
- package/src/components/SearchFilter/helpers/build-query.js +3 -1
- package/src/components/SearchFilter/helpers/build-raw-query-stringified.js +2 -1
- package/src/components/SearchFilter/helpers/get-initial-filter-values.js +12 -1
- package/src/components/SearchFilter/helpers/index.js +3 -1
- package/src/components/SearchFilter/helpers/parse-filter-value.js +3 -3
- package/src/components/index.js +10 -1
- package/src/constants/index.js +2 -0
- package/src/helpers/build-raw-query.js +1 -0
- package/src/hooks/helpers/append-gtm-classname.js +3 -0
- package/tests/unit/src/components/Button.test.js +55 -1
- package/tests/unit/src/components/ItemList/ItemListButton.test.js +175 -0
- package/tests/unit/src/components/ItemList/ItemListCounter.test.js +65 -0
- package/tests/unit/src/components/ItemList/ItemListNew.test.js +164 -0
- package/tests/unit/src/components/ItemList/__snapshots__/ItemListButton.test.js.snap +107 -0
- package/tests/unit/src/components/ItemList/__snapshots__/ItemListCounter.test.js.snap +31 -0
- package/tests/unit/src/components/ItemList/__snapshots__/ItemListNew.test.js.snap +27 -0
- package/tests/unit/src/components/ItemList/helpers/get-item-list-data.test.js +28 -0
- package/tests/unit/src/components/ItemList/helpers/get-item-list-id.test.js +20 -0
- package/tests/unit/src/components/ItemList/helpers/get-item-list-ids.test.js +19 -0
- package/tests/unit/src/components/ItemList/helpers/set-item-list-id.test.js +13 -0
- package/tests/unit/src/components/ItemList/helpers/set-param-and-redirect.test.js +30 -0
- package/tests/unit/src/components/ItemList/hooks/use-item-list-id.test.js +32 -0
- package/tests/unit/src/components/List/helpers/has-required-item-list-details.test.js +30 -0
- package/tests/unit/src/components/Menu/Menu.test.js +9 -3
- package/tests/unit/src/components/Menu/__snapshots__/Menu.test.js.snap +12 -11
- package/tests/unit/src/components/MenuItem/MenuItem.test.js +1 -1
- package/tests/unit/src/components/MenuItem/SubMenu.test.js +5 -1
- package/tests/unit/src/components/MenuItem/__snapshots__/MenuItem.test.js.snap +54 -10
- package/tests/unit/src/components/SearchContent/SearchContent.test.js +29 -0
- package/tests/unit/src/components/SearchContent/__snapshots__/SearchContent.test.js.snap +9 -0
- package/tests/unit/src/components/SearchFilter/SearchFilter/SearchFilter.test.js +3 -6
- package/tests/unit/src/components/SearchFilter/components/__snapshots__/Checkbox.test.js.snap +2 -0
- package/tests/unit/src/components/SearchFilter/components/__snapshots__/Select.test.js.snap +4 -0
- package/tests/unit/src/components/SearchFilter/helpers/build-query.test.js +2 -2
- package/tests/unit/src/components/SearchFilter/helpers/get-initial-filter-values.test.js +25 -11
- package/tests/unit/src/components/SearchFilter/helpers/parse-filter-value.test.js +1 -1
- package/tests/unit/src/components/__snapshots__/index.test.js.snap +12 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`ItemListButton component should add and remove item to the list on click 1`] = `
|
|
4
|
+
<DocumentFragment>
|
|
5
|
+
<div
|
|
6
|
+
class="item-list-button item-list-button--selected modifier"
|
|
7
|
+
role="button"
|
|
8
|
+
>
|
|
9
|
+
<i>
|
|
10
|
+
<svg
|
|
11
|
+
fill="currentColor"
|
|
12
|
+
height="1em"
|
|
13
|
+
stroke="currentColor"
|
|
14
|
+
stroke-width="0"
|
|
15
|
+
viewBox="0 0 16 16"
|
|
16
|
+
width="1em"
|
|
17
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
18
|
+
>
|
|
19
|
+
<path
|
|
20
|
+
d="M2 15.5V2a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v13.5a.5.5 0 0 1-.74.439L8 13.069l-5.26 2.87A.5.5 0 0 1 2 15.5zm8.854-9.646a.5.5 0 0 0-.708-.708L7.5 7.793 6.354 6.646a.5.5 0 1 0-.708.708l1.5 1.5a.5.5 0 0 0 .708 0l3-3z"
|
|
21
|
+
fill-rule="evenodd"
|
|
22
|
+
/>
|
|
23
|
+
</svg>
|
|
24
|
+
</i>
|
|
25
|
+
</div>
|
|
26
|
+
</DocumentFragment>
|
|
27
|
+
`;
|
|
28
|
+
|
|
29
|
+
exports[`ItemListButton component should add and remove item to the list on click 2`] = `
|
|
30
|
+
<DocumentFragment>
|
|
31
|
+
<div
|
|
32
|
+
class="item-list-button item-list-button--selected modifier"
|
|
33
|
+
role="button"
|
|
34
|
+
>
|
|
35
|
+
<i>
|
|
36
|
+
<svg
|
|
37
|
+
fill="currentColor"
|
|
38
|
+
height="1em"
|
|
39
|
+
stroke="currentColor"
|
|
40
|
+
stroke-width="0"
|
|
41
|
+
viewBox="0 0 16 16"
|
|
42
|
+
width="1em"
|
|
43
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
44
|
+
>
|
|
45
|
+
<path
|
|
46
|
+
d="M2 15.5V2a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v13.5a.5.5 0 0 1-.74.439L8 13.069l-5.26 2.87A.5.5 0 0 1 2 15.5zm8.854-9.646a.5.5 0 0 0-.708-.708L7.5 7.793 6.354 6.646a.5.5 0 1 0-.708.708l1.5 1.5a.5.5 0 0 0 .708 0l3-3z"
|
|
47
|
+
fill-rule="evenodd"
|
|
48
|
+
/>
|
|
49
|
+
</svg>
|
|
50
|
+
</i>
|
|
51
|
+
</div>
|
|
52
|
+
</DocumentFragment>
|
|
53
|
+
`;
|
|
54
|
+
|
|
55
|
+
exports[`ItemListButton component should render button marked selected when current parent is in the list 1`] = `
|
|
56
|
+
<DocumentFragment>
|
|
57
|
+
<div
|
|
58
|
+
class="item-list-button item-list-button--selected modifier"
|
|
59
|
+
role="button"
|
|
60
|
+
>
|
|
61
|
+
<i>
|
|
62
|
+
<svg
|
|
63
|
+
fill="currentColor"
|
|
64
|
+
height="1em"
|
|
65
|
+
stroke="currentColor"
|
|
66
|
+
stroke-width="0"
|
|
67
|
+
viewBox="0 0 16 16"
|
|
68
|
+
width="1em"
|
|
69
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
70
|
+
>
|
|
71
|
+
<path
|
|
72
|
+
d="M2 15.5V2a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v13.5a.5.5 0 0 1-.74.439L8 13.069l-5.26 2.87A.5.5 0 0 1 2 15.5zm8.854-9.646a.5.5 0 0 0-.708-.708L7.5 7.793 6.354 6.646a.5.5 0 1 0-.708.708l1.5 1.5a.5.5 0 0 0 .708 0l3-3z"
|
|
73
|
+
fill-rule="evenodd"
|
|
74
|
+
/>
|
|
75
|
+
</svg>
|
|
76
|
+
</i>
|
|
77
|
+
</div>
|
|
78
|
+
</DocumentFragment>
|
|
79
|
+
`;
|
|
80
|
+
|
|
81
|
+
exports[`ItemListButton component should render button not marked selected when current parent is not in the list 1`] = `
|
|
82
|
+
<DocumentFragment>
|
|
83
|
+
<div
|
|
84
|
+
class="item-list-button modifier"
|
|
85
|
+
role="button"
|
|
86
|
+
>
|
|
87
|
+
<i>
|
|
88
|
+
<svg
|
|
89
|
+
fill="currentColor"
|
|
90
|
+
height="1em"
|
|
91
|
+
stroke="currentColor"
|
|
92
|
+
stroke-width="0"
|
|
93
|
+
viewBox="0 0 16 16"
|
|
94
|
+
width="1em"
|
|
95
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
96
|
+
>
|
|
97
|
+
<path
|
|
98
|
+
d="M7.84 4.1a.178.178 0 0 1 .32 0l.634 1.285a.178.178 0 0 0 .134.098l1.42.206c.145.021.204.2.098.303L9.42 6.993a.178.178 0 0 0-.051.158l.242 1.414a.178.178 0 0 1-.258.187l-1.27-.668a.178.178 0 0 0-.165 0l-1.27.668a.178.178 0 0 1-.257-.187l.242-1.414a.178.178 0 0 0-.05-.158l-1.03-1.001a.178.178 0 0 1 .098-.303l1.42-.206a.178.178 0 0 0 .134-.098L7.84 4.1z"
|
|
99
|
+
/>
|
|
100
|
+
<path
|
|
101
|
+
d="M2 2a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v13.5a.5.5 0 0 1-.777.416L8 13.101l-5.223 2.815A.5.5 0 0 1 2 15.5V2zm2-1a1 1 0 0 0-1 1v12.566l4.723-2.482a.5.5 0 0 1 .554 0L13 14.566V2a1 1 0 0 0-1-1H4z"
|
|
102
|
+
/>
|
|
103
|
+
</svg>
|
|
104
|
+
</i>
|
|
105
|
+
</div>
|
|
106
|
+
</DocumentFragment>
|
|
107
|
+
`;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`ItemListCounter component should display listItem count and route to url 1`] = `
|
|
4
|
+
<DocumentFragment>
|
|
5
|
+
<div
|
|
6
|
+
class="item-list-counter modifier"
|
|
7
|
+
role="button"
|
|
8
|
+
type="button"
|
|
9
|
+
>
|
|
10
|
+
<svg
|
|
11
|
+
fill="currentColor"
|
|
12
|
+
height="1em"
|
|
13
|
+
stroke="currentColor"
|
|
14
|
+
stroke-width="0"
|
|
15
|
+
viewBox="0 0 16 16"
|
|
16
|
+
width="1em"
|
|
17
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
18
|
+
>
|
|
19
|
+
<path
|
|
20
|
+
d="M2 15.5V2a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v13.5a.5.5 0 0 1-.74.439L8 13.069l-5.26 2.87A.5.5 0 0 1 2 15.5zM8.16 4.1a.178.178 0 0 0-.32 0l-.634 1.285a.178.178 0 0 1-.134.098l-1.42.206a.178.178 0 0 0-.098.303L6.58 6.993c.042.041.061.1.051.158L6.39 8.565a.178.178 0 0 0 .258.187l1.27-.668a.178.178 0 0 1 .165 0l1.27.668a.178.178 0 0 0 .257-.187L9.368 7.15a.178.178 0 0 1 .05-.158l1.028-1.001a.178.178 0 0 0-.098-.303l-1.42-.206a.178.178 0 0 1-.134-.098L8.16 4.1z"
|
|
21
|
+
fill-rule="evenodd"
|
|
22
|
+
/>
|
|
23
|
+
</svg>
|
|
24
|
+
<span
|
|
25
|
+
class="item-list-counter__badge"
|
|
26
|
+
>
|
|
27
|
+
1
|
|
28
|
+
</span>
|
|
29
|
+
</div>
|
|
30
|
+
</DocumentFragment>
|
|
31
|
+
`;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`ItemListNew component should match snapshot and render without throwing an error 1`] = `
|
|
4
|
+
<DocumentFragment>
|
|
5
|
+
<button
|
|
6
|
+
class="item-list-new button"
|
|
7
|
+
type="button"
|
|
8
|
+
>
|
|
9
|
+
Clear list
|
|
10
|
+
</button>
|
|
11
|
+
</DocumentFragment>
|
|
12
|
+
`;
|
|
13
|
+
|
|
14
|
+
exports[`ItemListNew component should not render if list has not items 1`] = `<DocumentFragment />`;
|
|
15
|
+
|
|
16
|
+
exports[`ItemListNew component should not render if list not found 1`] = `<DocumentFragment />`;
|
|
17
|
+
|
|
18
|
+
exports[`ItemListNew component should render using listId from query 1`] = `
|
|
19
|
+
<DocumentFragment>
|
|
20
|
+
<button
|
|
21
|
+
class="item-list-new button"
|
|
22
|
+
type="button"
|
|
23
|
+
>
|
|
24
|
+
Clear list
|
|
25
|
+
</button>
|
|
26
|
+
</DocumentFragment>
|
|
27
|
+
`;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
2
|
+
import getItemListData from '../../../../../../src/components/ItemList/helpers/get-item-list-data';
|
|
3
|
+
|
|
4
|
+
describe('getItemListData helper', () => {
|
|
5
|
+
const noData = getItemListData();
|
|
6
|
+
const noGetItemList = getItemListData({});
|
|
7
|
+
const noListItems = getItemListData({ getItemList: {} });
|
|
8
|
+
const withCorrectData = getItemListData({
|
|
9
|
+
getItemList: { listItems: ['one item', 'two items'] }
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('should always return an array', () => {
|
|
13
|
+
expect(Array.isArray(noData)).toBeTruthy();
|
|
14
|
+
expect(Array.isArray(noGetItemList)).toBeTruthy();
|
|
15
|
+
expect(Array.isArray(noListItems)).toBeTruthy();
|
|
16
|
+
expect(Array.isArray(withCorrectData)).toBeTruthy();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('should return an empty array if data passed doesnt have expected props', () => {
|
|
20
|
+
expect(noData).toEqual([]);
|
|
21
|
+
expect(noGetItemList).toEqual([]);
|
|
22
|
+
expect(noListItems).toEqual([]);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('should return listData otherwise', () => {
|
|
26
|
+
expect(withCorrectData).toEqual(['one item', 'two items']);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
2
|
+
import getitemListId from '../../../../../../src/components/ItemList/helpers/get-item-list-id';
|
|
3
|
+
|
|
4
|
+
describe('getitemListId helper', () => {
|
|
5
|
+
const noValues = getitemListId();
|
|
6
|
+
const noListId = getitemListId('listName');
|
|
7
|
+
const noListName = getitemListId(null, '123asd');
|
|
8
|
+
|
|
9
|
+
it('should return empty string if no values are passed', () => {
|
|
10
|
+
expect(noValues).toEqual('');
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it('should return listId if passed', () => {
|
|
14
|
+
expect(noListName).toEqual('123asd');
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('should return local value if no id is passed but name is', () => {
|
|
18
|
+
expect(noListId).toEqual('');
|
|
19
|
+
});
|
|
20
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
2
|
+
import getitemListIds from '../../../../../../src/components/ItemList/helpers/get-item-list-ids';
|
|
3
|
+
|
|
4
|
+
describe('getitemListIds helper', () => {
|
|
5
|
+
const noData = getitemListIds();
|
|
6
|
+
const emptyData = getitemListIds({});
|
|
7
|
+
const withData = getitemListIds({
|
|
8
|
+
getItemList: { listItems: [{ itemId: '123' }, { itemId: '456' }] }
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it('should return null if no valid data is passed', () => {
|
|
12
|
+
expect(noData).toEqual(null);
|
|
13
|
+
expect(emptyData).toEqual(null);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it('should return itemsToDisplay formatted ids', () => {
|
|
17
|
+
expect(withData).toEqual([{ displayItems: ['123'] }, { displayItems: ['456'] }]);
|
|
18
|
+
});
|
|
19
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
2
|
+
import setItemListId from '../../../../../../src/components/ItemList/helpers/set-item-list-id';
|
|
3
|
+
import { LIST_ITEM_LOCAL_KEY } from '../../../../../../src/components/ItemList/constants';
|
|
4
|
+
|
|
5
|
+
describe('setItemListId helper', () => {
|
|
6
|
+
const listId = 'LIST ID';
|
|
7
|
+
const listName = 'LIST';
|
|
8
|
+
|
|
9
|
+
it('should set list id in localstorage', () => {
|
|
10
|
+
setItemListId(listName, listId);
|
|
11
|
+
expect(localStorage.setItem).toHaveBeenCalledWith(`${LIST_ITEM_LOCAL_KEY}${listName}`, listId);
|
|
12
|
+
});
|
|
13
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
2
|
+
import setParamAndRedirect from '../../../../../../src/components/ItemList/helpers/set-param-and-redirect';
|
|
3
|
+
import { LIST_ITEM_QUERY_PARAM } from '../../../../../../src/components/ItemList/constants';
|
|
4
|
+
|
|
5
|
+
describe('setParamAndRedirect helper', () => {
|
|
6
|
+
const url = '/test?otherParam=abc';
|
|
7
|
+
const urlWithQueryString = `${url}&${LIST_ITEM_QUERY_PARAM}=123`;
|
|
8
|
+
|
|
9
|
+
it('should return if no value and queryParam not present', () => {
|
|
10
|
+
const router = { asPath: url, push: jest.fn() };
|
|
11
|
+
expect(setParamAndRedirect(router)).toBeUndefined();
|
|
12
|
+
expect(router.push).not.toHaveBeenCalled();
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('should remove queryString if no value passed', () => {
|
|
16
|
+
const router = { asPath: urlWithQueryString, push: jest.fn() };
|
|
17
|
+
expect(setParamAndRedirect(router)).toBeUndefined();
|
|
18
|
+
expect(router.push).toHaveBeenCalledWith('/Resolver', url, {
|
|
19
|
+
shallow: true
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('should add queryString if value passed', () => {
|
|
24
|
+
const router = { asPath: url, push: jest.fn() };
|
|
25
|
+
expect(setParamAndRedirect(router, '123')).toBeUndefined();
|
|
26
|
+
expect(router.push).toHaveBeenCalledWith('/Resolver', urlWithQueryString, {
|
|
27
|
+
shallow: true
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { renderHook, act } from '@testing-library/react-hooks';
|
|
2
|
+
import useItemListId from '../../../../../../src/components/ItemList/hooks/use-item-list-id';
|
|
3
|
+
import getItemListId from '../../../../../../src/components/ItemList/helpers/get-item-list-id';
|
|
4
|
+
|
|
5
|
+
jest.mock('../../../../../../src/components/ItemList/helpers/get-item-list-id', () =>
|
|
6
|
+
jest.fn(() => 'LIST ID')
|
|
7
|
+
);
|
|
8
|
+
|
|
9
|
+
describe('useItemListId hook', () => {
|
|
10
|
+
const listId = 'LIST ID';
|
|
11
|
+
const listName = 'LIST';
|
|
12
|
+
|
|
13
|
+
it('should return listId ', () => {
|
|
14
|
+
const { result } = renderHook(() => useItemListId({ listName }));
|
|
15
|
+
expect(result.current).toEqual({ listId });
|
|
16
|
+
expect(getItemListId).toHaveBeenCalledWith(listName);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('should return listId after storage event', () => {
|
|
20
|
+
const noListValue = 'empty';
|
|
21
|
+
getItemListId.mockReturnValueOnce(noListValue);
|
|
22
|
+
const { result } = renderHook(() => useItemListId({ listName }));
|
|
23
|
+
expect(result.current).toEqual({ listId: noListValue });
|
|
24
|
+
|
|
25
|
+
act(() => {
|
|
26
|
+
window.dispatchEvent(new Event('storage'));
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
expect(result.current).toEqual({ listId });
|
|
30
|
+
expect(getItemListId).toHaveBeenNthCalledWith(2, listName);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import hasRequiredItemListDetails from '../../../../../../src/components/List/helpers/has-required-item-list-details';
|
|
2
|
+
import setParamAndRedirect from '../../../../../../src/components/ItemList/helpers/set-param-and-redirect';
|
|
3
|
+
|
|
4
|
+
jest.mock('../../../../../../src/components/ItemList/helpers/set-param-and-redirect', () =>
|
|
5
|
+
jest.fn()
|
|
6
|
+
);
|
|
7
|
+
|
|
8
|
+
describe('hasRequiredItemListDetails helper function', () => {
|
|
9
|
+
const itemListId = 'localstorage id';
|
|
10
|
+
const router = {};
|
|
11
|
+
const itemListName = 'LIST NAME';
|
|
12
|
+
const queryItemListId = 'query id';
|
|
13
|
+
|
|
14
|
+
it('should return true if no itemListName', () => {
|
|
15
|
+
expect(hasRequiredItemListDetails({})).toEqual(true);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('should call setParamAndRedirect if queryItemListId not set and itemListId is', () => {
|
|
19
|
+
expect(hasRequiredItemListDetails({ itemListName, itemListId, router })).toEqual(false);
|
|
20
|
+
expect(setParamAndRedirect).toHaveBeenCalledWith(router, itemListId);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('should return false if no queryItemListId and itemListId', () => {
|
|
24
|
+
expect(hasRequiredItemListDetails({ itemListName })).toEqual(false);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('should return true queryItemListId is set', () => {
|
|
28
|
+
expect(hasRequiredItemListDetails({ itemListName, queryItemListId })).toEqual(true);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
@@ -3,16 +3,22 @@ import { render } from '@blaze-cms/tools/test-helpers/test-functions';
|
|
|
3
3
|
import '@testing-library/jest-dom/extend-expect';
|
|
4
4
|
import Menu from '../../../../../src/components/Menu';
|
|
5
5
|
|
|
6
|
-
jest.mock('
|
|
6
|
+
jest.mock('next/router', () => ({
|
|
7
|
+
useRouter: jest.fn(() => ({ events: { on: jest.fn(), off: jest.fn() } }))
|
|
8
|
+
}));
|
|
7
9
|
|
|
8
10
|
const props = {
|
|
9
11
|
collapse: false,
|
|
10
12
|
modifier: 'menu-mod',
|
|
11
|
-
children: [
|
|
13
|
+
children: [
|
|
14
|
+
<div className="child_1" key="1">
|
|
15
|
+
only child
|
|
16
|
+
</div>
|
|
17
|
+
]
|
|
12
18
|
};
|
|
13
19
|
|
|
14
20
|
describe('Menu component', () => {
|
|
15
|
-
it
|
|
21
|
+
it('should render without throwing an error and match snapshot', () => {
|
|
16
22
|
const { asFragment } = render(Menu, props);
|
|
17
23
|
expect(asFragment()).toMatchSnapshot();
|
|
18
24
|
});
|
|
@@ -3,20 +3,21 @@
|
|
|
3
3
|
exports[`Menu component should render without throwing an error and match snapshot 1`] = `
|
|
4
4
|
<DocumentFragment>
|
|
5
5
|
<div
|
|
6
|
-
class="menu--
|
|
6
|
+
class="menu--wrapper"
|
|
7
7
|
>
|
|
8
|
-
<
|
|
9
|
-
class="menu-
|
|
8
|
+
<div
|
|
9
|
+
class="menu--desktop-wrapper"
|
|
10
10
|
>
|
|
11
|
-
<
|
|
12
|
-
class="
|
|
11
|
+
<ul
|
|
12
|
+
class=" menu-mod"
|
|
13
13
|
>
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
<div
|
|
15
|
+
class="child_1"
|
|
16
|
+
>
|
|
17
|
+
only child
|
|
18
|
+
</div>
|
|
19
|
+
</ul>
|
|
20
|
+
</div>
|
|
20
21
|
</div>
|
|
21
22
|
</DocumentFragment>
|
|
22
23
|
`;
|
|
@@ -15,7 +15,11 @@ describe('SubMenu component', () => {
|
|
|
15
15
|
it('should render children if passed', () => {
|
|
16
16
|
const { container, asFragment } = render(SubMenu, {
|
|
17
17
|
modifier: '',
|
|
18
|
-
children: [
|
|
18
|
+
children: [
|
|
19
|
+
<div className="sub-menu-child" key="1">
|
|
20
|
+
some stuff
|
|
21
|
+
</div>
|
|
22
|
+
]
|
|
19
23
|
});
|
|
20
24
|
expect(asFragment()).toMatchSnapshot();
|
|
21
25
|
expect(container.firstChild.firstChild).toContainHTML('div');
|
|
@@ -5,13 +5,35 @@ exports[`MenuItem component should render link if url is passed 1`] = `
|
|
|
5
5
|
<li
|
|
6
6
|
class="menu-item-mod"
|
|
7
7
|
>
|
|
8
|
-
<
|
|
9
|
-
|
|
8
|
+
<div
|
|
9
|
+
class="menu--item--link"
|
|
10
10
|
>
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
<a
|
|
12
|
+
href="/somewhere"
|
|
13
|
+
>
|
|
14
|
+
Item 1
|
|
15
|
+
</a>
|
|
16
|
+
<i
|
|
17
|
+
class="menu--item--link--icon"
|
|
18
|
+
role="button"
|
|
19
|
+
>
|
|
20
|
+
<svg
|
|
21
|
+
fill="currentColor"
|
|
22
|
+
height="1em"
|
|
23
|
+
stroke="currentColor"
|
|
24
|
+
stroke-width="0"
|
|
25
|
+
viewBox="0 0 448 512"
|
|
26
|
+
width="1em"
|
|
27
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
28
|
+
>
|
|
29
|
+
<path
|
|
30
|
+
d="M207.029 381.476L12.686 187.132c-9.373-9.373-9.373-24.569 0-33.941l22.667-22.667c9.357-9.357 24.522-9.375 33.901-.04L224 284.505l154.745-154.021c9.379-9.335 24.544-9.317 33.901.04l22.667 22.667c9.373 9.373 9.373 24.569 0 33.941L240.971 381.476c-9.373 9.372-24.569 9.372-33.942 0z"
|
|
31
|
+
/>
|
|
32
|
+
</svg>
|
|
33
|
+
</i>
|
|
34
|
+
</div>
|
|
13
35
|
<div
|
|
14
|
-
class="hidden"
|
|
36
|
+
class="menu--item-children hidden"
|
|
15
37
|
>
|
|
16
38
|
<div
|
|
17
39
|
class="child_1"
|
|
@@ -29,13 +51,35 @@ exports[`MenuItem component should render without throwing an error and match sn
|
|
|
29
51
|
<li
|
|
30
52
|
class="menu-item-mod"
|
|
31
53
|
>
|
|
32
|
-
<
|
|
33
|
-
|
|
54
|
+
<div
|
|
55
|
+
class="menu--item--link"
|
|
34
56
|
>
|
|
35
|
-
|
|
36
|
-
|
|
57
|
+
<span
|
|
58
|
+
role="button"
|
|
59
|
+
>
|
|
60
|
+
Item 1
|
|
61
|
+
</span>
|
|
62
|
+
<i
|
|
63
|
+
class="menu--item--link--icon"
|
|
64
|
+
role="button"
|
|
65
|
+
>
|
|
66
|
+
<svg
|
|
67
|
+
fill="currentColor"
|
|
68
|
+
height="1em"
|
|
69
|
+
stroke="currentColor"
|
|
70
|
+
stroke-width="0"
|
|
71
|
+
viewBox="0 0 448 512"
|
|
72
|
+
width="1em"
|
|
73
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
74
|
+
>
|
|
75
|
+
<path
|
|
76
|
+
d="M207.029 381.476L12.686 187.132c-9.373-9.373-9.373-24.569 0-33.941l22.667-22.667c9.357-9.357 24.522-9.375 33.901-.04L224 284.505l154.745-154.021c9.379-9.335 24.544-9.317 33.901.04l22.667 22.667c9.373 9.373 9.373 24.569 0 33.941L240.971 381.476c-9.373 9.372-24.569 9.372-33.942 0z"
|
|
77
|
+
/>
|
|
78
|
+
</svg>
|
|
79
|
+
</i>
|
|
80
|
+
</div>
|
|
37
81
|
<div
|
|
38
|
-
class="hidden"
|
|
82
|
+
class="menu--item-children hidden"
|
|
39
83
|
>
|
|
40
84
|
<div
|
|
41
85
|
class="child_1"
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
3
|
+
import { MockedProvider } from '@apollo/client/testing';
|
|
4
|
+
import { render } from '@testing-library/react';
|
|
5
|
+
import SearchContent from '../../../../../src/components/SearchContent';
|
|
6
|
+
|
|
7
|
+
jest.mock('@apollo/client', () => ({
|
|
8
|
+
...jest.requireActual('@apollo/client'),
|
|
9
|
+
useQuery: jest.fn(() => ({ data: {}, loading: false, error: null }))
|
|
10
|
+
}));
|
|
11
|
+
|
|
12
|
+
jest.mock('next/router', () => ({
|
|
13
|
+
useRouter: jest.fn(() => ({ asPath: 'test-url' }))
|
|
14
|
+
}));
|
|
15
|
+
|
|
16
|
+
jest.mock('../../../../../src/components/SearchContent/SearchContent', () =>
|
|
17
|
+
jest.fn(() => <div>Mocked component</div>)
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
describe('SearchContent', () => {
|
|
21
|
+
it('should match snapshot', async () => {
|
|
22
|
+
const { asFragment } = render(
|
|
23
|
+
<MockedProvider mocks={[]} addTypename={false}>
|
|
24
|
+
<SearchContent />
|
|
25
|
+
</MockedProvider>
|
|
26
|
+
);
|
|
27
|
+
expect(asFragment()).toMatchSnapshot();
|
|
28
|
+
});
|
|
29
|
+
});
|
|
@@ -11,7 +11,7 @@ const renderComponent = (Component, props) => {
|
|
|
11
11
|
|
|
12
12
|
const mockedProps = {
|
|
13
13
|
data: {},
|
|
14
|
-
|
|
14
|
+
filterValues: {},
|
|
15
15
|
filters: [],
|
|
16
16
|
searchFilterRef: {},
|
|
17
17
|
buttonRef: { current: null },
|
|
@@ -24,14 +24,11 @@ const mockedProps = {
|
|
|
24
24
|
groupAfterMobile: 0,
|
|
25
25
|
groupAfterDesktop: 0,
|
|
26
26
|
isCollapsedOnResponsive: true,
|
|
27
|
-
displaySearchFilter: false
|
|
27
|
+
displaySearchFilter: false,
|
|
28
|
+
setAppliedFilters: jest.fn()
|
|
28
29
|
};
|
|
29
30
|
|
|
30
31
|
describe('SearchFilter component', () => {
|
|
31
|
-
it('should be defined', () => {
|
|
32
|
-
expect(SearchFilter).toBeDefined();
|
|
33
|
-
});
|
|
34
|
-
|
|
35
32
|
describe('when isCollapsedOnResponsive = true, displaySearchFilter = false', () => {
|
|
36
33
|
const specificMockedProps = {
|
|
37
34
|
...mockedProps,
|
package/tests/unit/src/components/SearchFilter/components/__snapshots__/Checkbox.test.js.snap
CHANGED
|
@@ -10,6 +10,7 @@ exports[`Checkbox component should render without throwing an error match snapsh
|
|
|
10
10
|
class="form-checkbox"
|
|
11
11
|
data-cy="checkbox-cy-1"
|
|
12
12
|
data-testid="checkbox-1"
|
|
13
|
+
disabled=""
|
|
13
14
|
id="name1-checkbox"
|
|
14
15
|
name="name"
|
|
15
16
|
readonly=""
|
|
@@ -36,6 +37,7 @@ exports[`Checkbox component should render without throwing an error match snapsh
|
|
|
36
37
|
class="form-checkbox"
|
|
37
38
|
data-cy="checkbox-cy-2"
|
|
38
39
|
data-testid="checkbox-2"
|
|
40
|
+
disabled=""
|
|
39
41
|
id="name2-checkbox"
|
|
40
42
|
name="name"
|
|
41
43
|
readonly=""
|
|
@@ -13,11 +13,13 @@ exports[`Select component should display label as placeholder with no label tag
|
|
|
13
13
|
Placeholder label
|
|
14
14
|
</option>
|
|
15
15
|
<option
|
|
16
|
+
disabled=""
|
|
16
17
|
value="name1"
|
|
17
18
|
>
|
|
18
19
|
name1
|
|
19
20
|
</option>
|
|
20
21
|
<option
|
|
22
|
+
disabled=""
|
|
21
23
|
value="name2"
|
|
22
24
|
>
|
|
23
25
|
name2
|
|
@@ -46,11 +48,13 @@ exports[`Select component should render witout throwing an error and match snaps
|
|
|
46
48
|
Any
|
|
47
49
|
</option>
|
|
48
50
|
<option
|
|
51
|
+
disabled=""
|
|
49
52
|
value="name1"
|
|
50
53
|
>
|
|
51
54
|
name1
|
|
52
55
|
</option>
|
|
53
56
|
<option
|
|
57
|
+
disabled=""
|
|
54
58
|
value="name2"
|
|
55
59
|
>
|
|
56
60
|
name2
|
|
@@ -24,10 +24,10 @@ describe('buildQuery helper function', () => {
|
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
it('should return new query string with search term if available', () => {
|
|
27
|
-
expect(withTextSearch).toEqual('search_term=new
|
|
27
|
+
expect(withTextSearch).toEqual('search_term=new%20search%20value');
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
it('should return new query string with search text and all other available query values', () => {
|
|
31
|
-
expect(withSearchAndRange).toEqual('search_term=new
|
|
31
|
+
expect(withSearchAndRange).toEqual('search_term=new%20search%20value&rangeFilter=2-10');
|
|
32
32
|
});
|
|
33
33
|
});
|