Skip to content

Commit 6b24f9d

Browse files
authored
Merge pull request alibaba#228 from alibaba/feat/lowcode-slot-props
fix: Fix the conversion failure of some props expressions under Slot …
2 parents 071e1e9 + 7db5461 commit 6b24f9d

File tree

8 files changed

+67
-7
lines changed

8 files changed

+67
-7
lines changed

packages/react-renderer/jest.config.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
1-
const esModules = ['@recore/obx-react'].join('|');
2-
31
module.exports = {
42
// transform: {
53
// '^.+\\.[jt]sx?$': 'babel-jest',
64
// // '^.+\\.(ts|tsx)$': 'ts-jest',
75
// // '^.+\\.(js|jsx)$': 'babel-jest',
86
// },
97
// testMatch: ['(/tests?/.*(test))\\.[jt]s$'],
10-
transformIgnorePatterns: [
11-
`/node_modules/(?!${esModules})/`,
12-
],
138
moduleFileExtensions: ['ts', 'tsx', 'js', 'json'],
149
collectCoverage: true,
1510
collectCoverageFrom: [

packages/renderer-core/jest.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
const esModules = [
2-
'@recore/obx-react',
32
'@alilc/lowcode-datasource-engine',
43
].join('|');
54

packages/utils/build.test.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"plugins": [
3+
"build-plugin-component",
4+
"@alilc/lowcode-test-mate/plugin/index.ts"
5+
]
6+
}

packages/utils/jest.config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = {
2+
moduleFileExtensions: ['ts', 'tsx', 'js', 'json'],
3+
collectCoverage: true,
4+
collectCoverageFrom: [
5+
'src/**/*.{ts,tsx}',
6+
'!**/node_modules/**',
7+
'!**/vendor/**',
8+
],
9+
};

packages/utils/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"main": "lib/index.js",
1010
"module": "es/index.js",
1111
"scripts": {
12+
"test": "build-scripts test --config build.test.json",
1213
"build": "build-scripts build --skip-demo"
1314
},
1415
"dependencies": {

packages/utils/src/schema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export function compatibleLegaoSchema(props: any): any {
2626
type: 'JSSlot',
2727
title: (props.value.props as any)?.slotTitle,
2828
name: (props.value.props as any)?.slotName,
29-
value: props.value.children,
29+
value: compatibleLegaoSchema(props.value.children),
3030
params: (props.value.props as any)?.slotParams,
3131
};
3232
} else {
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Schema Ut props 1`] = `
4+
Object {
5+
"props": Object {
6+
"mobileSlot": Object {
7+
"name": undefined,
8+
"params": undefined,
9+
"title": undefined,
10+
"type": "JSSlot",
11+
"value": Array [
12+
Object {
13+
"loop": Object {
14+
"mock": undefined,
15+
"type": "JSExpression",
16+
"value": "props.content",
17+
},
18+
},
19+
],
20+
},
21+
},
22+
}
23+
`;
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { compatibleLegaoSchema } from '../../src/schema';
2+
describe('Schema Ut', () => {
3+
it('props', () => {
4+
const schema = {
5+
props: {
6+
mobileSlot: {
7+
type: "JSBlock",
8+
value: {
9+
componentName: "Slot",
10+
children: [
11+
{
12+
loop: {
13+
variable: "props.content",
14+
type: "variable"
15+
},
16+
}
17+
],
18+
}
19+
},
20+
},
21+
};
22+
23+
const result = compatibleLegaoSchema(schema);
24+
expect(result).toMatchSnapshot();
25+
expect(result.props.mobileSlot.value[0].loop.type).toBe('JSExpression');
26+
});
27+
})

0 commit comments

Comments
 (0)