@@ -4,44 +4,18 @@ import { withSimpleExposing } from "comps/generators/withExposing";
4
4
import { withMethodExposing } from "comps/generators/withMethodExposing" ;
5
5
import { evalAndReduce } from "comps/utils" ;
6
6
import { customAction } from "lowcoder-core" ;
7
- import { RemoteCompInfo } from "types/remoteComp" ;
8
7
import { lazyLoadComp } from "./lazyLoadComp" ;
9
8
10
- const npmRemoteInfo : RemoteCompInfo = {
11
- isRemote : true ,
12
- source : "npm" ,
13
- packageName : "p" ,
14
- packageVersion : "v" ,
15
- compName : "n" ,
16
- } ;
9
+ const TestComp = valueComp < number > ( 123 ) ;
10
+ export { TestComp } ;
17
11
18
- let TestComp = simpleMultiComp ( { hello : valueComp < number > ( 123 ) } ) ;
19
- TestComp = withSimpleExposing ( TestComp , ( comp ) => {
20
- return {
21
- hello : comp . children . hello . getView ( ) ,
22
- } ;
23
- } ) ;
24
- TestComp = withMethodExposing ( TestComp , [
25
- {
26
- method : {
27
- name : "add" ,
28
- params : [ { name : "value" , type : "number" } ] ,
29
- } ,
30
- execute : ( comp , values ) => {
31
- const hello = comp . children . hello ;
32
- hello . dispatchChangeValueAction ( hello . getView ( ) + ( values [ 0 ] as number ) ) ;
33
- } ,
34
- } ,
35
- ] ) ;
36
- export {
37
- TestComp ,
38
- } ;
12
+ const compName = 'TestComp' ;
13
+ const compPath = 'comps/lazyLoadComp/lazyLoadComp.test.tsx' ;
39
14
40
- // const RComp = lazyLoadComp('TestComp', './lazyLoadComp.test.tsx' );
15
+ const RComp = lazyLoadComp ( compName , compPath ) ;
41
16
42
17
test ( "lazyload comp" , async ( ) => {
43
18
let c : any = null ;
44
- const RComp = await lazyLoadComp ( 'TestComp' , './lazyLoadComp.test.tsx' ) ;
45
19
c = new RComp ( {
46
20
dispatch : ( action ) => {
47
21
if ( c ) {
@@ -60,7 +34,6 @@ test("lazyload comp", async () => {
60
34
61
35
test ( "lazyload comp keep values" , async ( ) => {
62
36
let c : any = null ;
63
- const RComp = await lazyLoadComp ( 'TestComp' , './lazyLoadComp.test.tsx' ) ;
64
37
c = new RComp ( {
65
38
dispatch : ( action ) => {
66
39
if ( c ) {
@@ -69,21 +42,20 @@ test("lazyload comp keep values", async () => {
69
42
} ,
70
43
value : 456 ,
71
44
} ) ;
72
-
45
+
73
46
expect ( c . toJsonValue ( ) ) . toBe ( 456 ) ;
74
47
await c . load ( ) ;
75
48
expect ( c . toJsonValue ( ) ) . toBe ( 456 ) ;
76
49
} ) ;
77
50
78
51
test ( "lazyload comp exposing data" , async ( ) => {
79
- // const EComp = lazyLoadComp('comp-path', async () => {
80
- // return withSimpleExposing(simpleMultiComp({ hello: valueComp(123) }), (comp) => {
81
- // return {
82
- // hello: comp.children.hello.getView(),
83
- // };
84
- // });
85
- // });
86
- const EComp = await lazyLoadComp ( 'TestComp' , './lazyLoadComp.test.tsx' ) ;
52
+ const EComp = lazyLoadComp ( compName , compPath , async ( ) => {
53
+ return withSimpleExposing ( simpleMultiComp ( { hello : valueComp ( 123 ) } ) , ( comp ) => {
54
+ return {
55
+ hello : comp . children . hello . getView ( ) ,
56
+ } ;
57
+ } ) ;
58
+ } ) ;
87
59
88
60
let c : any = null ;
89
61
c = new EComp ( {
@@ -94,27 +66,26 @@ test("lazyload comp exposing data", async () => {
94
66
} ,
95
67
} ) ;
96
68
97
- await c . load ( ) ;
69
+ await c . load ( ) ;
98
70
const c1 = evalAndReduce ( c ) ;
99
71
expect ( c1 . exposingValues . hello ) . toBe ( 123 ) ;
100
72
} ) ;
101
73
102
74
test ( "lazyload comp execute method" , async ( ) => {
103
- // const MComp = lazyLoadComp('comp-path', async () => {
104
- // return withMethodExposing(simpleMultiComp({ hello: valueComp<number>(123) }), [
105
- // {
106
- // method: {
107
- // name: "add",
108
- // params: [{ name: "value", type: "number" }],
109
- // },
110
- // execute: (comp, values) => {
111
- // const hello = comp.children.hello;
112
- // hello.dispatchChangeValueAction(hello.getView() + (values[0] as number));
113
- // },
114
- // },
115
- // ]);
116
- // });
117
- const MComp = await lazyLoadComp ( 'TestComp' , './lazyLoadComp.test.tsx' ) ;
75
+ const MComp = lazyLoadComp ( compName , compPath , async ( ) => {
76
+ return withMethodExposing ( simpleMultiComp ( { hello : valueComp < number > ( 123 ) } ) , [
77
+ {
78
+ method : {
79
+ name : "add" ,
80
+ params : [ { name : "value" , type : "number" } ] ,
81
+ } ,
82
+ execute : ( comp , values ) => {
83
+ const hello = comp . children . hello ;
84
+ hello . dispatchChangeValueAction ( hello . getView ( ) + ( values [ 0 ] as number ) ) ;
85
+ } ,
86
+ } ,
87
+ ] ) ;
88
+ } ) ;
118
89
let c : any = null ;
119
90
c = new MComp ( {
120
91
dispatch : ( action ) => {
0 commit comments