@blaze-cms/react-page-builder 0.130.0-admin-updates.2 → 0.130.0-admin-updates.6
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 +25 -0
- 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 +3 -1
- 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/SearchContent/SearchContent.js +8 -6
- package/lib/components/SearchContent/SearchContent.js.map +1 -1
- package/lib/components/SearchFilter/SearchFilterContainer.js +2 -1
- package/lib/components/SearchFilter/SearchFilterContainer.js.map +1 -1
- package/lib/components/SearchFilter/helpers/build-new-query.js +3 -2
- package/lib/components/SearchFilter/helpers/build-new-query.js.map +1 -1
- package/lib/components/SearchFilterSort/helpers/handle-sort-update.js +5 -2
- package/lib/components/SearchFilterSort/helpers/handle-sort-update.js.map +1 -1
- package/lib/components/SearchFilterSort/helpers/update-sort.js +2 -1
- package/lib/components/SearchFilterSort/helpers/update-sort.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 +7 -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/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 +3 -1
- 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/SearchContent/SearchContent.js +8 -6
- package/lib-es/components/SearchContent/SearchContent.js.map +1 -1
- package/lib-es/components/SearchFilter/SearchFilterContainer.js +2 -1
- package/lib-es/components/SearchFilter/SearchFilterContainer.js.map +1 -1
- package/lib-es/components/SearchFilter/helpers/build-new-query.js +3 -2
- package/lib-es/components/SearchFilter/helpers/build-new-query.js.map +1 -1
- package/lib-es/components/SearchFilterSort/helpers/handle-sort-update.js +7 -2
- package/lib-es/components/SearchFilterSort/helpers/handle-sort-update.js.map +1 -1
- package/lib-es/components/SearchFilterSort/helpers/update-sort.js +2 -2
- package/lib-es/components/SearchFilterSort/helpers/update-sort.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 +1 -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 +3 -3
- package/src/components/Code/Code.js +7 -3
- package/src/components/DataSummary/helpers/build-loop-props-content.js +4 -1
- package/src/components/DataSummary/helpers/build-props-to-display-with-content.js +6 -3
- package/src/components/SearchContent/SearchContent.js +8 -6
- package/src/components/SearchFilter/SearchFilterContainer.js +2 -1
- package/src/components/SearchFilter/helpers/build-new-query.js +3 -2
- package/src/components/SearchFilterSort/helpers/handle-sort-update.js +7 -3
- package/src/components/SearchFilterSort/helpers/update-sort.js +2 -2
- package/src/helpers/get-wrapped-value-with-link.js +6 -3
- package/src/helpers/index.js +1 -0
- package/src/helpers/parse-props-to-display.js +25 -21
- package/src/helpers/process-data-summary-value.js +22 -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 +9 -0
- package/tests/unit/src/components/SearchFilter/helpers/build-new-query.test.js +15 -1
- package/tests/unit/src/components/SearchFilterSort/helpers/handle-sort-update.test.js +9 -3
- 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/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
|
@@ -2,16 +2,22 @@ import handleSortUpdate from '../../../../../../src/components/SearchFilterSort/
|
|
|
2
2
|
|
|
3
3
|
const routerPushResultMock = () => ({ then: jest.fn() });
|
|
4
4
|
const mockedProps = [
|
|
5
|
-
[{ push: jest.fn(routerPushResultMock) }, 'defaultOption', {}, 'url', 'defaultOption'],
|
|
6
5
|
[
|
|
7
|
-
{ push: jest.fn(routerPushResultMock) },
|
|
6
|
+
{ asPath: 'asPath', push: jest.fn(routerPushResultMock) },
|
|
7
|
+
'defaultOption',
|
|
8
|
+
{},
|
|
9
|
+
'url',
|
|
10
|
+
'defaultOption'
|
|
11
|
+
],
|
|
12
|
+
[
|
|
13
|
+
{ push: jest.fn(routerPushResultMock), asPath: 'asPath' },
|
|
8
14
|
'defaultOption',
|
|
9
15
|
{ sort: 'asc', sortby: 'name', type: 'big' },
|
|
10
16
|
'baseurl',
|
|
11
17
|
'defaultOption'
|
|
12
18
|
],
|
|
13
19
|
[
|
|
14
|
-
{ push: jest.fn(routerPushResultMock) },
|
|
20
|
+
{ push: jest.fn(routerPushResultMock), asPath: 'asPath' },
|
|
15
21
|
'name:desc',
|
|
16
22
|
{ someOther: 'ott' },
|
|
17
23
|
'url',
|
|
@@ -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
|
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`get wrapped value with link func should return array with correponding value and link 1`] = `
|
|
4
|
+
<React.Fragment>
|
|
5
|
+
<React.Fragment>
|
|
6
|
+
test-name
|
|
7
|
+
,
|
|
8
|
+
</React.Fragment>
|
|
9
|
+
|
|
10
|
+
</React.Fragment>
|
|
11
|
+
`;
|
|
12
|
+
|
|
13
|
+
exports[`get wrapped value with link func should return array with correponding value and link 2`] = `
|
|
14
|
+
<React.Fragment>
|
|
15
|
+
test-name2
|
|
16
|
+
|
|
17
|
+
</React.Fragment>
|
|
18
|
+
`;
|
|
@@ -33,7 +33,7 @@ describe('get wrapped value with link func', () => {
|
|
|
33
33
|
expect(resultWithArray).toHaveLength(2);
|
|
34
34
|
expect(resultWithArray[0].props.href).toEqual(link);
|
|
35
35
|
expect(resultWithArray[0].key).toEqual(`${keyPrefix}-0`);
|
|
36
|
-
expect(resultWithArray[0].props.children).
|
|
37
|
-
expect(resultWithArray[1]).
|
|
36
|
+
expect(resultWithArray[0].props.children).toMatchSnapshot();
|
|
37
|
+
expect(resultWithArray[1]).toMatchSnapshot();
|
|
38
38
|
});
|
|
39
39
|
});
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import '@testing-library/jest-dom/extend-expect';
|
|
2
2
|
import parsePropsToDisplay from '../../../../src/helpers/parse-props-to-display';
|
|
3
|
+
import processDataSummaryValue from '../../../../src/helpers/process-data-summary-value';
|
|
4
|
+
|
|
5
|
+
jest.mock('../../../../src/helpers/process-data-summary-value', () => jest.fn(value => value));
|
|
3
6
|
|
|
4
7
|
const mockedPropsToDisplayStringArr = ['name', 'other', 'cat.name', 'tag.name'];
|
|
5
8
|
const mockedPropsToDisplayObjectArr = [
|
|
@@ -34,6 +37,7 @@ describe('parsePropsToDisplay func', () => {
|
|
|
34
37
|
it('should return an array of react elements if an array of objects is passed', () => {
|
|
35
38
|
const nonElement = !!withObjArr.find(({ type }) => typeof type !== 'symbol');
|
|
36
39
|
expect(nonElement).toEqual(false);
|
|
40
|
+
expect(processDataSummaryValue).toHaveBeenCalled();
|
|
37
41
|
});
|
|
38
42
|
|
|
39
43
|
it('should display bold tag wrapper when props to display has bold property', () => {
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jest-environment jsdom
|
|
3
|
+
*/
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import processDataSummaryValue from '../../../../src/helpers/process-data-summary-value';
|
|
6
|
+
import components from '../../../../src/components';
|
|
7
|
+
|
|
8
|
+
const { code: Code } = components;
|
|
9
|
+
|
|
10
|
+
const keyField = 'name';
|
|
11
|
+
const john = { keyField, name: 'John', age: 30 };
|
|
12
|
+
const jane = { keyField, name: 'Jane', age: 25 };
|
|
13
|
+
|
|
14
|
+
describe('processDataSummaryValue', () => {
|
|
15
|
+
test('should return the same value when isHtml is false', () => {
|
|
16
|
+
const value = 'Hello, world!';
|
|
17
|
+
const result = processDataSummaryValue(value, { isHtml: false });
|
|
18
|
+
expect(result).toBe(value);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
test('should render code when isHtml is true and objPropValue is a string', () => {
|
|
22
|
+
const value = 'value';
|
|
23
|
+
const result = processDataSummaryValue(value, { isHtml: true });
|
|
24
|
+
const expectedResult = <Code code={value} disableWrapper />;
|
|
25
|
+
expect(result).toEqual(expectedResult);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test('should render code for each object property when isHtml is true and objPropValue is an array of objects', () => {
|
|
29
|
+
const value = [john, jane];
|
|
30
|
+
const result = processDataSummaryValue(value, { isHtml: true });
|
|
31
|
+
const expectedResult = [
|
|
32
|
+
{
|
|
33
|
+
keyField,
|
|
34
|
+
name: <Code code={john.name} disableWrapper />,
|
|
35
|
+
age: 30
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
keyField,
|
|
39
|
+
name: <Code code={jane.name} disableWrapper />,
|
|
40
|
+
age: 25
|
|
41
|
+
}
|
|
42
|
+
];
|
|
43
|
+
expect(result).toEqual(expectedResult);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test('should not render code for the only property when isHtml is false and objPropValue is an object', () => {
|
|
47
|
+
const value = [john];
|
|
48
|
+
const result = processDataSummaryValue(value, { isHtml: false });
|
|
49
|
+
const expectedResult = [john];
|
|
50
|
+
expect(result).toEqual(expectedResult);
|
|
51
|
+
});
|
|
52
|
+
});
|