@tanstack/devtools-vite 0.3.1 → 0.3.3
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/esm/enhance-logs.d.ts +1 -3
- package/dist/esm/enhance-logs.js +2 -2
- package/dist/esm/enhance-logs.js.map +1 -1
- package/dist/esm/inject-source.d.ts +1 -3
- package/dist/esm/inject-source.js +2 -2
- package/dist/esm/inject-source.js.map +1 -1
- package/dist/esm/plugin.d.ts +6 -1
- package/dist/esm/plugin.js +17 -8
- package/dist/esm/plugin.js.map +1 -1
- package/dist/esm/remove-devtools.d.ts +1 -3
- package/dist/esm/remove-devtools.js +83 -5
- package/dist/esm/remove-devtools.js.map +1 -1
- package/package.json +1 -1
- package/src/enhance-logs.test.ts +32 -72
- package/src/enhance-logs.ts +2 -2
- package/src/inject-source.test.ts +108 -268
- package/src/inject-source.ts +2 -2
- package/src/plugin.ts +23 -10
- package/src/remove-devtools.test.ts +350 -19
- package/src/remove-devtools.ts +127 -7
|
@@ -7,62 +7,38 @@ const removeEmptySpace = (str: string) => {
|
|
|
7
7
|
|
|
8
8
|
describe('inject source', () => {
|
|
9
9
|
it("shouldn't augment react fragments", () => {
|
|
10
|
-
const output =
|
|
11
|
-
|
|
12
|
-
`
|
|
10
|
+
const output = addSourceToJsx(
|
|
11
|
+
`
|
|
13
12
|
export const Route = createFileRoute("/test")({
|
|
14
13
|
component: function() { return <>Hello World</> },
|
|
15
14
|
})
|
|
16
15
|
`,
|
|
17
|
-
|
|
18
|
-
).code,
|
|
19
|
-
)
|
|
20
|
-
expect(output).toBe(
|
|
21
|
-
removeEmptySpace(`
|
|
22
|
-
export const Route = createFileRoute("/test")({
|
|
23
|
-
component: function() { return <>Hello World</> },
|
|
24
|
-
})
|
|
25
|
-
`),
|
|
16
|
+
'test.jsx',
|
|
26
17
|
)
|
|
18
|
+
expect(output).toBe(undefined)
|
|
27
19
|
})
|
|
28
20
|
|
|
29
21
|
it("shouldn't augment react fragments if they start with Fragment ", () => {
|
|
30
|
-
const output =
|
|
31
|
-
|
|
32
|
-
`
|
|
22
|
+
const output = addSourceToJsx(
|
|
23
|
+
`
|
|
33
24
|
export const Route = createFileRoute("/test")({
|
|
34
25
|
component: function() { return <Fragment>Hello World</Fragment> },
|
|
35
26
|
})
|
|
36
27
|
`,
|
|
37
|
-
|
|
38
|
-
).code,
|
|
39
|
-
)
|
|
40
|
-
expect(output).toBe(
|
|
41
|
-
removeEmptySpace(`
|
|
42
|
-
export const Route = createFileRoute("/test")({
|
|
43
|
-
component: function() { return <Fragment>Hello World</Fragment> },
|
|
44
|
-
})
|
|
45
|
-
`),
|
|
28
|
+
'test.jsx',
|
|
46
29
|
)
|
|
30
|
+
expect(output).toBe(undefined)
|
|
47
31
|
})
|
|
48
32
|
it("shouldn't augment react fragments if they start with React.Fragment ", () => {
|
|
49
|
-
const output =
|
|
50
|
-
|
|
51
|
-
`
|
|
33
|
+
const output = addSourceToJsx(
|
|
34
|
+
`
|
|
52
35
|
export const Route = createFileRoute("/test")({
|
|
53
36
|
component: function() { return <React.Fragment>Hello World</React.Fragment> },
|
|
54
37
|
})
|
|
55
38
|
`,
|
|
56
|
-
|
|
57
|
-
).code,
|
|
58
|
-
)
|
|
59
|
-
expect(output).toBe(
|
|
60
|
-
removeEmptySpace(`
|
|
61
|
-
export const Route = createFileRoute("/test")({
|
|
62
|
-
component: function() { return <React.Fragment>Hello World</React.Fragment> },
|
|
63
|
-
})
|
|
64
|
-
`),
|
|
39
|
+
'test.jsx',
|
|
65
40
|
)
|
|
41
|
+
expect(output).toBe(undefined)
|
|
66
42
|
})
|
|
67
43
|
describe('FunctionExpression', () => {
|
|
68
44
|
it('should work with deeply nested custom JSX syntax', () => {
|
|
@@ -74,7 +50,7 @@ describe('inject source', () => {
|
|
|
74
50
|
})
|
|
75
51
|
`,
|
|
76
52
|
'test.jsx',
|
|
77
|
-
)
|
|
53
|
+
)!.code,
|
|
78
54
|
)
|
|
79
55
|
expect(output).toBe(
|
|
80
56
|
removeEmptySpace(`
|
|
@@ -86,63 +62,39 @@ describe('inject source', () => {
|
|
|
86
62
|
})
|
|
87
63
|
|
|
88
64
|
it('should work with props not destructured and spread', () => {
|
|
89
|
-
const output =
|
|
90
|
-
|
|
91
|
-
`
|
|
65
|
+
const output = addSourceToJsx(
|
|
66
|
+
`
|
|
92
67
|
export const Route = createFileRoute("/test")({
|
|
93
68
|
component: function(props) { return <div {...props}>Hello World</div> },
|
|
94
69
|
})
|
|
95
70
|
`,
|
|
96
|
-
|
|
97
|
-
).code,
|
|
98
|
-
)
|
|
99
|
-
expect(output).toBe(
|
|
100
|
-
removeEmptySpace(`
|
|
101
|
-
export const Route = createFileRoute("/test")({
|
|
102
|
-
component: function(props) { return <div {...props}>Hello World</div> },
|
|
103
|
-
})
|
|
104
|
-
`),
|
|
71
|
+
'test.jsx',
|
|
105
72
|
)
|
|
73
|
+
expect(output).toBe(undefined)
|
|
106
74
|
})
|
|
107
75
|
|
|
108
76
|
it('should work with props destructured and spread', () => {
|
|
109
|
-
const output =
|
|
110
|
-
|
|
111
|
-
`
|
|
77
|
+
const output = addSourceToJsx(
|
|
78
|
+
`
|
|
112
79
|
export const Route = createFileRoute("/test")({
|
|
113
80
|
component: function({...props}) { return <div {...props}>Hello World</div> },
|
|
114
81
|
})
|
|
115
82
|
`,
|
|
116
|
-
|
|
117
|
-
).code,
|
|
118
|
-
)
|
|
119
|
-
expect(output).toBe(
|
|
120
|
-
removeEmptySpace(`
|
|
121
|
-
export const Route = createFileRoute("/test")({
|
|
122
|
-
component: function({...props}) { return <div {...props}>Hello World</div> },
|
|
123
|
-
})
|
|
124
|
-
`),
|
|
83
|
+
'test.jsx',
|
|
125
84
|
)
|
|
85
|
+
expect(output).toBe(undefined)
|
|
126
86
|
})
|
|
127
87
|
|
|
128
88
|
it('should work with props destructured and spread with a different name', () => {
|
|
129
|
-
const output =
|
|
130
|
-
|
|
131
|
-
`
|
|
89
|
+
const output = addSourceToJsx(
|
|
90
|
+
`
|
|
132
91
|
export const Route = createFileRoute("/test")({
|
|
133
92
|
component: function({...rest}) { return <div {...rest}>Hello World</div> },
|
|
134
93
|
})
|
|
135
94
|
`,
|
|
136
|
-
|
|
137
|
-
).code,
|
|
138
|
-
)
|
|
139
|
-
expect(output).toBe(
|
|
140
|
-
removeEmptySpace(`
|
|
141
|
-
export const Route = createFileRoute("/test")({
|
|
142
|
-
component: function({...rest}) { return <div {...rest}>Hello World</div> },
|
|
143
|
-
})
|
|
144
|
-
`),
|
|
95
|
+
'test.jsx',
|
|
145
96
|
)
|
|
97
|
+
expect(output).toBe(undefined)
|
|
146
98
|
})
|
|
147
99
|
|
|
148
100
|
it('should work with props spread and other normal elements', () => {
|
|
@@ -154,7 +106,7 @@ describe('inject source', () => {
|
|
|
154
106
|
})
|
|
155
107
|
`,
|
|
156
108
|
'test.jsx',
|
|
157
|
-
)
|
|
109
|
+
)!.code,
|
|
158
110
|
)
|
|
159
111
|
expect(output).toBe(
|
|
160
112
|
removeEmptySpace(`
|
|
@@ -176,7 +128,7 @@ describe('inject source', () => {
|
|
|
176
128
|
})
|
|
177
129
|
`,
|
|
178
130
|
'test.jsx',
|
|
179
|
-
)
|
|
131
|
+
)!.code,
|
|
180
132
|
)
|
|
181
133
|
expect(output).toBe(
|
|
182
134
|
removeEmptySpace(`
|
|
@@ -188,63 +140,39 @@ describe('inject source', () => {
|
|
|
188
140
|
})
|
|
189
141
|
|
|
190
142
|
it('should work with props not destructured and spread', () => {
|
|
191
|
-
const output =
|
|
192
|
-
|
|
193
|
-
`
|
|
143
|
+
const output = addSourceToJsx(
|
|
144
|
+
`
|
|
194
145
|
export const Route = createFileRoute("/test")({
|
|
195
146
|
component: (props) => <div {...props}>Hello World</div>,
|
|
196
147
|
})
|
|
197
148
|
`,
|
|
198
|
-
|
|
199
|
-
).code,
|
|
200
|
-
)
|
|
201
|
-
expect(output).toBe(
|
|
202
|
-
removeEmptySpace(`
|
|
203
|
-
export const Route = createFileRoute("/test")({
|
|
204
|
-
component: (props) => <div {...props}>Hello World</div>,
|
|
205
|
-
})
|
|
206
|
-
`),
|
|
149
|
+
'test.jsx',
|
|
207
150
|
)
|
|
151
|
+
expect(output).toBe(undefined)
|
|
208
152
|
})
|
|
209
153
|
|
|
210
154
|
it('should work with props destructured and spread', () => {
|
|
211
|
-
const output =
|
|
212
|
-
|
|
213
|
-
`
|
|
155
|
+
const output = addSourceToJsx(
|
|
156
|
+
`
|
|
214
157
|
export const Route = createFileRoute("/test")({
|
|
215
158
|
component: ({...props}) => <div {...props}>Hello World</div>,
|
|
216
159
|
})
|
|
217
160
|
`,
|
|
218
|
-
|
|
219
|
-
).code,
|
|
220
|
-
)
|
|
221
|
-
expect(output).toBe(
|
|
222
|
-
removeEmptySpace(`
|
|
223
|
-
export const Route = createFileRoute("/test")({
|
|
224
|
-
component: ({...props}) => <div {...props}>Hello World</div>,
|
|
225
|
-
})
|
|
226
|
-
`),
|
|
161
|
+
'test.jsx',
|
|
227
162
|
)
|
|
163
|
+
expect(output).toBe(undefined)
|
|
228
164
|
})
|
|
229
165
|
|
|
230
166
|
it('should work with props destructured and spread with a different name', () => {
|
|
231
|
-
const output =
|
|
232
|
-
|
|
233
|
-
`
|
|
167
|
+
const output = addSourceToJsx(
|
|
168
|
+
`
|
|
234
169
|
export const Route = createFileRoute("/test")({
|
|
235
170
|
component: ({...rest}) => <div {...rest}>Hello World</div>,
|
|
236
171
|
})
|
|
237
172
|
`,
|
|
238
|
-
|
|
239
|
-
).code,
|
|
240
|
-
)
|
|
241
|
-
expect(output).toBe(
|
|
242
|
-
removeEmptySpace(`
|
|
243
|
-
export const Route = createFileRoute("/test")({
|
|
244
|
-
component: ({...rest}) => <div {...rest}>Hello World</div>,
|
|
245
|
-
})
|
|
246
|
-
`),
|
|
173
|
+
'test.jsx',
|
|
247
174
|
)
|
|
175
|
+
expect(output).toBe(undefined)
|
|
248
176
|
})
|
|
249
177
|
|
|
250
178
|
it('should work with props spread and other normal elements', () => {
|
|
@@ -256,7 +184,7 @@ describe('inject source', () => {
|
|
|
256
184
|
})
|
|
257
185
|
`,
|
|
258
186
|
'test.jsx',
|
|
259
|
-
)
|
|
187
|
+
)!.code,
|
|
260
188
|
)
|
|
261
189
|
expect(output).toBe(
|
|
262
190
|
removeEmptySpace(`
|
|
@@ -280,7 +208,7 @@ describe('inject source', () => {
|
|
|
280
208
|
}
|
|
281
209
|
`,
|
|
282
210
|
'test.jsx',
|
|
283
|
-
)
|
|
211
|
+
)!.code,
|
|
284
212
|
)
|
|
285
213
|
expect(output).toBe(
|
|
286
214
|
removeEmptySpace(`
|
|
@@ -305,7 +233,7 @@ function test({...props }) {
|
|
|
305
233
|
}
|
|
306
234
|
`,
|
|
307
235
|
'test.tsx',
|
|
308
|
-
)
|
|
236
|
+
)!.code,
|
|
309
237
|
)
|
|
310
238
|
expect(output).toBe(
|
|
311
239
|
removeEmptySpace(`
|
|
@@ -325,7 +253,7 @@ function test({...props }) {
|
|
|
325
253
|
}
|
|
326
254
|
`,
|
|
327
255
|
'test.jsx',
|
|
328
|
-
)
|
|
256
|
+
)!.code,
|
|
329
257
|
)
|
|
330
258
|
expect(output).toBe(
|
|
331
259
|
removeEmptySpace(`
|
|
@@ -337,23 +265,15 @@ function test(props) {
|
|
|
337
265
|
})
|
|
338
266
|
|
|
339
267
|
it("doesn't transform when props are spread across the element", () => {
|
|
340
|
-
const output =
|
|
341
|
-
|
|
342
|
-
`
|
|
268
|
+
const output = addSourceToJsx(
|
|
269
|
+
`
|
|
343
270
|
function test(props) {
|
|
344
271
|
return <button {...props} />
|
|
345
272
|
}
|
|
346
273
|
`,
|
|
347
|
-
|
|
348
|
-
).code,
|
|
349
|
-
)
|
|
350
|
-
expect(output).toBe(
|
|
351
|
-
removeEmptySpace(`
|
|
352
|
-
function test(props) {
|
|
353
|
-
return <button {...props} />
|
|
354
|
-
}
|
|
355
|
-
`),
|
|
274
|
+
'test.jsx',
|
|
356
275
|
)
|
|
276
|
+
expect(output).toBe(undefined)
|
|
357
277
|
})
|
|
358
278
|
|
|
359
279
|
it("doesn't transform when props are spread across the element but applies to other elements without any props", () => {
|
|
@@ -367,7 +287,7 @@ function test(props) {
|
|
|
367
287
|
}
|
|
368
288
|
`,
|
|
369
289
|
'test.jsx',
|
|
370
|
-
)
|
|
290
|
+
)!.code,
|
|
371
291
|
)
|
|
372
292
|
expect(output).toBe(
|
|
373
293
|
removeEmptySpace(`
|
|
@@ -391,7 +311,7 @@ function test(props) {
|
|
|
391
311
|
}
|
|
392
312
|
`,
|
|
393
313
|
'test.jsx',
|
|
394
|
-
)
|
|
314
|
+
)!.code,
|
|
395
315
|
)
|
|
396
316
|
expect(output).toBe(
|
|
397
317
|
removeEmptySpace(`
|
|
@@ -415,7 +335,7 @@ function test({...props}) {
|
|
|
415
335
|
}
|
|
416
336
|
`,
|
|
417
337
|
'test.jsx',
|
|
418
|
-
)
|
|
338
|
+
)!.code,
|
|
419
339
|
)
|
|
420
340
|
expect(output).toBe(
|
|
421
341
|
removeEmptySpace(`
|
|
@@ -429,23 +349,15 @@ function test({...rest}) {
|
|
|
429
349
|
})
|
|
430
350
|
|
|
431
351
|
it(' props destructured and collected with a different name', () => {
|
|
432
|
-
const output =
|
|
433
|
-
|
|
434
|
-
`
|
|
352
|
+
const output = addSourceToJsx(
|
|
353
|
+
`
|
|
435
354
|
function test({ children, ...rest }) {
|
|
436
355
|
return <button children={children} {...rest} />
|
|
437
356
|
}
|
|
438
357
|
`,
|
|
439
|
-
|
|
440
|
-
).code,
|
|
441
|
-
)
|
|
442
|
-
expect(output).toBe(
|
|
443
|
-
removeEmptySpace(`
|
|
444
|
-
function test({ children, ...rest }) {
|
|
445
|
-
return <button children={children} {...rest} />
|
|
446
|
-
}
|
|
447
|
-
`),
|
|
358
|
+
'test.jsx',
|
|
448
359
|
)
|
|
360
|
+
expect(output).toBe(undefined)
|
|
449
361
|
})
|
|
450
362
|
|
|
451
363
|
it(' props destructured and collected', () => {
|
|
@@ -457,7 +369,7 @@ function test({ children, ...rest }) {
|
|
|
457
369
|
}
|
|
458
370
|
`,
|
|
459
371
|
'test.jsx',
|
|
460
|
-
)
|
|
372
|
+
)!.code,
|
|
461
373
|
)
|
|
462
374
|
expect(output).toBe(
|
|
463
375
|
removeEmptySpace(`
|
|
@@ -469,23 +381,15 @@ function test({ children, ...rest }) {
|
|
|
469
381
|
})
|
|
470
382
|
|
|
471
383
|
it('props destructured and collected with a different name even on custom components', () => {
|
|
472
|
-
const output =
|
|
473
|
-
|
|
474
|
-
`
|
|
384
|
+
const output = addSourceToJsx(
|
|
385
|
+
`
|
|
475
386
|
function test({ children, ...rest }) {
|
|
476
387
|
return <CustomButton children={children} {...rest} />
|
|
477
388
|
}
|
|
478
389
|
`,
|
|
479
|
-
|
|
480
|
-
).code,
|
|
481
|
-
)
|
|
482
|
-
expect(output).toBe(
|
|
483
|
-
removeEmptySpace(`
|
|
484
|
-
function test({ children, ...rest }) {
|
|
485
|
-
return <CustomButton children={children} {...rest} />
|
|
486
|
-
}
|
|
487
|
-
`),
|
|
390
|
+
'test.jsx',
|
|
488
391
|
)
|
|
392
|
+
expect(output).toBe(undefined)
|
|
489
393
|
})
|
|
490
394
|
|
|
491
395
|
it('props destructured and collected even on custom components', () => {
|
|
@@ -497,7 +401,7 @@ function test({ children, ...rest }) {
|
|
|
497
401
|
}
|
|
498
402
|
`,
|
|
499
403
|
'test.jsx',
|
|
500
|
-
)
|
|
404
|
+
)!.code,
|
|
501
405
|
)
|
|
502
406
|
expect(output).toBe(
|
|
503
407
|
removeEmptySpace(`
|
|
@@ -509,23 +413,15 @@ function test({ children, ...rest }) {
|
|
|
509
413
|
})
|
|
510
414
|
|
|
511
415
|
it('props destructured and collected with a different name even on custom components even if exported', () => {
|
|
512
|
-
const output =
|
|
513
|
-
|
|
514
|
-
`
|
|
416
|
+
const output = addSourceToJsx(
|
|
417
|
+
`
|
|
515
418
|
function test({ children, ...rest }) {
|
|
516
419
|
return <CustomButton children={children} {...rest} />
|
|
517
420
|
}
|
|
518
421
|
`,
|
|
519
|
-
|
|
520
|
-
).code,
|
|
521
|
-
)
|
|
522
|
-
expect(output).toBe(
|
|
523
|
-
removeEmptySpace(`
|
|
524
|
-
function test({ children, ...rest }) {
|
|
525
|
-
return <CustomButton children={children} {...rest} />
|
|
526
|
-
}
|
|
527
|
-
`),
|
|
422
|
+
'test.jsx',
|
|
528
423
|
)
|
|
424
|
+
expect(output).toBe(undefined)
|
|
529
425
|
})
|
|
530
426
|
|
|
531
427
|
it('props destructured and collected even on custom components even if exported', () => {
|
|
@@ -537,7 +433,7 @@ function test({ children, ...rest }) {
|
|
|
537
433
|
}
|
|
538
434
|
`,
|
|
539
435
|
'test.jsx',
|
|
540
|
-
)
|
|
436
|
+
)!.code,
|
|
541
437
|
)
|
|
542
438
|
expect(output).toBe(
|
|
543
439
|
removeEmptySpace(`
|
|
@@ -558,7 +454,7 @@ function test({ children, ...rest }) {
|
|
|
558
454
|
}
|
|
559
455
|
`,
|
|
560
456
|
'test.jsx',
|
|
561
|
-
)
|
|
457
|
+
)!.code,
|
|
562
458
|
)
|
|
563
459
|
expect(output).toBe(
|
|
564
460
|
removeEmptySpace(`
|
|
@@ -570,23 +466,15 @@ function test({ children, ...rest }) {
|
|
|
570
466
|
})
|
|
571
467
|
|
|
572
468
|
it("doesn't transform when props are spread across the element", () => {
|
|
573
|
-
const output =
|
|
574
|
-
|
|
575
|
-
`
|
|
469
|
+
const output = addSourceToJsx(
|
|
470
|
+
`
|
|
576
471
|
const ButtonWithProps = function test(props) {
|
|
577
472
|
return <button {...props} />
|
|
578
473
|
}
|
|
579
474
|
`,
|
|
580
|
-
|
|
581
|
-
).code,
|
|
582
|
-
)
|
|
583
|
-
expect(output).toBe(
|
|
584
|
-
removeEmptySpace(`
|
|
585
|
-
const ButtonWithProps = function test(props) {
|
|
586
|
-
return <button {...props} />
|
|
587
|
-
}
|
|
588
|
-
`),
|
|
475
|
+
'test.jsx',
|
|
589
476
|
)
|
|
477
|
+
expect(output).toBe(undefined)
|
|
590
478
|
})
|
|
591
479
|
|
|
592
480
|
it("doesn't transform when props are spread across the element but applies to other elements without any props", () => {
|
|
@@ -600,7 +488,7 @@ function test({ children, ...rest }) {
|
|
|
600
488
|
}
|
|
601
489
|
`,
|
|
602
490
|
'test.jsx',
|
|
603
|
-
)
|
|
491
|
+
)!.code,
|
|
604
492
|
)
|
|
605
493
|
expect(output).toBe(
|
|
606
494
|
removeEmptySpace(`
|
|
@@ -624,7 +512,7 @@ function test({ children, ...rest }) {
|
|
|
624
512
|
}
|
|
625
513
|
`,
|
|
626
514
|
'test.jsx',
|
|
627
|
-
)
|
|
515
|
+
)!.code,
|
|
628
516
|
)
|
|
629
517
|
expect(output).toBe(
|
|
630
518
|
removeEmptySpace(`
|
|
@@ -648,7 +536,7 @@ function test({ children, ...rest }) {
|
|
|
648
536
|
}
|
|
649
537
|
`,
|
|
650
538
|
'test.jsx',
|
|
651
|
-
)
|
|
539
|
+
)!.code,
|
|
652
540
|
)
|
|
653
541
|
expect(output).toBe(
|
|
654
542
|
removeEmptySpace(`
|
|
@@ -662,23 +550,15 @@ function test({ children, ...rest }) {
|
|
|
662
550
|
})
|
|
663
551
|
|
|
664
552
|
it(' props destructured and collected with a different name', () => {
|
|
665
|
-
const output =
|
|
666
|
-
|
|
667
|
-
`
|
|
553
|
+
const output = addSourceToJsx(
|
|
554
|
+
`
|
|
668
555
|
const ButtonWithProps = function test({ children, ...rest }) {
|
|
669
556
|
return <button children={children} {...rest} />
|
|
670
557
|
}
|
|
671
558
|
`,
|
|
672
|
-
|
|
673
|
-
).code,
|
|
674
|
-
)
|
|
675
|
-
expect(output).toBe(
|
|
676
|
-
removeEmptySpace(`
|
|
677
|
-
const ButtonWithProps = function test({ children, ...rest }) {
|
|
678
|
-
return <button children={children} {...rest} />
|
|
679
|
-
}
|
|
680
|
-
`),
|
|
559
|
+
'test.jsx',
|
|
681
560
|
)
|
|
561
|
+
expect(output).toBe(undefined)
|
|
682
562
|
})
|
|
683
563
|
|
|
684
564
|
it(' props destructured and collected', () => {
|
|
@@ -690,7 +570,7 @@ function test({ children, ...rest }) {
|
|
|
690
570
|
}
|
|
691
571
|
`,
|
|
692
572
|
'test.jsx',
|
|
693
|
-
)
|
|
573
|
+
)!.code,
|
|
694
574
|
)
|
|
695
575
|
expect(output).toBe(
|
|
696
576
|
removeEmptySpace(`
|
|
@@ -702,23 +582,15 @@ function test({ children, ...rest }) {
|
|
|
702
582
|
})
|
|
703
583
|
|
|
704
584
|
it('props destructured and collected with a different name even on custom components', () => {
|
|
705
|
-
const output =
|
|
706
|
-
|
|
707
|
-
`
|
|
585
|
+
const output = addSourceToJsx(
|
|
586
|
+
`
|
|
708
587
|
const ButtonWithProps = function test({ children, ...rest }) {
|
|
709
588
|
return <CustomButton children={children} {...rest} />
|
|
710
589
|
}
|
|
711
590
|
`,
|
|
712
|
-
|
|
713
|
-
).code,
|
|
714
|
-
)
|
|
715
|
-
expect(output).toBe(
|
|
716
|
-
removeEmptySpace(`
|
|
717
|
-
const ButtonWithProps = function test({ children, ...rest }) {
|
|
718
|
-
return <CustomButton children={children} {...rest} />
|
|
719
|
-
}
|
|
720
|
-
`),
|
|
591
|
+
'test.jsx',
|
|
721
592
|
)
|
|
593
|
+
expect(output).toBe(undefined)
|
|
722
594
|
})
|
|
723
595
|
|
|
724
596
|
it('props destructured and collected even on custom components', () => {
|
|
@@ -730,7 +602,7 @@ function test({ children, ...rest }) {
|
|
|
730
602
|
}
|
|
731
603
|
`,
|
|
732
604
|
'test.jsx',
|
|
733
|
-
)
|
|
605
|
+
)!.code,
|
|
734
606
|
)
|
|
735
607
|
expect(output).toBe(
|
|
736
608
|
removeEmptySpace(`
|
|
@@ -742,23 +614,15 @@ function test({ children, ...rest }) {
|
|
|
742
614
|
})
|
|
743
615
|
|
|
744
616
|
it('props destructured and collected with a different name even on custom components even if exported', () => {
|
|
745
|
-
const output =
|
|
746
|
-
|
|
747
|
-
`
|
|
617
|
+
const output = addSourceToJsx(
|
|
618
|
+
`
|
|
748
619
|
export const ButtonWithProps = function test({ children, ...rest }) {
|
|
749
620
|
return <CustomButton children={children} {...rest} />
|
|
750
621
|
}
|
|
751
622
|
`,
|
|
752
|
-
|
|
753
|
-
).code,
|
|
754
|
-
)
|
|
755
|
-
expect(output).toBe(
|
|
756
|
-
removeEmptySpace(`
|
|
757
|
-
export const ButtonWithProps = function test({ children, ...rest }) {
|
|
758
|
-
return <CustomButton children={children} {...rest} />
|
|
759
|
-
}
|
|
760
|
-
`),
|
|
623
|
+
'test.jsx',
|
|
761
624
|
)
|
|
625
|
+
expect(output).toBe(undefined)
|
|
762
626
|
})
|
|
763
627
|
|
|
764
628
|
it('props destructured and collected even on custom components even if exported', () => {
|
|
@@ -770,7 +634,7 @@ function test({ children, ...rest }) {
|
|
|
770
634
|
}
|
|
771
635
|
`,
|
|
772
636
|
'test.jsx',
|
|
773
|
-
)
|
|
637
|
+
)!.code,
|
|
774
638
|
)
|
|
775
639
|
expect(output).toBe(
|
|
776
640
|
removeEmptySpace(`
|
|
@@ -791,7 +655,7 @@ function test({ children, ...rest }) {
|
|
|
791
655
|
}
|
|
792
656
|
`,
|
|
793
657
|
'test.jsx',
|
|
794
|
-
)
|
|
658
|
+
)!.code,
|
|
795
659
|
)
|
|
796
660
|
expect(output).toBe(
|
|
797
661
|
removeEmptySpace(`
|
|
@@ -803,23 +667,15 @@ function test({ children, ...rest }) {
|
|
|
803
667
|
})
|
|
804
668
|
|
|
805
669
|
it("doesn't transform when props are spread across the element", () => {
|
|
806
|
-
const output =
|
|
807
|
-
|
|
808
|
-
`
|
|
670
|
+
const output = addSourceToJsx(
|
|
671
|
+
`
|
|
809
672
|
const ButtonWithProps = (props) => {
|
|
810
673
|
return <button {...props} />
|
|
811
674
|
}
|
|
812
675
|
`,
|
|
813
|
-
|
|
814
|
-
).code,
|
|
815
|
-
)
|
|
816
|
-
expect(output).toBe(
|
|
817
|
-
removeEmptySpace(`
|
|
818
|
-
const ButtonWithProps = (props) => {
|
|
819
|
-
return <button {...props} />
|
|
820
|
-
}
|
|
821
|
-
`),
|
|
676
|
+
'test.jsx',
|
|
822
677
|
)
|
|
678
|
+
expect(output).toBe(undefined)
|
|
823
679
|
})
|
|
824
680
|
|
|
825
681
|
it("doesn't transform when props are spread across the element but applies to other elements without any props", () => {
|
|
@@ -833,7 +689,7 @@ function test({ children, ...rest }) {
|
|
|
833
689
|
}
|
|
834
690
|
`,
|
|
835
691
|
'test.jsx',
|
|
836
|
-
)
|
|
692
|
+
)!.code,
|
|
837
693
|
)
|
|
838
694
|
expect(output).toBe(
|
|
839
695
|
removeEmptySpace(`
|
|
@@ -857,7 +713,7 @@ function test({ children, ...rest }) {
|
|
|
857
713
|
}
|
|
858
714
|
`,
|
|
859
715
|
'test.jsx',
|
|
860
|
-
)
|
|
716
|
+
)!.code,
|
|
861
717
|
)
|
|
862
718
|
expect(output).toBe(
|
|
863
719
|
removeEmptySpace(`
|
|
@@ -881,7 +737,7 @@ function test({ children, ...rest }) {
|
|
|
881
737
|
}
|
|
882
738
|
`,
|
|
883
739
|
'test.jsx',
|
|
884
|
-
)
|
|
740
|
+
)!.code,
|
|
885
741
|
)
|
|
886
742
|
expect(output).toBe(
|
|
887
743
|
removeEmptySpace(`
|
|
@@ -903,7 +759,7 @@ function test({ children, ...rest }) {
|
|
|
903
759
|
}
|
|
904
760
|
`,
|
|
905
761
|
'test.jsx',
|
|
906
|
-
)
|
|
762
|
+
)!.code,
|
|
907
763
|
)
|
|
908
764
|
expect(output).toBe(
|
|
909
765
|
removeEmptySpace(`
|
|
@@ -923,7 +779,7 @@ function test({ children, ...rest }) {
|
|
|
923
779
|
}
|
|
924
780
|
`,
|
|
925
781
|
'test.jsx',
|
|
926
|
-
)
|
|
782
|
+
)!.code,
|
|
927
783
|
)
|
|
928
784
|
expect(output).toBe(
|
|
929
785
|
removeEmptySpace(`
|
|
@@ -935,23 +791,15 @@ function test({ children, ...rest }) {
|
|
|
935
791
|
})
|
|
936
792
|
|
|
937
793
|
it('works with arrow function and props destructured and collected with a different name even on custom components', () => {
|
|
938
|
-
const output =
|
|
939
|
-
|
|
940
|
-
`
|
|
794
|
+
const output = addSourceToJsx(
|
|
795
|
+
`
|
|
941
796
|
const ButtonWithProps = ({ children, ...rest }) => {
|
|
942
797
|
return <CustomButton children={children} {...rest} />
|
|
943
798
|
}
|
|
944
799
|
`,
|
|
945
|
-
|
|
946
|
-
).code,
|
|
947
|
-
)
|
|
948
|
-
expect(output).toBe(
|
|
949
|
-
removeEmptySpace(`
|
|
950
|
-
const ButtonWithProps = ({ children, ...rest }) => {
|
|
951
|
-
return <CustomButton children={children} {...rest} />
|
|
952
|
-
}
|
|
953
|
-
`),
|
|
800
|
+
'test.jsx',
|
|
954
801
|
)
|
|
802
|
+
expect(output).toBe(undefined)
|
|
955
803
|
})
|
|
956
804
|
|
|
957
805
|
it('works with arrow function and props destructured and collected even on custom components', () => {
|
|
@@ -963,7 +811,7 @@ function test({ children, ...rest }) {
|
|
|
963
811
|
}
|
|
964
812
|
`,
|
|
965
813
|
'test.jsx',
|
|
966
|
-
)
|
|
814
|
+
)!.code,
|
|
967
815
|
)
|
|
968
816
|
expect(output).toBe(
|
|
969
817
|
removeEmptySpace(`
|
|
@@ -975,23 +823,15 @@ function test({ children, ...rest }) {
|
|
|
975
823
|
})
|
|
976
824
|
|
|
977
825
|
it('works with arrow function and props destructured and collected with a different name even on custom components even if exported', () => {
|
|
978
|
-
const output =
|
|
979
|
-
|
|
980
|
-
`
|
|
826
|
+
const output = addSourceToJsx(
|
|
827
|
+
`
|
|
981
828
|
export const ButtonWithProps = ({ children, ...rest }) => {
|
|
982
829
|
return <CustomButton children={children} {...rest} />
|
|
983
830
|
}
|
|
984
831
|
`,
|
|
985
|
-
|
|
986
|
-
).code,
|
|
987
|
-
)
|
|
988
|
-
expect(output).toBe(
|
|
989
|
-
removeEmptySpace(`
|
|
990
|
-
export const ButtonWithProps = ({ children, ...rest }) => {
|
|
991
|
-
return <CustomButton children={children} {...rest} />
|
|
992
|
-
}
|
|
993
|
-
`),
|
|
832
|
+
'test.jsx',
|
|
994
833
|
)
|
|
834
|
+
expect(output).toBe(undefined)
|
|
995
835
|
})
|
|
996
836
|
|
|
997
837
|
it('works with arrow function and props destructured and collected even on custom components even if exported', () => {
|
|
@@ -1003,7 +843,7 @@ function test({ children, ...rest }) {
|
|
|
1003
843
|
}
|
|
1004
844
|
`,
|
|
1005
845
|
'test.jsx',
|
|
1006
|
-
)
|
|
846
|
+
)!.code,
|
|
1007
847
|
)
|
|
1008
848
|
expect(output).toBe(
|
|
1009
849
|
removeEmptySpace(`
|