@blaze-cms/react-page-builder 0.131.1 → 0.132.0-admin-updates.1
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 +101 -2
- package/lib/components/Button.js +2 -1
- package/lib/components/Button.js.map +1 -1
- package/lib/components/Card/CardsRender.js +13 -6
- package/lib/components/Card/CardsRender.js.map +1 -1
- package/lib/components/Card/helpers/get-updated-items-to-display.js +55 -0
- package/lib/components/Card/helpers/get-updated-items-to-display.js.map +1 -0
- package/lib/components/Card/helpers/index.js +7 -0
- package/lib/components/Card/helpers/index.js.map +1 -1
- package/lib/components/CarouselWrapper/SmoothScrollCarousel.js +2 -2
- package/lib/components/CarouselWrapper/SmoothScrollCarousel.js.map +1 -1
- package/lib/components/Code/Code.js +7 -3
- package/lib/components/Code/Code.js.map +1 -1
- package/lib/components/DataSummary/helpers/build-loop-props-content.js +6 -3
- package/lib/components/DataSummary/helpers/build-loop-props-content.js.map +1 -1
- package/lib/components/DataSummary/helpers/build-props-to-display-with-content.js +3 -2
- package/lib/components/DataSummary/helpers/build-props-to-display-with-content.js.map +1 -1
- package/lib/components/DataSummary/helpers/get-link-to-published-content.js +2 -0
- package/lib/components/DataSummary/helpers/get-link-to-published-content.js.map +1 -1
- package/lib/components/List/ListFactory.js +16 -11
- package/lib/components/List/ListFactory.js.map +1 -1
- package/lib/components/List/helpers/get-list-query.js +43 -0
- package/lib/components/List/helpers/get-list-query.js.map +1 -0
- package/lib/components/List/helpers/get-list-specific-search-filter.js +21 -0
- package/lib/components/List/helpers/get-list-specific-search-filter.js.map +1 -0
- package/lib/components/List/helpers/index.js +14 -0
- package/lib/components/List/helpers/index.js.map +1 -1
- package/lib/components/List/helpers/strip-query-key.js +14 -0
- package/lib/components/List/helpers/strip-query-key.js.map +1 -0
- package/lib/components/SearchContent/SearchContent.js +8 -8
- package/lib/components/SearchContent/SearchContent.js.map +1 -1
- package/lib/components/SearchFilter/SearchFilter/SearchFilter.js +17 -13
- package/lib/components/SearchFilter/SearchFilter/SearchFilter.js.map +1 -1
- package/lib/components/SearchFilter/SearchFilterContainer.js +64 -83
- package/lib/components/SearchFilter/SearchFilterContainer.js.map +1 -1
- package/lib/components/SearchFilter/helpers/build-filters-query.js +3 -1
- package/lib/components/SearchFilter/helpers/build-filters-query.js.map +1 -1
- package/lib/components/SearchFilter/helpers/build-new-url.js +17 -0
- package/lib/components/SearchFilter/helpers/build-new-url.js.map +1 -0
- package/lib/components/SearchFilter/helpers/build-url-query.js +49 -0
- package/lib/components/SearchFilter/helpers/build-url-query.js.map +1 -0
- package/lib/components/SearchFilter/helpers/get-filter-ranges-and-checkboxes-values.js +32 -0
- package/lib/components/SearchFilter/helpers/get-filter-ranges-and-checkboxes-values.js.map +1 -0
- package/lib/components/SearchFilter/helpers/get-filter-values.js +31 -0
- package/lib/components/SearchFilter/helpers/get-filter-values.js.map +1 -0
- package/lib/components/SearchFilter/helpers/index.js +18 -11
- package/lib/components/SearchFilter/helpers/index.js.map +1 -1
- package/lib/components/SearchFilter/index.js.map +1 -1
- package/lib/components/SearchFilter/searchFilterReducer.js +43 -0
- package/lib/components/SearchFilter/searchFilterReducer.js.map +1 -0
- package/lib/components/SearchFilterSort/SearchFilterSort.js +31 -11
- package/lib/components/SearchFilterSort/SearchFilterSort.js.map +1 -1
- package/lib/components/SearchFilterSort/helpers/handle-sort-update.js +19 -5
- package/lib/components/SearchFilterSort/helpers/handle-sort-update.js.map +1 -1
- package/lib/components/SearchFilterSort/helpers/update-sort.js +9 -5
- package/lib/components/SearchFilterSort/helpers/update-sort.js.map +1 -1
- package/lib/helpers/build-inherited-filters.js +2 -0
- package/lib/helpers/build-inherited-filters.js.map +1 -1
- package/lib/helpers/build-props-query.js +5 -2
- package/lib/helpers/build-props-query.js.map +1 -1
- package/lib/helpers/build-query-key.js +16 -0
- package/lib/helpers/build-query-key.js.map +1 -0
- package/lib/helpers/build-set-filters.js +5 -1
- package/lib/helpers/build-set-filters.js.map +1 -1
- package/lib/helpers/get-entities-with-banner.js +8 -2
- package/lib/helpers/get-entities-with-banner.js.map +1 -1
- package/lib/helpers/get-query-filters.js +6 -8
- package/lib/helpers/get-query-filters.js.map +1 -1
- package/lib/helpers/get-query-props.js +13 -2
- package/lib/helpers/get-query-props.js.map +1 -1
- package/lib/helpers/get-wrapped-value-with-link.js +2 -3
- package/lib/helpers/get-wrapped-value-with-link.js.map +1 -1
- package/lib/helpers/index.js +14 -0
- package/lib/helpers/index.js.map +1 -1
- package/lib/helpers/parse-props-to-display.js +13 -8
- package/lib/helpers/parse-props-to-display.js.map +1 -1
- package/lib/helpers/process-data-summary-value.js +56 -0
- package/lib/helpers/process-data-summary-value.js.map +1 -0
- package/lib-es/components/Button.js +2 -1
- package/lib-es/components/Button.js.map +1 -1
- package/lib-es/components/Card/CardsRender.js +14 -7
- package/lib-es/components/Card/CardsRender.js.map +1 -1
- package/lib-es/components/Card/helpers/get-updated-items-to-display.js +32 -0
- package/lib-es/components/Card/helpers/get-updated-items-to-display.js.map +1 -0
- package/lib-es/components/Card/helpers/index.js +1 -0
- package/lib-es/components/Card/helpers/index.js.map +1 -1
- package/lib-es/components/CarouselWrapper/SmoothScrollCarousel.js +2 -2
- package/lib-es/components/CarouselWrapper/SmoothScrollCarousel.js.map +1 -1
- package/lib-es/components/Code/Code.js +8 -4
- package/lib-es/components/Code/Code.js.map +1 -1
- package/lib-es/components/DataSummary/helpers/build-loop-props-content.js +6 -3
- package/lib-es/components/DataSummary/helpers/build-loop-props-content.js.map +1 -1
- package/lib-es/components/DataSummary/helpers/build-props-to-display-with-content.js +4 -3
- package/lib-es/components/DataSummary/helpers/build-props-to-display-with-content.js.map +1 -1
- package/lib-es/components/DataSummary/helpers/get-link-to-published-content.js +2 -1
- package/lib-es/components/DataSummary/helpers/get-link-to-published-content.js.map +1 -1
- package/lib-es/components/List/ListFactory.js +16 -12
- package/lib-es/components/List/ListFactory.js.map +1 -1
- package/lib-es/components/List/helpers/get-list-query.js +24 -0
- package/lib-es/components/List/helpers/get-list-query.js.map +1 -0
- package/lib-es/components/List/helpers/get-list-specific-search-filter.js +12 -0
- package/lib-es/components/List/helpers/get-list-specific-search-filter.js.map +1 -0
- package/lib-es/components/List/helpers/index.js +2 -0
- package/lib-es/components/List/helpers/index.js.map +1 -1
- package/lib-es/components/List/helpers/strip-query-key.js +6 -0
- package/lib-es/components/List/helpers/strip-query-key.js.map +1 -0
- package/lib-es/components/SearchContent/SearchContent.js +8 -8
- package/lib-es/components/SearchContent/SearchContent.js.map +1 -1
- package/lib-es/components/SearchFilter/SearchFilter/SearchFilter.js +18 -13
- package/lib-es/components/SearchFilter/SearchFilter/SearchFilter.js.map +1 -1
- package/lib-es/components/SearchFilter/SearchFilterContainer.js +48 -70
- package/lib-es/components/SearchFilter/SearchFilterContainer.js.map +1 -1
- package/lib-es/components/SearchFilter/helpers/build-filters-query.js +2 -0
- package/lib-es/components/SearchFilter/helpers/build-filters-query.js.map +1 -1
- package/lib-es/components/SearchFilter/helpers/build-new-url.js +8 -0
- package/lib-es/components/SearchFilter/helpers/build-new-url.js.map +1 -0
- package/lib-es/components/SearchFilter/helpers/build-url-query.js +31 -0
- package/lib-es/components/SearchFilter/helpers/build-url-query.js.map +1 -0
- package/lib-es/components/SearchFilter/helpers/get-filter-ranges-and-checkboxes-values.js +18 -0
- package/lib-es/components/SearchFilter/helpers/get-filter-ranges-and-checkboxes-values.js.map +1 -0
- package/lib-es/components/SearchFilter/helpers/get-filter-values.js +19 -0
- package/lib-es/components/SearchFilter/helpers/get-filter-values.js.map +1 -0
- package/lib-es/components/SearchFilter/helpers/index.js +5 -4
- package/lib-es/components/SearchFilter/helpers/index.js.map +1 -1
- package/lib-es/components/SearchFilter/index.js +2 -2
- package/lib-es/components/SearchFilter/index.js.map +1 -1
- package/lib-es/components/SearchFilter/searchFilterReducer.js +26 -0
- package/lib-es/components/SearchFilter/searchFilterReducer.js.map +1 -0
- package/lib-es/components/SearchFilterSort/SearchFilterSort.js +26 -10
- package/lib-es/components/SearchFilterSort/SearchFilterSort.js.map +1 -1
- package/lib-es/components/SearchFilterSort/helpers/handle-sort-update.js +21 -4
- package/lib-es/components/SearchFilterSort/helpers/handle-sort-update.js.map +1 -1
- package/lib-es/components/SearchFilterSort/helpers/update-sort.js +8 -4
- package/lib-es/components/SearchFilterSort/helpers/update-sort.js.map +1 -1
- package/lib-es/helpers/build-inherited-filters.js +2 -0
- package/lib-es/helpers/build-inherited-filters.js.map +1 -1
- package/lib-es/helpers/build-props-query.js +4 -2
- package/lib-es/helpers/build-props-query.js.map +1 -1
- package/lib-es/helpers/build-query-key.js +7 -0
- package/lib-es/helpers/build-query-key.js.map +1 -0
- package/lib-es/helpers/build-set-filters.js +5 -1
- package/lib-es/helpers/build-set-filters.js.map +1 -1
- package/lib-es/helpers/get-entities-with-banner.js +9 -2
- package/lib-es/helpers/get-entities-with-banner.js.map +1 -1
- package/lib-es/helpers/get-query-filters.js +6 -8
- package/lib-es/helpers/get-query-filters.js.map +1 -1
- package/lib-es/helpers/get-query-props.js +10 -2
- package/lib-es/helpers/get-query-props.js.map +1 -1
- package/lib-es/helpers/get-wrapped-value-with-link.js +2 -2
- package/lib-es/helpers/get-wrapped-value-with-link.js.map +1 -1
- package/lib-es/helpers/index.js +2 -0
- package/lib-es/helpers/index.js.map +1 -1
- package/lib-es/helpers/parse-props-to-display.js +12 -9
- package/lib-es/helpers/parse-props-to-display.js.map +1 -1
- package/lib-es/helpers/process-data-summary-value.js +36 -0
- package/lib-es/helpers/process-data-summary-value.js.map +1 -0
- package/package.json +10 -10
- package/src/components/Button.js +2 -1
- package/src/components/Card/CardsRender.js +27 -7
- package/src/components/Card/helpers/get-updated-items-to-display.js +32 -0
- package/src/components/Card/helpers/index.js +1 -0
- package/src/components/CarouselWrapper/SmoothScrollCarousel.js +2 -2
- package/src/components/Code/Code.js +7 -3
- package/src/components/DataSummary/helpers/build-loop-props-content.js +7 -3
- package/src/components/DataSummary/helpers/build-props-to-display-with-content.js +6 -3
- package/src/components/DataSummary/helpers/get-link-to-published-content.js +4 -1
- package/src/components/List/ListFactory.js +25 -15
- package/src/components/List/helpers/get-list-query.js +28 -0
- package/src/components/List/helpers/get-list-specific-search-filter.js +10 -0
- package/src/components/List/helpers/index.js +2 -0
- package/src/components/List/helpers/strip-query-key.js +6 -0
- package/src/components/SearchContent/SearchContent.js +8 -8
- package/src/components/SearchFilter/SearchFilter/SearchFilter.js +21 -18
- package/src/components/SearchFilter/SearchFilterContainer.js +59 -67
- package/src/components/SearchFilter/helpers/build-filters-query.js +9 -1
- package/src/components/SearchFilter/helpers/build-new-url.js +8 -0
- package/src/components/SearchFilter/helpers/build-url-query.js +33 -0
- package/src/components/SearchFilter/helpers/get-filter-ranges-and-checkboxes-values.js +17 -0
- package/src/components/SearchFilter/helpers/get-filter-values.js +21 -0
- package/src/components/SearchFilter/helpers/index.js +9 -7
- package/src/components/SearchFilter/index.js +2 -2
- package/src/components/SearchFilter/searchFilterReducer.js +15 -0
- package/src/components/SearchFilterSort/SearchFilterSort.js +18 -8
- package/src/components/SearchFilterSort/helpers/handle-sort-update.js +14 -5
- package/src/components/SearchFilterSort/helpers/update-sort.js +7 -3
- package/src/helpers/build-inherited-filters.js +3 -1
- package/src/helpers/build-props-query.js +4 -2
- package/src/helpers/build-query-key.js +7 -0
- package/src/helpers/build-set-filters.js +2 -1
- package/src/helpers/get-entities-with-banner.js +3 -2
- package/src/helpers/get-query-filters.js +4 -4
- package/src/helpers/get-query-props.js +12 -4
- package/src/helpers/get-wrapped-value-with-link.js +6 -3
- package/src/helpers/index.js +2 -0
- package/src/helpers/parse-props-to-display.js +25 -21
- package/src/helpers/process-data-summary-value.js +22 -0
- package/tests/helpers/mocks.js +3 -5
- package/tests/unit/src/components/Card/helpers/get-updated-items-to-display.test.js +72 -0
- package/tests/unit/src/components/Code/Code.test.js +5 -0
- package/tests/unit/src/components/Code/__snapshots__/Code.test.js.snap +8 -0
- package/tests/unit/src/components/DataSummary/helpers/build-loop-props-content.test.js +50 -0
- package/tests/unit/src/components/DataSummary/helpers/get-link-to-published-content.test.js +21 -0
- package/tests/unit/src/components/PlaceholderIcon/__snapshots__/index.test.js.snap +72 -0
- package/tests/unit/src/components/PlaceholderIcon/index.test.js +20 -0
- package/tests/unit/src/components/SearchFilter/__snapshots__/SearchFilterContainer.test.js.snap +1 -7
- package/tests/unit/src/components/SearchFilter/helpers/build-new-query.test.js +10 -10
- package/tests/unit/src/components/SearchFilter/helpers/build-query.test.js +24 -7
- package/tests/unit/src/components/SearchFilter/helpers/get-initial-filter-values.test.js +10 -10
- package/tests/unit/src/components/SearchFilterSort/SearchFilterSort.test.js +4 -1
- package/tests/unit/src/components/SearchFilterSort/helpers/handle-sort-update.test.js +26 -19
- package/tests/unit/src/components/SearchFilterSort/helpers/update-sort.test.js +10 -1
- package/tests/unit/src/helpers/__snapshots__/get-wrapped-value-with-link.test.js.snap +18 -0
- package/tests/unit/src/helpers/build-props-query.test.js +25 -0
- package/tests/unit/src/helpers/get-wrapped-value-with-link.test.js +2 -2
- package/tests/unit/src/helpers/parse-props-to-display.test.js +4 -0
- package/tests/unit/src/helpers/prcoess-data-summary-value.test.js +52 -0
- package/lib/components/SearchFilter/helpers/build-new-query.js +0 -15
- package/lib/components/SearchFilter/helpers/build-new-query.js.map +0 -1
- package/lib/components/SearchFilter/helpers/build-query.js +0 -37
- package/lib/components/SearchFilter/helpers/build-query.js.map +0 -1
- package/lib/components/SearchFilter/helpers/get-initial-filter-values.js +0 -43
- package/lib/components/SearchFilter/helpers/get-initial-filter-values.js.map +0 -1
- package/lib-es/components/SearchFilter/helpers/build-new-query.js +0 -6
- package/lib-es/components/SearchFilter/helpers/build-new-query.js.map +0 -1
- package/lib-es/components/SearchFilter/helpers/build-query.js +0 -23
- package/lib-es/components/SearchFilter/helpers/build-query.js.map +0 -1
- package/lib-es/components/SearchFilter/helpers/get-initial-filter-values.js +0 -26
- package/lib-es/components/SearchFilter/helpers/get-initial-filter-values.js.map +0 -1
- package/src/components/SearchFilter/helpers/build-new-query.js +0 -6
- package/src/components/SearchFilter/helpers/build-query.js +0 -26
- package/src/components/SearchFilter/helpers/get-initial-filter-values.js +0 -30
package/src/helpers/index.js
CHANGED
|
@@ -51,3 +51,5 @@ export { default as getParsedPropValues } from './get-parsed-prop-values';
|
|
|
51
51
|
export { default as getSanitizedPropValues } from './get-sanitized-prop-values';
|
|
52
52
|
export { default as appendImages } from './append-images';
|
|
53
53
|
export { default as parseTextBlock } from './parse-TextBlock';
|
|
54
|
+
export { default as processDataSummaryValue } from './process-data-summary-value';
|
|
55
|
+
export { default as buildQueryKey } from './build-query-key';
|
|
@@ -4,35 +4,39 @@ import isObject from './is-object';
|
|
|
4
4
|
import getParsedPropValues from './get-parsed-prop-values';
|
|
5
5
|
import getSanitizedPropValues from './get-sanitized-prop-values';
|
|
6
6
|
import { BOLD_TAG, BLANK_SPACE_UNICODE_STRING } from '../constants';
|
|
7
|
+
import processDataSummaryValue from './process-data-summary-value';
|
|
7
8
|
|
|
8
9
|
// TODO this helper should be removed if database is wiped clean and all elements change to new props struc
|
|
9
10
|
const parsePropsToDisplay = (props = {}, propsToDisplay = []) => {
|
|
10
11
|
if (!isObject(propsToDisplay[0])) return at(props, propsToDisplay).filter(Boolean);
|
|
11
12
|
|
|
12
|
-
return propsToDisplay.map(
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
return propsToDisplay.map((options, currentIndex) => {
|
|
14
|
+
const { bold, propertiesToDisplay, prefix, suffix, shouldStrip, enableLink } = options;
|
|
15
|
+
const Wrapper = bold ? BOLD_TAG : Fragment;
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
const parsedPropValues = getParsedPropValues({
|
|
18
|
+
propertiesToDisplay,
|
|
19
|
+
props,
|
|
20
|
+
enableLink,
|
|
21
|
+
shouldStrip
|
|
22
|
+
});
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
const sanitizedPropValues = getSanitizedPropValues(parsedPropValues);
|
|
25
|
+
if (!sanitizedPropValues || !sanitizedPropValues.length) return null;
|
|
26
|
+
const stringEndBlank =
|
|
27
|
+
currentIndex + 1 === propsToDisplay.length ? '' : BLANK_SPACE_UNICODE_STRING;
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
29
|
+
const processedValue = Array.isArray(sanitizedPropValues)
|
|
30
|
+
? sanitizedPropValues.map(value => processDataSummaryValue(value, options))
|
|
31
|
+
: processDataSummaryValue(sanitizedPropValues, options);
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<Wrapper>
|
|
35
|
+
{prefix} {processedValue} {suffix}
|
|
36
|
+
{stringEndBlank}
|
|
37
|
+
</Wrapper>
|
|
38
|
+
);
|
|
39
|
+
});
|
|
36
40
|
};
|
|
37
41
|
|
|
38
42
|
export default parsePropsToDisplay;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import components from '../components';
|
|
3
|
+
|
|
4
|
+
const { code: Code } = components;
|
|
5
|
+
|
|
6
|
+
const renderCode = value => <Code code={value} disableWrapper />;
|
|
7
|
+
|
|
8
|
+
const processDataSummaryValue = (objPropValue, { isHtml }) => {
|
|
9
|
+
let pValue = objPropValue;
|
|
10
|
+
if (isHtml) {
|
|
11
|
+
pValue = Array.isArray(objPropValue)
|
|
12
|
+
? objPropValue.map(({ keyField, [keyField]: value, ...otherProps }) => ({
|
|
13
|
+
[keyField]: renderCode(value),
|
|
14
|
+
keyField,
|
|
15
|
+
...otherProps
|
|
16
|
+
}))
|
|
17
|
+
: renderCode(objPropValue);
|
|
18
|
+
}
|
|
19
|
+
return pValue;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default processDataSummaryValue;
|
package/tests/helpers/mocks.js
CHANGED
|
@@ -1139,11 +1139,9 @@ const MOCKED_PROPS_FILTERS_LIST = {
|
|
|
1139
1139
|
};
|
|
1140
1140
|
|
|
1141
1141
|
const MOCKED_PROPS_SEARCH_FILTER = {
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
push: () => {}
|
|
1146
|
-
},
|
|
1142
|
+
listComponentName: '',
|
|
1143
|
+
filterData: {},
|
|
1144
|
+
asPath: 'somePath',
|
|
1147
1145
|
parent: {
|
|
1148
1146
|
itemEntity: 'published_page'
|
|
1149
1147
|
},
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
2
|
+
import getUpdatedItemsToDisplay from '../../../../../../src/components/Card/helpers/get-updated-items-to-display';
|
|
3
|
+
|
|
4
|
+
const mockedProps = {
|
|
5
|
+
itemsToDisplay: [
|
|
6
|
+
{
|
|
7
|
+
displayItems: ['54321']
|
|
8
|
+
}
|
|
9
|
+
],
|
|
10
|
+
parentEntityData: {
|
|
11
|
+
authorIds: ['12345']
|
|
12
|
+
},
|
|
13
|
+
parentSchema: {
|
|
14
|
+
properties: {
|
|
15
|
+
authorIds: {
|
|
16
|
+
relation: {
|
|
17
|
+
entityIdentifier: 'author'
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
inheritedFilters: ['id/author']
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
describe('getUpdatedItemsToDisplay helper function', () => {
|
|
26
|
+
it('should return empty array if no props passed', () => {
|
|
27
|
+
const emptyArray = getUpdatedItemsToDisplay({});
|
|
28
|
+
expect(emptyArray).toEqual([]);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('should return old itemsToDisplay itemsToDisplay if no idProp match, no parentSchema or no parentEntityData', () => {
|
|
32
|
+
const onlyItemsToDisplayPassed = getUpdatedItemsToDisplay({
|
|
33
|
+
itemsToDisplay: mockedProps.itemsToDisplay
|
|
34
|
+
});
|
|
35
|
+
const noIdPropMatch = getUpdatedItemsToDisplay({
|
|
36
|
+
...mockedProps,
|
|
37
|
+
inheritedFilters: ['notid/author']
|
|
38
|
+
});
|
|
39
|
+
const noParentSchema = getUpdatedItemsToDisplay({
|
|
40
|
+
...mockedProps,
|
|
41
|
+
parentSchema: null
|
|
42
|
+
});
|
|
43
|
+
const noParentEntityData = getUpdatedItemsToDisplay({
|
|
44
|
+
...mockedProps,
|
|
45
|
+
parentEntityData: null
|
|
46
|
+
});
|
|
47
|
+
expect(onlyItemsToDisplayPassed).toEqual(mockedProps.itemsToDisplay);
|
|
48
|
+
expect(noIdPropMatch).toEqual(mockedProps.itemsToDisplay);
|
|
49
|
+
expect(noParentSchema).toEqual(mockedProps.itemsToDisplay);
|
|
50
|
+
expect(noParentEntityData).toEqual(mockedProps.itemsToDisplay);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('should return old itemsToDisplay if parentSchema has no propMatch with idProp entity', () => {
|
|
54
|
+
const sameItemsToDisplay = getUpdatedItemsToDisplay({
|
|
55
|
+
...mockedProps,
|
|
56
|
+
inheritedFilters: ['id/noentitymatch']
|
|
57
|
+
});
|
|
58
|
+
expect(sameItemsToDisplay).toEqual(mockedProps.itemsToDisplay);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('should return updated itemsToDisplay otherwise', () => {
|
|
62
|
+
const sameItemsToDisplay = getUpdatedItemsToDisplay({
|
|
63
|
+
...mockedProps
|
|
64
|
+
});
|
|
65
|
+
expect(sameItemsToDisplay).toEqual([
|
|
66
|
+
...mockedProps.itemsToDisplay,
|
|
67
|
+
{
|
|
68
|
+
displayItems: ['12345']
|
|
69
|
+
}
|
|
70
|
+
]);
|
|
71
|
+
});
|
|
72
|
+
});
|
|
@@ -23,6 +23,11 @@ describe('Code component', () => {
|
|
|
23
23
|
expect(asFragment()).toMatchSnapshot();
|
|
24
24
|
});
|
|
25
25
|
|
|
26
|
+
it('should not render wrapper', () => {
|
|
27
|
+
const { asFragment } = render(Code, { ...props, disableWrapper: true });
|
|
28
|
+
expect(asFragment()).toMatchSnapshot();
|
|
29
|
+
});
|
|
30
|
+
|
|
26
31
|
it('should return null if there is not embed code', () => {
|
|
27
32
|
const { container } = render(Code, {});
|
|
28
33
|
expect(container.innerHTML).toBe('');
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import '@testing-library/jest-dom/extend-expect';
|
|
2
2
|
import buildLoopPropsContent from '../../../../../../src/components/DataSummary/helpers/build-loop-props-content';
|
|
3
3
|
import { mockedLoopProps, mockedPropsToDisplay, mockedData, mockedResults } from './mocks';
|
|
4
|
+
import processDataSummaryValue from '../../../../../../src/helpers/process-data-summary-value';
|
|
5
|
+
|
|
6
|
+
jest.mock('../../../../../../src/helpers/process-data-summary-value', () =>
|
|
7
|
+
jest.fn(value => value)
|
|
8
|
+
);
|
|
4
9
|
|
|
5
10
|
describe('buildLoopPropsContent helper function', () => {
|
|
6
11
|
const noParamsPassed = buildLoopPropsContent();
|
|
@@ -41,6 +46,10 @@ describe('buildLoopPropsContent helper function', () => {
|
|
|
41
46
|
expect(noDataPassed).toEqual([]);
|
|
42
47
|
});
|
|
43
48
|
|
|
49
|
+
it('should call processDataSummaryValue', () => {
|
|
50
|
+
expect(processDataSummaryValue).toHaveBeenCalledWith('pre data name', mockedPropsToDisplay[0]);
|
|
51
|
+
});
|
|
52
|
+
|
|
44
53
|
it('should return regular dataSummary content if no loopable values are found', () => {
|
|
45
54
|
expect(withNoLoopValues).toEqual(mockedResults[0]);
|
|
46
55
|
expect(withNoLoopableValues).toEqual(mockedResults[1]);
|
|
@@ -81,4 +90,45 @@ describe('buildLoopPropsContent helper function', () => {
|
|
|
81
90
|
});
|
|
82
91
|
expect.hasAssertions();
|
|
83
92
|
});
|
|
93
|
+
|
|
94
|
+
it('should nested items with urls', () => {
|
|
95
|
+
const data = {
|
|
96
|
+
nestedLoopProp: [
|
|
97
|
+
{
|
|
98
|
+
nestedValue: 'abc',
|
|
99
|
+
url: 'http://blazecms.app/abc'
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
nestedValue: '123',
|
|
103
|
+
url: 'http://blazecms.app/123'
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
nestedValue: 'no url',
|
|
107
|
+
url: null
|
|
108
|
+
}
|
|
109
|
+
]
|
|
110
|
+
};
|
|
111
|
+
const withUrl = buildLoopPropsContent(
|
|
112
|
+
mockedLoopProps,
|
|
113
|
+
[
|
|
114
|
+
{
|
|
115
|
+
bold: false,
|
|
116
|
+
enableLink: true,
|
|
117
|
+
label: '',
|
|
118
|
+
modifier: '',
|
|
119
|
+
prefix: '',
|
|
120
|
+
propertiesToDisplay: ['nestedLoopProp.nestedValue'],
|
|
121
|
+
shouldStrip: true
|
|
122
|
+
}
|
|
123
|
+
],
|
|
124
|
+
0,
|
|
125
|
+
data
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
withUrl.forEach(([, value, url], index) => {
|
|
129
|
+
expect(value).toEqual(data.nestedLoopProp[index].nestedValue);
|
|
130
|
+
expect(url).toEqual(data.nestedLoopProp[index].url || '');
|
|
131
|
+
});
|
|
132
|
+
expect.hasAssertions();
|
|
133
|
+
});
|
|
84
134
|
});
|
|
@@ -38,4 +38,25 @@ describe('get link to published content', () => {
|
|
|
38
38
|
const result = getLinkToPublishedContent(publishedKey, props);
|
|
39
39
|
expect(result).toEqual('');
|
|
40
40
|
});
|
|
41
|
+
|
|
42
|
+
it('should return url from the currentValue', () => {
|
|
43
|
+
const currentValue = { url: 'currentValueUrl' };
|
|
44
|
+
const props = { content: [content] };
|
|
45
|
+
const result = getLinkToPublishedContent(publishedKey, props, currentValue);
|
|
46
|
+
expect(result).toEqual(currentValue.url);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('should return url from the currentValue even if falsey', () => {
|
|
50
|
+
const currentValue = { url: null };
|
|
51
|
+
const props = { content: [content] };
|
|
52
|
+
const result = getLinkToPublishedContent(publishedKey, props, currentValue);
|
|
53
|
+
expect(result).toEqual(currentValue.url);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('should not return url from the currentValue if not set', () => {
|
|
57
|
+
const currentValue = {};
|
|
58
|
+
const props = { content: [content] };
|
|
59
|
+
const result = getLinkToPublishedContent(publishedKey, props, currentValue);
|
|
60
|
+
expect(result).toEqual(content.url);
|
|
61
|
+
});
|
|
41
62
|
});
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Placeholder component should render PlaceholderIcon 1`] = `
|
|
4
|
+
<DocumentFragment>
|
|
5
|
+
<div
|
|
6
|
+
class="editor-view__placeholder"
|
|
7
|
+
data-testid="placeholder-icon"
|
|
8
|
+
>
|
|
9
|
+
<svg
|
|
10
|
+
height="25px"
|
|
11
|
+
version="1.1"
|
|
12
|
+
viewBox="0 0 16 16"
|
|
13
|
+
width="25px"
|
|
14
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
15
|
+
>
|
|
16
|
+
<title>
|
|
17
|
+
card
|
|
18
|
+
</title>
|
|
19
|
+
<g
|
|
20
|
+
fill="none"
|
|
21
|
+
fill-rule="evenodd"
|
|
22
|
+
id="Icons"
|
|
23
|
+
stroke="none"
|
|
24
|
+
stroke-width="1"
|
|
25
|
+
>
|
|
26
|
+
<g
|
|
27
|
+
id="card"
|
|
28
|
+
transform="translate(-261.000000, -216.000000)"
|
|
29
|
+
>
|
|
30
|
+
<g
|
|
31
|
+
transform="translate(261.000000, 216.000000)"
|
|
32
|
+
>
|
|
33
|
+
<path
|
|
34
|
+
d="M15,1 L15,9.53124644 L14.998,9.531 L14.9986024,7.67959976 L11.4210663,4.62547112 L7.4590683,8.08893259 C7.08560181,8.77082265 6.07591438,8.77082265 5.51715851,8.27688661 L3.50145721,6.5 L1,8.77 L1,7.323 L2.58011188,5.9054667 C3.10161735,5.44445974 3.91799869,5.41372594 4.47882094,5.81326531 L4.59488493,5.9054667 L6.4402744,7.56106172 L10.4252459,3.98593625 C10.9840017,3.49200022 11.8812631,3.49200022 12.4400189,3.98593625 L14.9986024,6.28137475 L14.998,1 Z M6.14778213,2.60821539 C6.69719001,2.60821539 7.14257312,3.0379169 7.14257312,3.56798059 C7.14257312,4.09804429 6.69719002,4.52774581 6.14778213,4.52774581 C5.88422964,4.52580316 5.6316942,4.42547921 5.44313851,4.24781429 C5.25594548,4.06784498 5.15142164,3.82293899 5.15297371,3.56798059 C5.15297371,3.0379169 5.59837425,2.60821539 6.14778213,2.60821539 Z"
|
|
35
|
+
fill="#63779C"
|
|
36
|
+
fill-rule="nonzero"
|
|
37
|
+
id="Combined-Shape"
|
|
38
|
+
/>
|
|
39
|
+
<path
|
|
40
|
+
d="M3,13 C3,12.7238576 3.22385763,12.5 3.5,12.5 L12.5,12.5 C12.7761424,12.5 13,12.7238576 13,13 C13,13.2761424 12.7761424,13.5 12.5,13.5 L3.5,13.5 C3.22385763,13.5 3,13.2761424 3,13 Z"
|
|
41
|
+
fill="#899BBC"
|
|
42
|
+
fill-rule="nonzero"
|
|
43
|
+
id="Shape"
|
|
44
|
+
/>
|
|
45
|
+
<rect
|
|
46
|
+
height="15"
|
|
47
|
+
id="Rectangle"
|
|
48
|
+
rx="2"
|
|
49
|
+
stroke="#899BBC"
|
|
50
|
+
width="15"
|
|
51
|
+
x="0.5"
|
|
52
|
+
y="0.5"
|
|
53
|
+
/>
|
|
54
|
+
<line
|
|
55
|
+
id="Line-2"
|
|
56
|
+
stroke="#63779C"
|
|
57
|
+
stroke-linecap="square"
|
|
58
|
+
x1="0.5"
|
|
59
|
+
x2="15.5"
|
|
60
|
+
y1="10.5"
|
|
61
|
+
y2="10.5"
|
|
62
|
+
/>
|
|
63
|
+
</g>
|
|
64
|
+
</g>
|
|
65
|
+
</g>
|
|
66
|
+
</svg>
|
|
67
|
+
<span>
|
|
68
|
+
card
|
|
69
|
+
</span>
|
|
70
|
+
</div>
|
|
71
|
+
</DocumentFragment>
|
|
72
|
+
`;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jest-environment jsdom
|
|
3
|
+
*/
|
|
4
|
+
import { render } from '@blaze-cms/tools/test-helpers/test-functions';
|
|
5
|
+
|
|
6
|
+
import PlaceholderIcon from '../../../../../../blaze-plugin-page-builder-ui/src/components/EditorView/PlaceholderIcon';
|
|
7
|
+
import { CardIcon } from '../../../../../../blaze-plugin-page-builder-ui/src/components/EditorView/Icons';
|
|
8
|
+
|
|
9
|
+
const mockedProps = {
|
|
10
|
+
type: 'card',
|
|
11
|
+
icon: CardIcon
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
describe('Placeholder component', () => {
|
|
15
|
+
it('should render PlaceholderIcon', () => {
|
|
16
|
+
const { asFragment, getByTestId } = render(PlaceholderIcon, mockedProps);
|
|
17
|
+
expect(getByTestId('placeholder-icon')).toBeDefined();
|
|
18
|
+
expect(asFragment()).toMatchSnapshot();
|
|
19
|
+
});
|
|
20
|
+
});
|
package/tests/unit/src/components/SearchFilter/__snapshots__/SearchFilterContainer.test.js.snap
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`SearchFilter container should match snapshot 1`] =
|
|
4
|
-
<DocumentFragment>
|
|
5
|
-
<div>
|
|
6
|
-
Mocked component
|
|
7
|
-
</div>
|
|
8
|
-
</DocumentFragment>
|
|
9
|
-
`;
|
|
3
|
+
exports[`SearchFilter container should match snapshot 1`] = `<DocumentFragment />`;
|
|
10
4
|
|
|
11
5
|
exports[`SearchFilter container should return null if no filters are passed 1`] = `<DocumentFragment />`;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import buildNewUrl from '../../../../../../src/components/SearchFilter/helpers/build-new-url';
|
|
2
|
+
// url, currentUrl, queryParams, hashBit
|
|
3
3
|
const mockedProps = [
|
|
4
4
|
['', 'current-as-path', 'some=query¶ms=value'],
|
|
5
5
|
['urlFromProps', '', 'other=query&with=value'],
|
|
6
|
-
['urlFromProps', 'not=used', 'another=query&withthis=value',
|
|
6
|
+
['urlFromProps', 'not=used', 'another=query&withthis=value'],
|
|
7
|
+
['urlFromProps', 'not=used', 'another=query&withthis=value', 'this-is-content']
|
|
7
8
|
];
|
|
8
9
|
|
|
9
|
-
describe('
|
|
10
|
-
const simpleExample =
|
|
11
|
-
const withPropsUrl =
|
|
12
|
-
const
|
|
10
|
+
describe('buildNewUrl helper function', () => {
|
|
11
|
+
const simpleExample = buildNewUrl(...mockedProps[0]);
|
|
12
|
+
const withPropsUrl = buildNewUrl(...mockedProps[1]);
|
|
13
|
+
const withHash = buildNewUrl(...mockedProps[3]);
|
|
13
14
|
|
|
14
15
|
it('should always return a string', () => {
|
|
15
16
|
expect(typeof simpleExample).toBe('string');
|
|
16
17
|
expect(typeof withPropsUrl).toBe('string');
|
|
17
|
-
expect(typeof withSort).toBe('string');
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
it('should return new url using asPath and queryParams passed', () => {
|
|
@@ -25,7 +25,7 @@ describe('buildNewQuery helper function', () => {
|
|
|
25
25
|
expect(withPropsUrl).toEqual('urlFromProps?other=query&with=value');
|
|
26
26
|
});
|
|
27
27
|
|
|
28
|
-
it('should return new url with
|
|
29
|
-
expect(
|
|
28
|
+
it('should return new url with hash if passed', () => {
|
|
29
|
+
expect(withHash).toEqual('urlFromProps?another=query&withthis=value#this-is-content');
|
|
30
30
|
});
|
|
31
31
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import buildUrlQuery from '../../../../../../src/components/SearchFilter/helpers/build-url-query';
|
|
2
2
|
import { SEARCH_TERM } from '../../../../../../src/components/SearchFilter/constants';
|
|
3
3
|
|
|
4
4
|
const mockedProps = [
|
|
@@ -10,10 +10,15 @@ const mockedProps = [
|
|
|
10
10
|
]
|
|
11
11
|
];
|
|
12
12
|
|
|
13
|
-
describe('
|
|
14
|
-
const simpleExample =
|
|
15
|
-
const withTextSearch =
|
|
16
|
-
const withSearchAndRange =
|
|
13
|
+
describe('buildUrlQuery helper function', () => {
|
|
14
|
+
const simpleExample = buildUrlQuery(...mockedProps[0]);
|
|
15
|
+
const withTextSearch = buildUrlQuery(...mockedProps[1]);
|
|
16
|
+
const withSearchAndRange = buildUrlQuery(...mockedProps[2]);
|
|
17
|
+
const withListName = buildUrlQuery(...mockedProps[2], 'listName');
|
|
18
|
+
const withListNameAndOtherQueryBits = buildUrlQuery(...mockedProps[2], 'listName', {
|
|
19
|
+
sort: 'asc',
|
|
20
|
+
anotherQuery: '123'
|
|
21
|
+
});
|
|
17
22
|
|
|
18
23
|
it('should always return a string', () => {
|
|
19
24
|
expect(typeof simpleExample).toBe('string');
|
|
@@ -24,10 +29,22 @@ describe('buildQuery helper function', () => {
|
|
|
24
29
|
});
|
|
25
30
|
|
|
26
31
|
it('should return new query string with search term if available', () => {
|
|
27
|
-
expect(withTextSearch).toEqual('search_term=new
|
|
32
|
+
expect(withTextSearch).toEqual('search_term=new search value');
|
|
28
33
|
});
|
|
29
34
|
|
|
30
35
|
it('should return new query string with search text and all other available query values', () => {
|
|
31
|
-
expect(withSearchAndRange).toEqual('search_term=new
|
|
36
|
+
expect(withSearchAndRange).toEqual('search_term=new search value&rangeFilter=2-10');
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('should return new query string listName if passed', () => {
|
|
40
|
+
expect(withListName).toEqual(
|
|
41
|
+
'pb[listName][search_term]=new search value&pb[listName][rangeFilter]=2-10'
|
|
42
|
+
);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('should return new query string with unaltered bits from other query', () => {
|
|
46
|
+
expect(withListNameAndOtherQueryBits).toEqual(
|
|
47
|
+
'pb[listName][search_term]=new search value&pb[listName][rangeFilter]=2-10&sort=asc&anotherQuery=123'
|
|
48
|
+
);
|
|
32
49
|
});
|
|
33
50
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import getFilterValues from '../../../../../../src/components/SearchFilter/helpers/get-filter-values';
|
|
2
2
|
import { SEARCH_TERM } from '../../../../../../src/components/SearchFilter/constants';
|
|
3
3
|
|
|
4
4
|
const filters = [
|
|
@@ -16,25 +16,24 @@ const mockedProps = [
|
|
|
16
16
|
[{ rangeFilter: { min: 5, max: 10 }, checkboxFilter: {}, emptySelect: {} }, filters, query]
|
|
17
17
|
];
|
|
18
18
|
|
|
19
|
-
describe('
|
|
20
|
-
const withNoValue =
|
|
21
|
-
const withValues =
|
|
19
|
+
describe('getFilterValues helper function', () => {
|
|
20
|
+
const withNoValue = getFilterValues(...mockedProps[0]);
|
|
21
|
+
const withValues = getFilterValues(...mockedProps[1]);
|
|
22
22
|
|
|
23
23
|
it('should return init filter values based on query and filterData', () => {
|
|
24
|
-
expect(withNoValue).toEqual({
|
|
24
|
+
expect(withNoValue).toEqual({ search_term: '', dataNotSet: false });
|
|
25
25
|
expect(withValues).toEqual({
|
|
26
|
-
dataNotSet: false,
|
|
27
26
|
search_term: query[SEARCH_TERM],
|
|
28
27
|
rangeFilter: { max: 10, maxValue: 8, min: 5, minValue: 7, step: 1 },
|
|
29
28
|
checkboxFilter: ['check1', 'check2'],
|
|
30
|
-
emptySelect: null
|
|
29
|
+
emptySelect: null,
|
|
30
|
+
dataNotSet: false
|
|
31
31
|
});
|
|
32
32
|
});
|
|
33
33
|
|
|
34
34
|
it('should return init filter values without filterData', () => {
|
|
35
|
-
const withNoData =
|
|
35
|
+
const withNoData = getFilterValues(null, filters, query);
|
|
36
36
|
expect(withNoData).toEqual({
|
|
37
|
-
dataNotSet: true,
|
|
38
37
|
search_term: query[SEARCH_TERM],
|
|
39
38
|
rangeFilter: {
|
|
40
39
|
max: 8,
|
|
@@ -44,7 +43,8 @@ describe('getInitialFilterValues helper function', () => {
|
|
|
44
43
|
step: 1
|
|
45
44
|
},
|
|
46
45
|
checkboxFilter: query.checkboxFilter,
|
|
47
|
-
emptySelect: null
|
|
46
|
+
emptySelect: null,
|
|
47
|
+
dataNotSet: true
|
|
48
48
|
});
|
|
49
49
|
});
|
|
50
50
|
});
|
|
@@ -5,8 +5,11 @@ import { render } from '@blaze-cms/tools/test-helpers/test-functions';
|
|
|
5
5
|
import '@testing-library/jest-dom/extend-expect';
|
|
6
6
|
import SearchFilterSort from '../../../../../src/components/SearchFilterSort/SearchFilterSort';
|
|
7
7
|
|
|
8
|
+
jest.mock('next/router', () => ({
|
|
9
|
+
useRouter: jest.fn(() => ({ asPath: 'test-url' }))
|
|
10
|
+
}));
|
|
11
|
+
|
|
8
12
|
const props = {
|
|
9
|
-
router: { asPath: 'some-path' },
|
|
10
13
|
filters: [{ label: 'label1', propsToDisplay: ['name'], sort: 'ascending' }],
|
|
11
14
|
label: 'someLabel',
|
|
12
15
|
id: '123456'
|
|
@@ -1,43 +1,50 @@
|
|
|
1
1
|
import handleSortUpdate from '../../../../../../src/components/SearchFilterSort/helpers/handle-sort-update';
|
|
2
2
|
|
|
3
3
|
const routerPushResultMock = () => ({ then: jest.fn() });
|
|
4
|
+
// router, value, query, url, selectLabel, listComponentName
|
|
4
5
|
const mockedProps = [
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
'
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
'name:
|
|
16
|
-
|
|
17
|
-
'
|
|
18
|
-
|
|
19
|
-
|
|
6
|
+
{
|
|
7
|
+
router: { asPath: 'asPath', push: jest.fn(routerPushResultMock) },
|
|
8
|
+
value: 'defaultOption',
|
|
9
|
+
query: {},
|
|
10
|
+
url: 'url',
|
|
11
|
+
selectLabel: 'defaultOption'
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
router: { asPath: 'asPath', push: jest.fn(routerPushResultMock) },
|
|
15
|
+
value: 'defaultOption',
|
|
16
|
+
query: { sort: 'asc', sortby: 'name', type: 'big' },
|
|
17
|
+
url: 'baseurl',
|
|
18
|
+
selectLabel: 'defaultOption'
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
router: { asPath: 'asPath', push: jest.fn(routerPushResultMock) },
|
|
22
|
+
value: 'name:desc',
|
|
23
|
+
query: { someOther: 'ott' },
|
|
24
|
+
url: 'url',
|
|
25
|
+
selectLabel: 'defaultOption'
|
|
26
|
+
}
|
|
20
27
|
];
|
|
21
28
|
|
|
22
29
|
describe('handleSortUpdate helper function', () => {
|
|
23
|
-
mockedProps.forEach(props => handleSortUpdate(...props));
|
|
30
|
+
mockedProps.forEach(props => handleSortUpdate({ ...props }));
|
|
24
31
|
|
|
25
32
|
it('should navigate to url with no sort if default value is selected', () => {
|
|
26
|
-
expect(mockedProps[0]
|
|
33
|
+
expect(mockedProps[0].router.push).toHaveBeenLastCalledWith('/Resolver', 'url', {
|
|
27
34
|
shallow: true,
|
|
28
35
|
scroll: false
|
|
29
36
|
});
|
|
30
37
|
});
|
|
31
38
|
|
|
32
39
|
it('should navigate to url with no sort with previous querys if default value is selected', () => {
|
|
33
|
-
expect(mockedProps[1]
|
|
40
|
+
expect(mockedProps[1].router.push).toHaveBeenLastCalledWith('/Resolver', 'baseurl?type=big', {
|
|
34
41
|
shallow: true,
|
|
35
42
|
scroll: false
|
|
36
43
|
});
|
|
37
44
|
});
|
|
38
45
|
|
|
39
46
|
it('should navigate to url with new sort if selected', () => {
|
|
40
|
-
expect(mockedProps[2]
|
|
47
|
+
expect(mockedProps[2].router.push).toHaveBeenLastCalledWith(
|
|
41
48
|
'/Resolver',
|
|
42
49
|
'url?someOther=ott&sort=desc&sortby=name',
|
|
43
50
|
{ shallow: true, scroll: false }
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import updateSort from '../../../../../../src/components/SearchFilterSort/helpers/update-sort';
|
|
2
2
|
|
|
3
|
-
const mockedProps = [
|
|
3
|
+
const mockedProps = [
|
|
4
|
+
['name:asc', {}, 'aurl'],
|
|
5
|
+
['name:asc', { other: '12', query2: 'an' }, 'aurl'],
|
|
6
|
+
['name:desc', { query1: 'aquery' }, 'theUrl', '#hashBit']
|
|
7
|
+
];
|
|
4
8
|
|
|
5
9
|
describe('updateSort helper function', () => {
|
|
6
10
|
const basicSort = updateSort(...mockedProps[0]);
|
|
7
11
|
const sortWithOtherQuerys = updateSort(...mockedProps[1]);
|
|
12
|
+
const sortWithhash = updateSort(...mockedProps[2]);
|
|
8
13
|
|
|
9
14
|
it('should return a parsed url based on the parameters passed', () => {
|
|
10
15
|
expect(basicSort).toEqual('aurl?sort=asc&sortby=name');
|
|
@@ -13,4 +18,8 @@ describe('updateSort helper function', () => {
|
|
|
13
18
|
it('should return a parsed url with extra query params if passed', () => {
|
|
14
19
|
expect(sortWithOtherQuerys).toEqual('aurl?other=12&query2=an&sort=asc&sortby=name');
|
|
15
20
|
});
|
|
21
|
+
|
|
22
|
+
it('should return a parsed url with extra query params and hash if passed', () => {
|
|
23
|
+
expect(sortWithhash).toEqual('theUrl?query1=aquery&sort=desc&sortby=name#hashBit');
|
|
24
|
+
});
|
|
16
25
|
});
|