GeezerVison is showing github.com — fix: fix the unit test failure problem caused by thisRequiredInJSE mo… · zfhstudy/lowcode-engine@c2c59b7
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: packages/renderer-core/src/hoc/leaf.tsx +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -226,7 +226,7 @@ export function leafWrapper(Comp: types.IBaseRenderComponent, { | 226 | 226 | nodeChildren: null, | 227 | 227 | childrenInState: false, | 228 | 228 | visible: !hidden, | 229 | | - condition: __parseData(condition, scope), | | 229 | + condition: __parseData?.(condition, scope), | 230 | 230 | nodeCacheProps: {}, | 231 | 231 | nodeProps: {}, | 232 | 232 | }; | @@ -396,7 +396,7 @@ export function leafWrapper(Comp: types.IBaseRenderComponent, { | 396 | 396 |
| 397 | 397 | if (key === '___condition___') { | 398 | 398 | const { condition = true } = this.leaf?.export(TransformStage.Render) || {}; | 399 | | - const conditionValue = __parseData(condition, scope); | | 399 | + const conditionValue = __parseData?.(condition, scope); | 400 | 400 | __debug(`key is ___condition___, change condition value to [${condition}]`); | 401 | 401 | // 条件表达式改变 | 402 | 402 | this.setState({ | |
Collapse file Copy file name to clipboardExpand all lines: packages/renderer-core/src/utils/common.ts +5-1Lines changed: 5 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -330,7 +330,11 @@ export function forEach(targetObj: any, fn: any, context?: any) { | 330 | 330 | Object.keys(targetObj).forEach((key) => fn.call(context, targetObj[key], key)); | 331 | 331 | } | 332 | 332 |
| 333 | | -export function parseData(schema: unknown, self: any, options: any): any { | | 333 | +interface IParseOptions { | | 334 | + thisRequiredInJSE?: boolean; | | 335 | +} | | 336 | + | | 337 | +export function parseData(schema: unknown, self: any, options: IParseOptions = {}): any { | 334 | 338 | if (isJSExpression(schema)) { | 335 | 339 | return parseExpression(schema, self, options.thisRequiredInJSE); | 336 | 340 | } else if (isI18nData(schema)) { | |
Collapse file Copy file name to clipboardExpand all lines: packages/renderer-core/tests/hoc/leaf.test.tsx +4Lines changed: 4 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -5,6 +5,7 @@ import '../utils/react-env-init'; | 5 | 5 | import { leafWrapper } from '../../src/hoc/leaf'; | 6 | 6 | import components from '../utils/components'; | 7 | 7 | import Node from '../utils/node'; | | 8 | +import { parseData } from '../../src/utils'; | 8 | 9 |
| 9 | 10 | let rerenderCount = 0; | 10 | 11 |
| @@ -37,6 +38,9 @@ const baseRenderer: any = { | 37 | 38 | } | 38 | 39 | }, | 39 | 40 | documentId: '01' | | 41 | + }, | | 42 | + __parseData (data, scope) { | | 43 | + return parseData(data, scope, {}); | 40 | 44 | } | 41 | 45 | } | 42 | 46 |
| |
Collapse file Copy file name to clipboardExpand all lines: packages/renderer-core/tests/renderer/renderer.test.tsx +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -329,7 +329,7 @@ describe('JSExpression', () => { | 329 | 329 | ], | 330 | 330 | loop: { | 331 | 331 | type: "JSExpression", | 332 | | - value: "state.content" | | 332 | + value: "this.state.content" | 333 | 333 | }, | 334 | 334 | loopArgs: [ | 335 | 335 | "item", | |
|