@lowdefy/block-dev 4.0.0-alpha.9 → 4.0.0-rc.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/dist/BlockSchemaErrors.js +2 -3
- package/dist/mockBlock.js +2 -4
- package/dist/runMockMethodTests.js +16 -16
- package/dist/runMockRenderTests.js +19 -22
- package/dist/runRenderTests.js +21 -28
- package/dist/stubBlockProps.js +10 -20
- package/package.json +18 -19
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/ import React from 'react';
|
|
16
16
|
const BlockSchemaErrors = ({ schemaErrors })=>{
|
|
17
17
|
if (!schemaErrors || schemaErrors.length === 0) return '';
|
|
18
|
-
return
|
|
18
|
+
return /*#__PURE__*/ React.createElement("div", {
|
|
19
19
|
style: {
|
|
20
20
|
padding: 10,
|
|
21
21
|
fontSize: '0.8rem',
|
|
@@ -25,7 +25,6 @@ const BlockSchemaErrors = ({ schemaErrors })=>{
|
|
|
25
25
|
}
|
|
26
26
|
}, /*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement("b", null, "Schema Errors")), schemaErrors.map((error, i)=>/*#__PURE__*/ React.createElement("div", {
|
|
27
27
|
key: i
|
|
28
|
-
}, /*#__PURE__*/ React.createElement("br", null), /*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement("b", null, "keyword:"), " ", error.keyword), /*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement("b", null, "message:"), " ", error.message), /*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement("b", null, "params:"), " ", JSON.stringify(error.params)), /*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement("b", null, "dataPath:"), " ", error.dataPath), /*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement("b", null, "schemaPath:"), " ", error.schemaPath))
|
|
29
|
-
)));
|
|
28
|
+
}, /*#__PURE__*/ React.createElement("br", null), /*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement("b", null, "keyword:"), " ", error.keyword), /*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement("b", null, "message:"), " ", error.message), /*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement("b", null, "params:"), " ", JSON.stringify(error.params)), /*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement("b", null, "dataPath:"), " ", error.dataPath), /*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement("b", null, "schemaPath:"), " ", error.schemaPath))));
|
|
30
29
|
};
|
|
31
30
|
export default BlockSchemaErrors;
|
package/dist/mockBlock.js
CHANGED
|
@@ -16,8 +16,7 @@
|
|
|
16
16
|
import stubBlockProps from './stubBlockProps.js';
|
|
17
17
|
const mockBlock = ({ meta , schema })=>{
|
|
18
18
|
const mockMath = Object.create(global.Math);
|
|
19
|
-
mockMath.random = ()=>0.5
|
|
20
|
-
;
|
|
19
|
+
mockMath.random = ()=>0.5;
|
|
21
20
|
global.Math = mockMath;
|
|
22
21
|
const moveItemDown = jest.fn();
|
|
23
22
|
const moveItemUp = jest.fn();
|
|
@@ -65,8 +64,7 @@ const mockBlock = ({ meta , schema })=>{
|
|
|
65
64
|
addEventListener: jest.fn(),
|
|
66
65
|
removeEventListener: jest.fn(),
|
|
67
66
|
dispatchEvent: jest.fn()
|
|
68
|
-
})
|
|
69
|
-
)
|
|
67
|
+
}))
|
|
70
68
|
});
|
|
71
69
|
}
|
|
72
70
|
if (typeof window !== 'undefined') {
|
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
function _extends() {
|
|
2
|
+
_extends = Object.assign || function(target) {
|
|
3
|
+
for(var i = 1; i < arguments.length; i++){
|
|
4
|
+
var source = arguments[i];
|
|
5
|
+
for(var key in source){
|
|
6
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
7
|
+
target[key] = source[key];
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
return target;
|
|
12
|
+
};
|
|
13
|
+
return _extends.apply(this, arguments);
|
|
14
|
+
}
|
|
1
15
|
/*
|
|
2
16
|
Copyright 2020-2022 Lowdefy, Inc
|
|
3
17
|
|
|
@@ -17,20 +31,6 @@ import { type } from '@lowdefy/helpers';
|
|
|
17
31
|
import { render, screen } from '@testing-library/react';
|
|
18
32
|
import userEvent from '@testing-library/user-event';
|
|
19
33
|
import mockBlock from './mockBlock.js';
|
|
20
|
-
function _extends() {
|
|
21
|
-
_extends = Object.assign || function(target) {
|
|
22
|
-
for(var i = 1; i < arguments.length; i++){
|
|
23
|
-
var source = arguments[i];
|
|
24
|
-
for(var key in source){
|
|
25
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
26
|
-
target[key] = source[key];
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
return target;
|
|
31
|
-
};
|
|
32
|
-
return _extends.apply(this, arguments);
|
|
33
|
-
}
|
|
34
34
|
const runMockMethodTests = ({ Block: Block1 , examples , mocks , schema , testConfig })=>{
|
|
35
35
|
const meta = Block1.meta;
|
|
36
36
|
const { before , methods , getProps } = mockBlock({
|
|
@@ -60,7 +60,7 @@ const runMockMethodTests = ({ Block: Block1 , examples , mocks , schema , testCo
|
|
|
60
60
|
...methods,
|
|
61
61
|
registerMethod: props.methods.registerMethod
|
|
62
62
|
};
|
|
63
|
-
return
|
|
63
|
+
return /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(Block, _extends({}, props, {
|
|
64
64
|
value: value
|
|
65
65
|
})), /*#__PURE__*/ React.createElement("button", {
|
|
66
66
|
id: `${ex.id}_button`,
|
|
@@ -68,7 +68,7 @@ const runMockMethodTests = ({ Block: Block1 , examples , mocks , schema , testCo
|
|
|
68
68
|
props.methods[method.name](method.args);
|
|
69
69
|
},
|
|
70
70
|
"data-testid": "btn_method"
|
|
71
|
-
}))
|
|
71
|
+
}));
|
|
72
72
|
};
|
|
73
73
|
const { container } = render(/*#__PURE__*/ React.createElement(Shell, null));
|
|
74
74
|
expect(container.firstChild).toMatchSnapshot();
|
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
function _extends() {
|
|
2
|
+
_extends = Object.assign || function(target) {
|
|
3
|
+
for(var i = 1; i < arguments.length; i++){
|
|
4
|
+
var source = arguments[i];
|
|
5
|
+
for(var key in source){
|
|
6
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
7
|
+
target[key] = source[key];
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
return target;
|
|
12
|
+
};
|
|
13
|
+
return _extends.apply(this, arguments);
|
|
14
|
+
}
|
|
1
15
|
/*
|
|
2
16
|
Copyright 2020-2022 Lowdefy, Inc
|
|
3
17
|
|
|
@@ -16,22 +30,7 @@
|
|
|
16
30
|
import { type } from '@lowdefy/helpers';
|
|
17
31
|
import { render, waitFor } from '@testing-library/react';
|
|
18
32
|
import mockBlock from './mockBlock.js';
|
|
19
|
-
|
|
20
|
-
_extends = Object.assign || function(target) {
|
|
21
|
-
for(var i = 1; i < arguments.length; i++){
|
|
22
|
-
var source = arguments[i];
|
|
23
|
-
for(var key in source){
|
|
24
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
25
|
-
target[key] = source[key];
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return target;
|
|
30
|
-
};
|
|
31
|
-
return _extends.apply(this, arguments);
|
|
32
|
-
}
|
|
33
|
-
const runMockRenderTests = ({ Block: Block1 , examples , logger , mocks , reset =()=>null
|
|
34
|
-
, schema , testConfig , })=>{
|
|
33
|
+
const runMockRenderTests = ({ Block: Block1 , examples , logger , mocks , reset =()=>null , schema , testConfig , })=>{
|
|
35
34
|
const { before , getProps } = mockBlock({
|
|
36
35
|
meta: Block1.meta,
|
|
37
36
|
logger,
|
|
@@ -41,8 +40,7 @@ const runMockRenderTests = ({ Block: Block1 , examples , logger , mocks , reset
|
|
|
41
40
|
const makeCssImp = (style, op)=>JSON.stringify({
|
|
42
41
|
style,
|
|
43
42
|
options: op
|
|
44
|
-
})
|
|
45
|
-
;
|
|
43
|
+
});
|
|
46
44
|
beforeEach(async ()=>{
|
|
47
45
|
await reset();
|
|
48
46
|
before();
|
|
@@ -66,17 +64,16 @@ const runMockRenderTests = ({ Block: Block1 , examples , logger , mocks , reset
|
|
|
66
64
|
const Block = await mock.getBlock();
|
|
67
65
|
const Shell = ()=>{
|
|
68
66
|
const props = getProps(ex);
|
|
69
|
-
return
|
|
67
|
+
return /*#__PURE__*/ React.createElement(Block, _extends({}, props, {
|
|
70
68
|
methods: {
|
|
71
69
|
...props.methods,
|
|
72
70
|
makeCssClass
|
|
73
71
|
},
|
|
74
72
|
value: value
|
|
75
|
-
}))
|
|
73
|
+
}));
|
|
76
74
|
};
|
|
77
75
|
const { container } = render(/*#__PURE__*/ React.createElement(Shell, null));
|
|
78
|
-
await waitFor(()=>expect(container.firstChild).toMatchSnapshot()
|
|
79
|
-
);
|
|
76
|
+
await waitFor(()=>expect(container.firstChild).toMatchSnapshot());
|
|
80
77
|
mockFns.forEach((mockFn)=>{
|
|
81
78
|
expect(mockFn.mock.calls).toMatchSnapshot();
|
|
82
79
|
});
|
package/dist/runRenderTests.js
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
function _extends() {
|
|
2
|
+
_extends = Object.assign || function(target) {
|
|
3
|
+
for(var i = 1; i < arguments.length; i++){
|
|
4
|
+
var source = arguments[i];
|
|
5
|
+
for(var key in source){
|
|
6
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
7
|
+
target[key] = source[key];
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
return target;
|
|
12
|
+
};
|
|
13
|
+
return _extends.apply(this, arguments);
|
|
14
|
+
}
|
|
1
15
|
/*
|
|
2
16
|
Copyright 2020-2022 Lowdefy, Inc
|
|
3
17
|
|
|
@@ -16,22 +30,7 @@
|
|
|
16
30
|
import { render, waitFor } from '@testing-library/react';
|
|
17
31
|
import { type } from '@lowdefy/helpers';
|
|
18
32
|
import mockBlock from './mockBlock.js';
|
|
19
|
-
|
|
20
|
-
_extends = Object.assign || function(target) {
|
|
21
|
-
for(var i = 1; i < arguments.length; i++){
|
|
22
|
-
var source = arguments[i];
|
|
23
|
-
for(var key in source){
|
|
24
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
25
|
-
target[key] = source[key];
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return target;
|
|
30
|
-
};
|
|
31
|
-
return _extends.apply(this, arguments);
|
|
32
|
-
}
|
|
33
|
-
const runRenderTests = ({ Block , examples , logger , reset =()=>null
|
|
34
|
-
, schema , testConfig , validationsExamples , })=>{
|
|
33
|
+
const runRenderTests = ({ Block , examples , logger , reset =()=>null , schema , testConfig , validationsExamples , })=>{
|
|
35
34
|
const { before , methods , getProps } = mockBlock({
|
|
36
35
|
meta: Block.meta,
|
|
37
36
|
logger,
|
|
@@ -57,11 +56,9 @@ const runRenderTests = ({ Block , examples , logger , reset =()=>null
|
|
|
57
56
|
const Shell = ()=>/*#__PURE__*/ React.createElement(Block, _extends({}, getProps(ex), {
|
|
58
57
|
value: value,
|
|
59
58
|
methods: methods
|
|
60
|
-
}))
|
|
61
|
-
;
|
|
59
|
+
}));
|
|
62
60
|
const { container } = render(/*#__PURE__*/ React.createElement(Shell, null));
|
|
63
|
-
await waitFor(()=>expect(container.firstChild).toMatchSnapshot()
|
|
64
|
-
);
|
|
61
|
+
await waitFor(()=>expect(container.firstChild).toMatchSnapshot());
|
|
65
62
|
});
|
|
66
63
|
if (testConfig && testConfig.validation) {
|
|
67
64
|
(validationsExamples || []).map((validationEx)=>{
|
|
@@ -71,11 +68,9 @@ const runRenderTests = ({ Block , examples , logger , reset =()=>null
|
|
|
71
68
|
value: value,
|
|
72
69
|
methods: methods,
|
|
73
70
|
validation: validationEx
|
|
74
|
-
}))
|
|
75
|
-
;
|
|
71
|
+
}));
|
|
76
72
|
const { container } = render(/*#__PURE__*/ React.createElement(Shell, null));
|
|
77
|
-
await waitFor(()=>expect(container.firstChild).toMatchSnapshot()
|
|
78
|
-
);
|
|
73
|
+
await waitFor(()=>expect(container.firstChild).toMatchSnapshot());
|
|
79
74
|
});
|
|
80
75
|
});
|
|
81
76
|
}
|
|
@@ -86,11 +81,9 @@ const runRenderTests = ({ Block , examples , logger , reset =()=>null
|
|
|
86
81
|
value: value,
|
|
87
82
|
methods: methods,
|
|
88
83
|
required: true
|
|
89
|
-
}))
|
|
90
|
-
;
|
|
84
|
+
}));
|
|
91
85
|
const { container } = render(/*#__PURE__*/ React.createElement(Shell, null));
|
|
92
|
-
await waitFor(()=>expect(container.firstChild).toMatchSnapshot()
|
|
93
|
-
);
|
|
86
|
+
await waitFor(()=>expect(container.firstChild).toMatchSnapshot());
|
|
94
87
|
});
|
|
95
88
|
}
|
|
96
89
|
});
|
package/dist/stubBlockProps.js
CHANGED
|
@@ -21,25 +21,21 @@ const Icons = {
|
|
|
21
21
|
AiIcon: ({ onClick , ...props })=>/*#__PURE__*/ React.createElement("svg", {
|
|
22
22
|
"data-testid": "AiIcon",
|
|
23
23
|
onClick: onClick
|
|
24
|
-
}, "ICON PROPS: ", JSON.stringify(props))
|
|
25
|
-
,
|
|
24
|
+
}, "ICON PROPS: ", JSON.stringify(props)),
|
|
26
25
|
AiOutlineExclamationCircle: ({ onClick , ...props })=>/*#__PURE__*/ React.createElement("svg", {
|
|
27
26
|
"data-testid": "AiOutlineExclamationCircle",
|
|
28
27
|
onClick: onClick
|
|
29
|
-
}, "ICON PROPS: ", JSON.stringify(props))
|
|
30
|
-
,
|
|
28
|
+
}, "ICON PROPS: ", JSON.stringify(props)),
|
|
31
29
|
AiOutlineLoading3Quarters: ({ onClick , ...props })=>/*#__PURE__*/ React.createElement("svg", {
|
|
32
30
|
"data-testid": "AiOutlineLoading3Quarters",
|
|
33
31
|
onClick: onClick
|
|
34
|
-
}, "ICON PROPS: ", JSON.stringify(props))
|
|
35
|
-
,
|
|
32
|
+
}, "ICON PROPS: ", JSON.stringify(props)),
|
|
36
33
|
ErrorIcon: ()=>{
|
|
37
34
|
throw new Error('ErrorIcon');
|
|
38
35
|
}
|
|
39
36
|
};
|
|
40
37
|
const IconComponent = createIcon(Icons);
|
|
41
|
-
const stubBlockProps = ({ block , meta , logger =()=>null
|
|
42
|
-
, initialValue , schema })=>{
|
|
38
|
+
const stubBlockProps = ({ block , meta , logger =()=>null , initialValue , schema })=>{
|
|
43
39
|
const [value, setState] = useState(type.enforceType(meta.valueType, block.value || initialValue));
|
|
44
40
|
const setValue = (val)=>{
|
|
45
41
|
setState(type.enforceType(meta.valueType, val));
|
|
@@ -101,16 +97,11 @@ const stubBlockProps = ({ block , meta , logger =()=>null
|
|
|
101
97
|
});
|
|
102
98
|
});
|
|
103
99
|
block.methods = {
|
|
104
|
-
pushItem: ()=>log('List pushItem')
|
|
105
|
-
,
|
|
106
|
-
|
|
107
|
-
,
|
|
108
|
-
|
|
109
|
-
,
|
|
110
|
-
moveItemDown: (i)=>log(`List moveItemDown ${i}`)
|
|
111
|
-
,
|
|
112
|
-
moveItemUp: (i)=>log(`List moveItemUp ${i}`)
|
|
113
|
-
,
|
|
100
|
+
pushItem: ()=>log('List pushItem'),
|
|
101
|
+
unshiftItem: ()=>log('List unshiftItem'),
|
|
102
|
+
removeItem: (i)=>log(`List removeItem ${i}`),
|
|
103
|
+
moveItemDown: (i)=>log(`List moveItemDown ${i}`),
|
|
104
|
+
moveItemUp: (i)=>log(`List moveItemUp ${i}`),
|
|
114
105
|
...block.methods
|
|
115
106
|
};
|
|
116
107
|
}
|
|
@@ -124,8 +115,7 @@ const stubBlockProps = ({ block , meta , logger =()=>null
|
|
|
124
115
|
border: '1px solid red',
|
|
125
116
|
padding: 10
|
|
126
117
|
}
|
|
127
|
-
}, key)
|
|
128
|
-
;
|
|
118
|
+
}, key);
|
|
129
119
|
});
|
|
130
120
|
}
|
|
131
121
|
if (meta.category === 'input') {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/block-dev",
|
|
3
|
-
"version": "4.0.0-
|
|
4
|
-
"
|
|
3
|
+
"version": "4.0.0-rc.0",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
5
|
"description": "Lowdefy Block Development Tools",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
7
7
|
"keywords": [
|
|
@@ -31,32 +31,31 @@
|
|
|
31
31
|
"dist/*"
|
|
32
32
|
],
|
|
33
33
|
"scripts": {
|
|
34
|
-
"build": "
|
|
34
|
+
"build": "swc src --out-dir dist --config-file ../../../.swcrc --delete-dir-on-start",
|
|
35
35
|
"clean": "rm -rf dist",
|
|
36
|
-
"
|
|
37
|
-
"swc": "swc src --out-dir dist --config-file ../../../.swcrc --delete-dir-on-start"
|
|
36
|
+
"prepublishOnly": "pnpm build"
|
|
38
37
|
},
|
|
39
38
|
"dependencies": {
|
|
40
|
-
"@emotion/jest": "11.
|
|
41
|
-
"@lowdefy/block-utils": "4.0.0-
|
|
42
|
-
"@lowdefy/helpers": "4.0.0-
|
|
43
|
-
"@testing-library/dom": "8.
|
|
44
|
-
"@testing-library/react": "13.
|
|
45
|
-
"@testing-library/user-event": "14.
|
|
46
|
-
"ajv": "8.
|
|
39
|
+
"@emotion/jest": "11.9.1",
|
|
40
|
+
"@lowdefy/block-utils": "4.0.0-rc.0",
|
|
41
|
+
"@lowdefy/helpers": "4.0.0-rc.0",
|
|
42
|
+
"@testing-library/dom": "8.13.0",
|
|
43
|
+
"@testing-library/react": "13.3.0",
|
|
44
|
+
"@testing-library/user-event": "14.2.0",
|
|
45
|
+
"ajv": "8.11.0",
|
|
47
46
|
"ajv-errors": "3.0.0",
|
|
48
|
-
"jest": "
|
|
47
|
+
"jest": "28.1.0",
|
|
49
48
|
"jest-serializer-html": "7.1.0",
|
|
50
|
-
"react": "
|
|
51
|
-
"react-dom": "
|
|
52
|
-
"yaml-loader": "0.
|
|
49
|
+
"react": "18.2.0",
|
|
50
|
+
"react-dom": "18.2.0",
|
|
51
|
+
"yaml-loader": "0.8.0"
|
|
53
52
|
},
|
|
54
53
|
"devDependencies": {
|
|
55
|
-
"@swc/cli": "0.1.
|
|
56
|
-
"@swc/core": "1.2.
|
|
54
|
+
"@swc/cli": "0.1.57",
|
|
55
|
+
"@swc/core": "1.2.194"
|
|
57
56
|
},
|
|
58
57
|
"publishConfig": {
|
|
59
58
|
"access": "public"
|
|
60
59
|
},
|
|
61
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "f6872d7ff6da421710096536fce7b2016ef8f35c"
|
|
62
61
|
}
|