@scalar/json-magic 0.1.0 → 0.3.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/.turbo/turbo-build.log +4 -3
- package/CHANGELOG.md +22 -0
- package/README.md +21 -3
- package/dist/bundle/bundle.d.ts +84 -14
- package/dist/bundle/bundle.d.ts.map +1 -1
- package/dist/bundle/bundle.js +56 -15
- package/dist/bundle/bundle.js.map +3 -3
- package/dist/bundle/index.d.ts +2 -1
- package/dist/bundle/index.d.ts.map +1 -1
- package/dist/bundle/index.js.map +2 -2
- package/dist/bundle/plugins/fetch-urls/index.d.ts +2 -2
- package/dist/bundle/plugins/fetch-urls/index.d.ts.map +1 -1
- package/dist/bundle/plugins/fetch-urls/index.js +1 -0
- package/dist/bundle/plugins/fetch-urls/index.js.map +2 -2
- package/dist/bundle/plugins/parse-json/index.d.ts +2 -2
- package/dist/bundle/plugins/parse-json/index.d.ts.map +1 -1
- package/dist/bundle/plugins/parse-json/index.js +1 -0
- package/dist/bundle/plugins/parse-json/index.js.map +2 -2
- package/dist/bundle/plugins/parse-yaml/index.d.ts +2 -2
- package/dist/bundle/plugins/parse-yaml/index.d.ts.map +1 -1
- package/dist/bundle/plugins/parse-yaml/index.js +1 -0
- package/dist/bundle/plugins/parse-yaml/index.js.map +2 -2
- package/dist/bundle/plugins/read-files/index.d.ts +2 -2
- package/dist/bundle/plugins/read-files/index.d.ts.map +1 -1
- package/dist/bundle/plugins/read-files/index.js +1 -0
- package/dist/bundle/plugins/read-files/index.js.map +2 -2
- package/dist/diff/apply.d.ts +1 -1
- package/dist/diff/apply.d.ts.map +1 -1
- package/dist/diff/apply.js.map +2 -2
- package/dist/diff/diff.d.ts +2 -2
- package/dist/diff/diff.d.ts.map +1 -1
- package/dist/diff/diff.js.map +2 -2
- package/dist/diff/merge.d.ts +3 -3
- package/dist/diff/merge.d.ts.map +1 -1
- package/dist/diff/merge.js.map +2 -2
- package/dist/magic-proxy/proxy.d.ts +23 -42
- package/dist/magic-proxy/proxy.d.ts.map +1 -1
- package/dist/magic-proxy/proxy.js +103 -80
- package/dist/magic-proxy/proxy.js.map +3 -3
- package/dist/utils/is-object.d.ts +1 -1
- package/dist/utils/is-object.d.ts.map +1 -1
- package/dist/utils/is-object.js.map +2 -2
- package/package.json +11 -10
- package/src/bundle/bundle.test.ts +594 -44
- package/src/bundle/bundle.ts +167 -32
- package/src/bundle/index.ts +2 -1
- package/src/bundle/plugins/fetch-urls/index.ts +3 -2
- package/src/bundle/plugins/parse-json/index.ts +3 -2
- package/src/bundle/plugins/parse-yaml/index.ts +3 -2
- package/src/bundle/plugins/read-files/index.ts +4 -2
- package/src/dereference/dereference.test.ts +26 -18
- package/src/diff/apply.ts +8 -3
- package/src/diff/diff.ts +3 -3
- package/src/diff/merge.ts +6 -6
- package/src/magic-proxy/proxy.test.ts +1095 -100
- package/src/magic-proxy/proxy.ts +150 -171
- package/src/utils/is-object.ts +1 -1
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
prefixInternalRef,
|
|
11
11
|
prefixInternalRefRecursive,
|
|
12
12
|
setValueAtPath,
|
|
13
|
+
type LoaderPlugin,
|
|
13
14
|
} from './bundle'
|
|
14
15
|
import { fetchUrls } from './plugins/fetch-urls'
|
|
15
16
|
import { readFiles } from './plugins/read-files'
|
|
@@ -18,11 +19,13 @@ import { parseJson } from '@/bundle/plugins/parse-json'
|
|
|
18
19
|
import { parseYaml } from '@/bundle/plugins/parse-yaml'
|
|
19
20
|
import YAML from 'yaml'
|
|
20
21
|
import { getHash } from '@/bundle/value-generator'
|
|
22
|
+
import { consoleWarnSpy, resetConsoleSpies } from '@scalar/helpers/testing/console-spies'
|
|
21
23
|
|
|
22
24
|
describe('bundle', () => {
|
|
23
25
|
describe('external urls', () => {
|
|
24
26
|
let server: FastifyInstance
|
|
25
|
-
const
|
|
27
|
+
const port = 7289
|
|
28
|
+
const url = `http://localhost:${port}`
|
|
26
29
|
|
|
27
30
|
beforeEach(() => {
|
|
28
31
|
server = fastify({ logger: false })
|
|
@@ -34,7 +37,7 @@ describe('bundle', () => {
|
|
|
34
37
|
})
|
|
35
38
|
|
|
36
39
|
it('bundles external urls', async () => {
|
|
37
|
-
const url = `http://localhost:${
|
|
40
|
+
const url = `http://localhost:${port}`
|
|
38
41
|
|
|
39
42
|
const external = {
|
|
40
43
|
prop: 'I am external json prop',
|
|
@@ -43,7 +46,7 @@ describe('bundle', () => {
|
|
|
43
46
|
reply.send(external)
|
|
44
47
|
})
|
|
45
48
|
|
|
46
|
-
await server.listen({ port:
|
|
49
|
+
await server.listen({ port: port })
|
|
47
50
|
|
|
48
51
|
const input = {
|
|
49
52
|
a: {
|
|
@@ -52,7 +55,7 @@ describe('bundle', () => {
|
|
|
52
55
|
},
|
|
53
56
|
},
|
|
54
57
|
d: {
|
|
55
|
-
'$ref': `http://localhost:${
|
|
58
|
+
'$ref': `http://localhost:${port}#/prop`,
|
|
56
59
|
},
|
|
57
60
|
}
|
|
58
61
|
|
|
@@ -79,7 +82,7 @@ describe('bundle', () => {
|
|
|
79
82
|
})
|
|
80
83
|
|
|
81
84
|
it('bundles external urls from resolved external piece', async () => {
|
|
82
|
-
const url = `http://localhost:${
|
|
85
|
+
const url = `http://localhost:${port}`
|
|
83
86
|
const chunk2 = {
|
|
84
87
|
hey: 'hey',
|
|
85
88
|
nested: {
|
|
@@ -104,7 +107,7 @@ describe('bundle', () => {
|
|
|
104
107
|
reply.send(chunk2)
|
|
105
108
|
})
|
|
106
109
|
|
|
107
|
-
await server.listen({ port:
|
|
110
|
+
await server.listen({ port: port })
|
|
108
111
|
|
|
109
112
|
const input = {
|
|
110
113
|
a: {
|
|
@@ -142,7 +145,7 @@ describe('bundle', () => {
|
|
|
142
145
|
})
|
|
143
146
|
|
|
144
147
|
it('should correctly handle only urls without a pointer', async () => {
|
|
145
|
-
const url = `http://localhost:${
|
|
148
|
+
const url = `http://localhost:${port}`
|
|
146
149
|
|
|
147
150
|
server.get('/', (_, reply) => {
|
|
148
151
|
reply.send({
|
|
@@ -150,7 +153,7 @@ describe('bundle', () => {
|
|
|
150
153
|
})
|
|
151
154
|
})
|
|
152
155
|
|
|
153
|
-
await server.listen({ port:
|
|
156
|
+
await server.listen({ port: port })
|
|
154
157
|
|
|
155
158
|
const input = {
|
|
156
159
|
a: {
|
|
@@ -178,7 +181,7 @@ describe('bundle', () => {
|
|
|
178
181
|
|
|
179
182
|
it('caches results for same resource', async () => {
|
|
180
183
|
const fn = vi.fn()
|
|
181
|
-
const url = `http://localhost:${
|
|
184
|
+
const url = `http://localhost:${port}`
|
|
182
185
|
|
|
183
186
|
server.get('/', (_, reply) => {
|
|
184
187
|
fn()
|
|
@@ -188,7 +191,7 @@ describe('bundle', () => {
|
|
|
188
191
|
})
|
|
189
192
|
})
|
|
190
193
|
|
|
191
|
-
await server.listen({ port:
|
|
194
|
+
await server.listen({ port: port })
|
|
192
195
|
|
|
193
196
|
const input = {
|
|
194
197
|
a: {
|
|
@@ -221,7 +224,7 @@ describe('bundle', () => {
|
|
|
221
224
|
})
|
|
222
225
|
|
|
223
226
|
it('handles correctly external nested refs', async () => {
|
|
224
|
-
const url = `http://localhost:${
|
|
227
|
+
const url = `http://localhost:${port}`
|
|
225
228
|
|
|
226
229
|
server.get('/nested/another-file.json', (_, reply) => {
|
|
227
230
|
reply.send({
|
|
@@ -237,7 +240,7 @@ describe('bundle', () => {
|
|
|
237
240
|
})
|
|
238
241
|
})
|
|
239
242
|
|
|
240
|
-
await server.listen({ port:
|
|
243
|
+
await server.listen({ port: port })
|
|
241
244
|
|
|
242
245
|
const input = {
|
|
243
246
|
a: {
|
|
@@ -265,7 +268,7 @@ describe('bundle', () => {
|
|
|
265
268
|
})
|
|
266
269
|
|
|
267
270
|
it('does not merge paths when we use absolute urls', async () => {
|
|
268
|
-
const url = `http://localhost:${
|
|
271
|
+
const url = `http://localhost:${port}`
|
|
269
272
|
|
|
270
273
|
server.get('/top-level', (_, reply) => {
|
|
271
274
|
reply.send({
|
|
@@ -281,7 +284,7 @@ describe('bundle', () => {
|
|
|
281
284
|
})
|
|
282
285
|
})
|
|
283
286
|
|
|
284
|
-
await server.listen({ port:
|
|
287
|
+
await server.listen({ port: port })
|
|
285
288
|
|
|
286
289
|
const input = {
|
|
287
290
|
a: {
|
|
@@ -309,7 +312,7 @@ describe('bundle', () => {
|
|
|
309
312
|
})
|
|
310
313
|
|
|
311
314
|
it('bundles from a url input', async () => {
|
|
312
|
-
const url = `http://localhost:${
|
|
315
|
+
const url = `http://localhost:${port}`
|
|
313
316
|
|
|
314
317
|
server.get('/top-level', (_, reply) => {
|
|
315
318
|
reply.send({
|
|
@@ -333,7 +336,7 @@ describe('bundle', () => {
|
|
|
333
336
|
})
|
|
334
337
|
})
|
|
335
338
|
|
|
336
|
-
await server.listen({ port:
|
|
339
|
+
await server.listen({ port: port })
|
|
337
340
|
|
|
338
341
|
const output = await bundle(`${url}/base/openapi.json`, { plugins: [fetchUrls()], treeShake: false })
|
|
339
342
|
|
|
@@ -355,7 +358,7 @@ describe('bundle', () => {
|
|
|
355
358
|
})
|
|
356
359
|
|
|
357
360
|
it('generated a map when we turn the urlMap on', async () => {
|
|
358
|
-
const url = `http://localhost:${
|
|
361
|
+
const url = `http://localhost:${port}`
|
|
359
362
|
|
|
360
363
|
server.get('/top-level', (_, reply) => {
|
|
361
364
|
reply.send({
|
|
@@ -379,7 +382,7 @@ describe('bundle', () => {
|
|
|
379
382
|
})
|
|
380
383
|
})
|
|
381
384
|
|
|
382
|
-
await server.listen({ port:
|
|
385
|
+
await server.listen({ port: port })
|
|
383
386
|
|
|
384
387
|
const output = await bundle(`${url}/base/openapi.json`, {
|
|
385
388
|
plugins: [fetchUrls()],
|
|
@@ -409,7 +412,7 @@ describe('bundle', () => {
|
|
|
409
412
|
})
|
|
410
413
|
|
|
411
414
|
it('prefixes the refs only once', async () => {
|
|
412
|
-
const url = `http://localhost:${
|
|
415
|
+
const url = `http://localhost:${port}`
|
|
413
416
|
|
|
414
417
|
const chunk2 = {
|
|
415
418
|
a: 'a',
|
|
@@ -433,7 +436,7 @@ describe('bundle', () => {
|
|
|
433
436
|
reply.send(chunk2)
|
|
434
437
|
})
|
|
435
438
|
|
|
436
|
-
await server.listen({ port:
|
|
439
|
+
await server.listen({ port: port })
|
|
437
440
|
|
|
438
441
|
const input = {
|
|
439
442
|
a: {
|
|
@@ -493,7 +496,7 @@ describe('bundle', () => {
|
|
|
493
496
|
})
|
|
494
497
|
|
|
495
498
|
it('bundles array references', async () => {
|
|
496
|
-
const url = `http://localhost:${
|
|
499
|
+
const url = `http://localhost:${port}`
|
|
497
500
|
|
|
498
501
|
const chunk1 = {
|
|
499
502
|
a: {
|
|
@@ -505,7 +508,7 @@ describe('bundle', () => {
|
|
|
505
508
|
reply.send(chunk1)
|
|
506
509
|
})
|
|
507
510
|
|
|
508
|
-
await server.listen({ port:
|
|
511
|
+
await server.listen({ port: port })
|
|
509
512
|
|
|
510
513
|
const input = {
|
|
511
514
|
a: [
|
|
@@ -536,7 +539,7 @@ describe('bundle', () => {
|
|
|
536
539
|
})
|
|
537
540
|
|
|
538
541
|
it('bundles subpart of the document', async () => {
|
|
539
|
-
const url = `http://localhost:${
|
|
542
|
+
const url = `http://localhost:${port}`
|
|
540
543
|
|
|
541
544
|
const chunk1 = {
|
|
542
545
|
a: {
|
|
@@ -551,7 +554,7 @@ describe('bundle', () => {
|
|
|
551
554
|
reply.send(chunk1)
|
|
552
555
|
})
|
|
553
556
|
|
|
554
|
-
await server.listen({ port:
|
|
557
|
+
await server.listen({ port: port })
|
|
555
558
|
|
|
556
559
|
const input = {
|
|
557
560
|
a: {
|
|
@@ -631,7 +634,7 @@ describe('bundle', () => {
|
|
|
631
634
|
})
|
|
632
635
|
|
|
633
636
|
it('always emits the url mappings when doing partial bundle', async () => {
|
|
634
|
-
const url = `http://localhost:${
|
|
637
|
+
const url = `http://localhost:${port}`
|
|
635
638
|
|
|
636
639
|
const chunk1 = {
|
|
637
640
|
a: {
|
|
@@ -643,7 +646,7 @@ describe('bundle', () => {
|
|
|
643
646
|
reply.send(chunk1)
|
|
644
647
|
})
|
|
645
648
|
|
|
646
|
-
await server.listen({ port:
|
|
649
|
+
await server.listen({ port: port })
|
|
647
650
|
|
|
648
651
|
const input = {
|
|
649
652
|
a: {
|
|
@@ -693,7 +696,7 @@ describe('bundle', () => {
|
|
|
693
696
|
})
|
|
694
697
|
|
|
695
698
|
it('tree shakes the external documents correctly', async () => {
|
|
696
|
-
const url = `http://localhost:${
|
|
699
|
+
const url = `http://localhost:${port}`
|
|
697
700
|
|
|
698
701
|
const chunk1 = {
|
|
699
702
|
a: {
|
|
@@ -715,7 +718,7 @@ describe('bundle', () => {
|
|
|
715
718
|
reply.send(chunk1)
|
|
716
719
|
})
|
|
717
720
|
|
|
718
|
-
await server.listen({ port:
|
|
721
|
+
await server.listen({ port: port })
|
|
719
722
|
|
|
720
723
|
const input = {
|
|
721
724
|
a: {
|
|
@@ -748,7 +751,7 @@ describe('bundle', () => {
|
|
|
748
751
|
})
|
|
749
752
|
|
|
750
753
|
it('tree shakes correctly when working with nested external refs', async () => {
|
|
751
|
-
const url = `http://localhost:${
|
|
754
|
+
const url = `http://localhost:${port}`
|
|
752
755
|
|
|
753
756
|
const chunk2 = {
|
|
754
757
|
a: {
|
|
@@ -786,7 +789,7 @@ describe('bundle', () => {
|
|
|
786
789
|
reply.send(chunk2)
|
|
787
790
|
})
|
|
788
791
|
|
|
789
|
-
await server.listen({ port:
|
|
792
|
+
await server.listen({ port: port })
|
|
790
793
|
|
|
791
794
|
const input = {
|
|
792
795
|
a: {
|
|
@@ -832,7 +835,7 @@ describe('bundle', () => {
|
|
|
832
835
|
})
|
|
833
836
|
|
|
834
837
|
it('handles circular references when we treeshake', async () => {
|
|
835
|
-
const url = `http://localhost:${
|
|
838
|
+
const url = `http://localhost:${port}`
|
|
836
839
|
|
|
837
840
|
const chunk1 = {
|
|
838
841
|
a: {
|
|
@@ -853,7 +856,7 @@ describe('bundle', () => {
|
|
|
853
856
|
reply.send(chunk1)
|
|
854
857
|
})
|
|
855
858
|
|
|
856
|
-
await server.listen({ port:
|
|
859
|
+
await server.listen({ port: port })
|
|
857
860
|
|
|
858
861
|
const input = {
|
|
859
862
|
a: {
|
|
@@ -887,7 +890,7 @@ describe('bundle', () => {
|
|
|
887
890
|
})
|
|
888
891
|
|
|
889
892
|
it('handles chunks', async () => {
|
|
890
|
-
const url = `http://localhost:${
|
|
893
|
+
const url = `http://localhost:${port}`
|
|
891
894
|
|
|
892
895
|
const chunk1 = {
|
|
893
896
|
description: 'Chunk 1',
|
|
@@ -907,7 +910,7 @@ describe('bundle', () => {
|
|
|
907
910
|
reply.send(chunk2)
|
|
908
911
|
})
|
|
909
912
|
|
|
910
|
-
await server.listen({ port:
|
|
913
|
+
await server.listen({ port: port })
|
|
911
914
|
|
|
912
915
|
const input = {
|
|
913
916
|
a: {
|
|
@@ -985,7 +988,7 @@ describe('bundle', () => {
|
|
|
985
988
|
})
|
|
986
989
|
|
|
987
990
|
it('when bundle partial document we ensure all the dependencies references are resolved', async () => {
|
|
988
|
-
const url = `http://localhost:${
|
|
991
|
+
const url = `http://localhost:${port}`
|
|
989
992
|
|
|
990
993
|
const chunk1 = {
|
|
991
994
|
a: {
|
|
@@ -996,7 +999,7 @@ describe('bundle', () => {
|
|
|
996
999
|
reply.send(chunk1)
|
|
997
1000
|
})
|
|
998
1001
|
|
|
999
|
-
await server.listen({ port:
|
|
1002
|
+
await server.listen({ port: port })
|
|
1000
1003
|
|
|
1001
1004
|
const input = {
|
|
1002
1005
|
a: {
|
|
@@ -1050,7 +1053,7 @@ describe('bundle', () => {
|
|
|
1050
1053
|
})
|
|
1051
1054
|
|
|
1052
1055
|
it('should correctly handle nested chunk urls', async () => {
|
|
1053
|
-
const url = `http://localhost:${
|
|
1056
|
+
const url = `http://localhost:${port}`
|
|
1054
1057
|
|
|
1055
1058
|
const chunk1 = {
|
|
1056
1059
|
chunk1: 'chunk1',
|
|
@@ -1092,7 +1095,7 @@ describe('bundle', () => {
|
|
|
1092
1095
|
reply.send(external)
|
|
1093
1096
|
})
|
|
1094
1097
|
|
|
1095
|
-
await server.listen({ port:
|
|
1098
|
+
await server.listen({ port: port })
|
|
1096
1099
|
|
|
1097
1100
|
const input = {
|
|
1098
1101
|
c: {
|
|
@@ -1142,7 +1145,7 @@ describe('bundle', () => {
|
|
|
1142
1145
|
$ref: '#/a',
|
|
1143
1146
|
},
|
|
1144
1147
|
nonBundle: {
|
|
1145
|
-
$ref: `http://localhost:${
|
|
1148
|
+
$ref: `http://localhost:${port}/chunk1#`,
|
|
1146
1149
|
},
|
|
1147
1150
|
'x-ext': {
|
|
1148
1151
|
[await getHash(`${url}/external/document.json`)]: {
|
|
@@ -1178,7 +1181,7 @@ describe('bundle', () => {
|
|
|
1178
1181
|
})
|
|
1179
1182
|
|
|
1180
1183
|
it('run success hook', async () => {
|
|
1181
|
-
const url = `http://localhost:${
|
|
1184
|
+
const url = `http://localhost:${port}`
|
|
1182
1185
|
|
|
1183
1186
|
const chunk1 = {
|
|
1184
1187
|
description: 'Chunk 1',
|
|
@@ -1188,7 +1191,7 @@ describe('bundle', () => {
|
|
|
1188
1191
|
reply.send(chunk1)
|
|
1189
1192
|
})
|
|
1190
1193
|
|
|
1191
|
-
await server.listen({ port:
|
|
1194
|
+
await server.listen({ port: port })
|
|
1192
1195
|
|
|
1193
1196
|
const input = {
|
|
1194
1197
|
a: {
|
|
@@ -1225,14 +1228,14 @@ describe('bundle', () => {
|
|
|
1225
1228
|
expect(resolveError).not.toHaveBeenCalledOnce()
|
|
1226
1229
|
})
|
|
1227
1230
|
|
|
1228
|
-
it('run
|
|
1229
|
-
const url = `http://localhost:${
|
|
1231
|
+
it('run error hook', async () => {
|
|
1232
|
+
const url = `http://localhost:${port}`
|
|
1230
1233
|
|
|
1231
1234
|
server.get('/chunk1', (_, reply) => {
|
|
1232
1235
|
reply.code(404).send()
|
|
1233
1236
|
})
|
|
1234
1237
|
|
|
1235
|
-
await server.listen({ port:
|
|
1238
|
+
await server.listen({ port: port })
|
|
1236
1239
|
|
|
1237
1240
|
const input = {
|
|
1238
1241
|
a: {
|
|
@@ -1268,6 +1271,66 @@ describe('bundle', () => {
|
|
|
1268
1271
|
expect(resolveError).toHaveBeenCalledOnce()
|
|
1269
1272
|
expect(resolveError).toHaveBeenCalledWith(refA)
|
|
1270
1273
|
})
|
|
1274
|
+
|
|
1275
|
+
it('uses the provided origin for object inputs', async () => {
|
|
1276
|
+
server.get('/', () => ({
|
|
1277
|
+
message: 'some resolved external reference',
|
|
1278
|
+
}))
|
|
1279
|
+
await server.listen({ port })
|
|
1280
|
+
|
|
1281
|
+
const result = await bundle(
|
|
1282
|
+
{
|
|
1283
|
+
a: {
|
|
1284
|
+
$ref: '/#',
|
|
1285
|
+
},
|
|
1286
|
+
},
|
|
1287
|
+
{
|
|
1288
|
+
treeShake: false,
|
|
1289
|
+
plugins: [fetchUrls()],
|
|
1290
|
+
origin: url,
|
|
1291
|
+
},
|
|
1292
|
+
)
|
|
1293
|
+
|
|
1294
|
+
expect(result).toEqual({
|
|
1295
|
+
'a': {
|
|
1296
|
+
'$ref': '#/x-ext/3664f29',
|
|
1297
|
+
},
|
|
1298
|
+
'x-ext': {
|
|
1299
|
+
'3664f29': {
|
|
1300
|
+
'message': 'some resolved external reference',
|
|
1301
|
+
},
|
|
1302
|
+
},
|
|
1303
|
+
})
|
|
1304
|
+
})
|
|
1305
|
+
|
|
1306
|
+
it('prioritizes configuration origin rather than document input url', async () => {
|
|
1307
|
+
server.get('/', () => ({
|
|
1308
|
+
a: {
|
|
1309
|
+
$ref: '/d#',
|
|
1310
|
+
},
|
|
1311
|
+
}))
|
|
1312
|
+
server.get('/a/b/d', () => ({
|
|
1313
|
+
message: 'some resolved external reference',
|
|
1314
|
+
}))
|
|
1315
|
+
await server.listen({ port: port })
|
|
1316
|
+
|
|
1317
|
+
const result = await bundle(url, {
|
|
1318
|
+
plugins: [fetchUrls()],
|
|
1319
|
+
treeShake: false,
|
|
1320
|
+
origin: `${url}/a/b/c`,
|
|
1321
|
+
})
|
|
1322
|
+
|
|
1323
|
+
expect(result).toEqual({
|
|
1324
|
+
'a': {
|
|
1325
|
+
'$ref': '#/x-ext/fb30100',
|
|
1326
|
+
},
|
|
1327
|
+
'x-ext': {
|
|
1328
|
+
'fb30100': {
|
|
1329
|
+
'message': 'some resolved external reference',
|
|
1330
|
+
},
|
|
1331
|
+
},
|
|
1332
|
+
})
|
|
1333
|
+
})
|
|
1271
1334
|
})
|
|
1272
1335
|
|
|
1273
1336
|
describe('local files', () => {
|
|
@@ -1764,6 +1827,493 @@ describe('bundle', () => {
|
|
|
1764
1827
|
})
|
|
1765
1828
|
})
|
|
1766
1829
|
})
|
|
1830
|
+
|
|
1831
|
+
describe('hooks', () => {
|
|
1832
|
+
describe('onBeforeNodeProcess', () => {
|
|
1833
|
+
it('should correctly call the `onBeforeNodeProcess` correctly on all the nodes', async () => {
|
|
1834
|
+
const fn = vi.fn()
|
|
1835
|
+
|
|
1836
|
+
const input = {
|
|
1837
|
+
someKey: 'someValue',
|
|
1838
|
+
anotherKey: {
|
|
1839
|
+
innerKey: 'nestedValue',
|
|
1840
|
+
},
|
|
1841
|
+
}
|
|
1842
|
+
|
|
1843
|
+
await bundle(input, {
|
|
1844
|
+
plugins: [],
|
|
1845
|
+
treeShake: false,
|
|
1846
|
+
hooks: {
|
|
1847
|
+
onBeforeNodeProcess(node) {
|
|
1848
|
+
fn(node)
|
|
1849
|
+
},
|
|
1850
|
+
},
|
|
1851
|
+
})
|
|
1852
|
+
|
|
1853
|
+
expect(fn).toHaveBeenCalled()
|
|
1854
|
+
expect(fn).toBeCalledTimes(2)
|
|
1855
|
+
|
|
1856
|
+
expect(fn.mock.calls[0][0]).toEqual(input)
|
|
1857
|
+
expect(fn.mock.calls[1][0]).toEqual(input.anotherKey)
|
|
1858
|
+
})
|
|
1859
|
+
|
|
1860
|
+
it('should run bundle on the mutated object properties', async () => {
|
|
1861
|
+
const fn = vi.fn()
|
|
1862
|
+
|
|
1863
|
+
const input = {
|
|
1864
|
+
a: {
|
|
1865
|
+
b: {
|
|
1866
|
+
c: 'c',
|
|
1867
|
+
d: 'd',
|
|
1868
|
+
},
|
|
1869
|
+
e: 'e',
|
|
1870
|
+
},
|
|
1871
|
+
}
|
|
1872
|
+
|
|
1873
|
+
await bundle(input, {
|
|
1874
|
+
plugins: [],
|
|
1875
|
+
treeShake: false,
|
|
1876
|
+
hooks: {
|
|
1877
|
+
onBeforeNodeProcess(node) {
|
|
1878
|
+
if ('e' in node) {
|
|
1879
|
+
node['processedKey'] = { 'message': 'Processed node' }
|
|
1880
|
+
}
|
|
1881
|
+
fn(node)
|
|
1882
|
+
},
|
|
1883
|
+
},
|
|
1884
|
+
})
|
|
1885
|
+
|
|
1886
|
+
expect(fn).toHaveBeenCalled()
|
|
1887
|
+
expect(fn).toBeCalledTimes(4)
|
|
1888
|
+
|
|
1889
|
+
expect(fn.mock.calls[3][0]).toEqual({ 'message': 'Processed node' })
|
|
1890
|
+
})
|
|
1891
|
+
})
|
|
1892
|
+
|
|
1893
|
+
describe('onAfterNodeProcess', () => {
|
|
1894
|
+
it('should call `onAfterNodeProcess` hook on the nodes', async () => {
|
|
1895
|
+
const fn = vi.fn()
|
|
1896
|
+
|
|
1897
|
+
const input = {
|
|
1898
|
+
a: {
|
|
1899
|
+
b: {
|
|
1900
|
+
c: 'c',
|
|
1901
|
+
d: 'd',
|
|
1902
|
+
},
|
|
1903
|
+
e: 'e',
|
|
1904
|
+
},
|
|
1905
|
+
}
|
|
1906
|
+
|
|
1907
|
+
await bundle(input, {
|
|
1908
|
+
plugins: [],
|
|
1909
|
+
treeShake: false,
|
|
1910
|
+
hooks: {
|
|
1911
|
+
onAfterNodeProcess(node) {
|
|
1912
|
+
if ('e' in node) {
|
|
1913
|
+
node['processedKey'] = { 'message': 'Processed node' }
|
|
1914
|
+
}
|
|
1915
|
+
fn(node)
|
|
1916
|
+
},
|
|
1917
|
+
},
|
|
1918
|
+
})
|
|
1919
|
+
|
|
1920
|
+
expect(fn).toHaveBeenCalled()
|
|
1921
|
+
expect(fn).toHaveBeenCalledTimes(3)
|
|
1922
|
+
})
|
|
1923
|
+
})
|
|
1924
|
+
})
|
|
1925
|
+
|
|
1926
|
+
describe('plugins', () => {
|
|
1927
|
+
it('use load plugins to load the documents', async () => {
|
|
1928
|
+
const validate = vi.fn()
|
|
1929
|
+
const exec = vi.fn()
|
|
1930
|
+
|
|
1931
|
+
const resolver = (): LoaderPlugin => {
|
|
1932
|
+
return {
|
|
1933
|
+
type: 'loader',
|
|
1934
|
+
validate(value) {
|
|
1935
|
+
validate(value)
|
|
1936
|
+
return true
|
|
1937
|
+
},
|
|
1938
|
+
async exec(value) {
|
|
1939
|
+
exec(value)
|
|
1940
|
+
return {
|
|
1941
|
+
ok: true,
|
|
1942
|
+
data: { message: 'Resolved document' },
|
|
1943
|
+
}
|
|
1944
|
+
},
|
|
1945
|
+
}
|
|
1946
|
+
}
|
|
1947
|
+
|
|
1948
|
+
const result = await bundle('hello', { treeShake: false, plugins: [resolver()] })
|
|
1949
|
+
|
|
1950
|
+
expect(validate).toHaveBeenCalledOnce()
|
|
1951
|
+
expect(exec).toHaveBeenCalledOnce()
|
|
1952
|
+
|
|
1953
|
+
expect(validate.mock.calls[0][0]).toBe('hello')
|
|
1954
|
+
expect(exec.mock.calls[0][0]).toBe('hello')
|
|
1955
|
+
|
|
1956
|
+
expect(result).toEqual({ message: 'Resolved document' })
|
|
1957
|
+
})
|
|
1958
|
+
|
|
1959
|
+
it('throws if we can not process the input with any of the provided loaders', async () => {
|
|
1960
|
+
const validate = vi.fn()
|
|
1961
|
+
const exec = vi.fn()
|
|
1962
|
+
|
|
1963
|
+
const resolver = (): LoaderPlugin => {
|
|
1964
|
+
return {
|
|
1965
|
+
type: 'loader',
|
|
1966
|
+
validate(value) {
|
|
1967
|
+
validate(value)
|
|
1968
|
+
return false
|
|
1969
|
+
},
|
|
1970
|
+
async exec(value) {
|
|
1971
|
+
exec(value)
|
|
1972
|
+
return {
|
|
1973
|
+
ok: true,
|
|
1974
|
+
data: { message: 'Resolved document' },
|
|
1975
|
+
}
|
|
1976
|
+
},
|
|
1977
|
+
}
|
|
1978
|
+
}
|
|
1979
|
+
|
|
1980
|
+
await expect(bundle('hello', { treeShake: false, plugins: [resolver()] })).rejects.toThrow()
|
|
1981
|
+
|
|
1982
|
+
expect(validate).toHaveBeenCalledOnce()
|
|
1983
|
+
expect(validate.mock.calls[0][0]).toBe('hello')
|
|
1984
|
+
|
|
1985
|
+
expect(exec).not.toHaveBeenCalled()
|
|
1986
|
+
})
|
|
1987
|
+
|
|
1988
|
+
it('use load plugin to resolve external refs', async () => {
|
|
1989
|
+
const validate = vi.fn()
|
|
1990
|
+
const exec = vi.fn()
|
|
1991
|
+
|
|
1992
|
+
const resolver = (): LoaderPlugin => {
|
|
1993
|
+
return {
|
|
1994
|
+
type: 'loader',
|
|
1995
|
+
validate(value) {
|
|
1996
|
+
validate(value)
|
|
1997
|
+
return true
|
|
1998
|
+
},
|
|
1999
|
+
async exec(value) {
|
|
2000
|
+
exec(value)
|
|
2001
|
+
return {
|
|
2002
|
+
ok: true,
|
|
2003
|
+
data: { message: 'Resolved document' },
|
|
2004
|
+
}
|
|
2005
|
+
},
|
|
2006
|
+
}
|
|
2007
|
+
}
|
|
2008
|
+
|
|
2009
|
+
const result = await bundle({ $ref: 'hello' }, { treeShake: false, plugins: [resolver()] })
|
|
2010
|
+
|
|
2011
|
+
expect(validate).toHaveBeenCalledOnce()
|
|
2012
|
+
expect(exec).toHaveBeenCalledOnce()
|
|
2013
|
+
|
|
2014
|
+
expect(validate.mock.calls[0][0]).toBe('hello')
|
|
2015
|
+
expect(exec.mock.calls[0][0]).toBe('hello')
|
|
2016
|
+
|
|
2017
|
+
expect(result).toEqual({
|
|
2018
|
+
$ref: '#/x-ext/aaf4c61',
|
|
2019
|
+
'x-ext': {
|
|
2020
|
+
'aaf4c61': {
|
|
2021
|
+
message: 'Resolved document',
|
|
2022
|
+
},
|
|
2023
|
+
},
|
|
2024
|
+
})
|
|
2025
|
+
})
|
|
2026
|
+
|
|
2027
|
+
it('emits warning when there is no loader to resolve the external ref', async () => {
|
|
2028
|
+
resetConsoleSpies()
|
|
2029
|
+
const validate = vi.fn()
|
|
2030
|
+
const exec = vi.fn()
|
|
2031
|
+
|
|
2032
|
+
const resolver = (): LoaderPlugin => {
|
|
2033
|
+
return {
|
|
2034
|
+
type: 'loader',
|
|
2035
|
+
validate(value) {
|
|
2036
|
+
validate(value)
|
|
2037
|
+
return false
|
|
2038
|
+
},
|
|
2039
|
+
async exec(value) {
|
|
2040
|
+
exec(value)
|
|
2041
|
+
return {
|
|
2042
|
+
ok: true,
|
|
2043
|
+
data: { message: 'Resolved document' },
|
|
2044
|
+
}
|
|
2045
|
+
},
|
|
2046
|
+
}
|
|
2047
|
+
}
|
|
2048
|
+
|
|
2049
|
+
const result = await bundle({ $ref: 'hello' }, { treeShake: false, plugins: [resolver()] })
|
|
2050
|
+
|
|
2051
|
+
expect(validate).toHaveBeenCalledOnce()
|
|
2052
|
+
expect(validate.mock.calls[0][0]).toBe('hello')
|
|
2053
|
+
|
|
2054
|
+
expect(exec).not.toHaveBeenCalled()
|
|
2055
|
+
|
|
2056
|
+
expect(result).toEqual({ $ref: 'hello' })
|
|
2057
|
+
|
|
2058
|
+
expect(consoleWarnSpy).toHaveBeenCalledTimes(1)
|
|
2059
|
+
expect(consoleWarnSpy).toHaveBeenCalledWith(
|
|
2060
|
+
'Failed to resolve external reference "hello". The reference may be invalid, inaccessible, or missing a loader for this type of reference.',
|
|
2061
|
+
)
|
|
2062
|
+
})
|
|
2063
|
+
|
|
2064
|
+
it('lets plugins hook into nodes lifecycle #1', async () => {
|
|
2065
|
+
const onBeforeNodeProcessCallback = vi.fn()
|
|
2066
|
+
const onAfterNodeProcessCallback = vi.fn()
|
|
2067
|
+
|
|
2068
|
+
await bundle(
|
|
2069
|
+
{
|
|
2070
|
+
prop: {
|
|
2071
|
+
innerProp: 'string',
|
|
2072
|
+
},
|
|
2073
|
+
},
|
|
2074
|
+
{
|
|
2075
|
+
treeShake: false,
|
|
2076
|
+
plugins: [
|
|
2077
|
+
{
|
|
2078
|
+
type: 'lifecycle',
|
|
2079
|
+
onBeforeNodeProcess: onBeforeNodeProcessCallback,
|
|
2080
|
+
onAfterNodeProcess: onAfterNodeProcessCallback,
|
|
2081
|
+
},
|
|
2082
|
+
],
|
|
2083
|
+
},
|
|
2084
|
+
)
|
|
2085
|
+
|
|
2086
|
+
expect(onBeforeNodeProcessCallback).toHaveBeenCalledTimes(2)
|
|
2087
|
+
expect(onBeforeNodeProcessCallback.mock.calls[0][0]).toEqual({
|
|
2088
|
+
prop: {
|
|
2089
|
+
innerProp: 'string',
|
|
2090
|
+
},
|
|
2091
|
+
})
|
|
2092
|
+
expect(onBeforeNodeProcessCallback.mock.calls[0][1]).toEqual({
|
|
2093
|
+
path: [],
|
|
2094
|
+
resolutionCache: new Map(),
|
|
2095
|
+
parentNode: null,
|
|
2096
|
+
rootNode: {
|
|
2097
|
+
prop: {
|
|
2098
|
+
innerProp: 'string',
|
|
2099
|
+
},
|
|
2100
|
+
},
|
|
2101
|
+
loaders: [],
|
|
2102
|
+
})
|
|
2103
|
+
expect(onBeforeNodeProcessCallback.mock.calls[1][0]).toEqual({
|
|
2104
|
+
innerProp: 'string',
|
|
2105
|
+
})
|
|
2106
|
+
expect(onBeforeNodeProcessCallback.mock.calls[1][1]).toEqual({
|
|
2107
|
+
path: ['prop'],
|
|
2108
|
+
resolutionCache: new Map(),
|
|
2109
|
+
parentNode: {
|
|
2110
|
+
prop: {
|
|
2111
|
+
innerProp: 'string',
|
|
2112
|
+
},
|
|
2113
|
+
},
|
|
2114
|
+
rootNode: {
|
|
2115
|
+
prop: {
|
|
2116
|
+
innerProp: 'string',
|
|
2117
|
+
},
|
|
2118
|
+
},
|
|
2119
|
+
loaders: [],
|
|
2120
|
+
})
|
|
2121
|
+
expect(onAfterNodeProcessCallback).toHaveBeenCalledTimes(2)
|
|
2122
|
+
expect(onAfterNodeProcessCallback.mock.calls[0][0]).toEqual({
|
|
2123
|
+
innerProp: 'string',
|
|
2124
|
+
})
|
|
2125
|
+
expect(onAfterNodeProcessCallback.mock.calls[0][1]).toEqual({
|
|
2126
|
+
path: ['prop'],
|
|
2127
|
+
resolutionCache: new Map(),
|
|
2128
|
+
parentNode: {
|
|
2129
|
+
prop: {
|
|
2130
|
+
innerProp: 'string',
|
|
2131
|
+
},
|
|
2132
|
+
},
|
|
2133
|
+
rootNode: {
|
|
2134
|
+
prop: {
|
|
2135
|
+
innerProp: 'string',
|
|
2136
|
+
},
|
|
2137
|
+
},
|
|
2138
|
+
loaders: [],
|
|
2139
|
+
})
|
|
2140
|
+
expect(onAfterNodeProcessCallback.mock.calls[1][0]).toEqual({
|
|
2141
|
+
prop: {
|
|
2142
|
+
innerProp: 'string',
|
|
2143
|
+
},
|
|
2144
|
+
})
|
|
2145
|
+
expect(onAfterNodeProcessCallback.mock.calls[1][1]).toEqual({
|
|
2146
|
+
path: [],
|
|
2147
|
+
resolutionCache: new Map(),
|
|
2148
|
+
parentNode: null,
|
|
2149
|
+
rootNode: {
|
|
2150
|
+
prop: {
|
|
2151
|
+
innerProp: 'string',
|
|
2152
|
+
},
|
|
2153
|
+
},
|
|
2154
|
+
loaders: [],
|
|
2155
|
+
})
|
|
2156
|
+
})
|
|
2157
|
+
|
|
2158
|
+
it('lets plugins hook into nodes lifecycle #2', async () => {
|
|
2159
|
+
const validate = vi.fn()
|
|
2160
|
+
const exec = vi.fn()
|
|
2161
|
+
const onResolveStart = vi.fn()
|
|
2162
|
+
const onResolveError = vi.fn()
|
|
2163
|
+
const onResolveSuccess = vi.fn()
|
|
2164
|
+
await bundle(
|
|
2165
|
+
{
|
|
2166
|
+
hello: {
|
|
2167
|
+
$ref: 'some-value',
|
|
2168
|
+
},
|
|
2169
|
+
hi: {
|
|
2170
|
+
$ref: 'resolve',
|
|
2171
|
+
},
|
|
2172
|
+
},
|
|
2173
|
+
{
|
|
2174
|
+
treeShake: false,
|
|
2175
|
+
plugins: [
|
|
2176
|
+
{
|
|
2177
|
+
type: 'loader',
|
|
2178
|
+
validate(value) {
|
|
2179
|
+
validate()
|
|
2180
|
+
if (value === 'resolve') {
|
|
2181
|
+
return true
|
|
2182
|
+
}
|
|
2183
|
+
return false
|
|
2184
|
+
},
|
|
2185
|
+
async exec(value) {
|
|
2186
|
+
exec()
|
|
2187
|
+
return {
|
|
2188
|
+
ok: true,
|
|
2189
|
+
data: {
|
|
2190
|
+
message: 'Resolved value',
|
|
2191
|
+
'x-original-value': value,
|
|
2192
|
+
},
|
|
2193
|
+
}
|
|
2194
|
+
},
|
|
2195
|
+
},
|
|
2196
|
+
{
|
|
2197
|
+
type: 'lifecycle',
|
|
2198
|
+
onResolveStart,
|
|
2199
|
+
onResolveError,
|
|
2200
|
+
onResolveSuccess,
|
|
2201
|
+
},
|
|
2202
|
+
],
|
|
2203
|
+
},
|
|
2204
|
+
)
|
|
2205
|
+
|
|
2206
|
+
expect(validate).toHaveBeenCalledTimes(2)
|
|
2207
|
+
expect(exec).toHaveBeenCalledOnce()
|
|
2208
|
+
|
|
2209
|
+
expect(onResolveStart).toHaveBeenCalledTimes(2)
|
|
2210
|
+
expect(onResolveStart.mock.calls[0][0]).toEqual({
|
|
2211
|
+
$ref: 'some-value',
|
|
2212
|
+
})
|
|
2213
|
+
expect(onResolveStart.mock.calls[1][0]).toEqual({
|
|
2214
|
+
$ref: '#/x-ext/4e7a208',
|
|
2215
|
+
})
|
|
2216
|
+
expect(onResolveError).toHaveBeenCalledTimes(1)
|
|
2217
|
+
expect(onResolveError.mock.calls[0][0]).toEqual({
|
|
2218
|
+
$ref: 'some-value',
|
|
2219
|
+
})
|
|
2220
|
+
expect(onResolveSuccess).toHaveBeenCalledTimes(1)
|
|
2221
|
+
expect(onResolveSuccess.mock.calls[0][0]).toEqual({
|
|
2222
|
+
$ref: '#/x-ext/4e7a208',
|
|
2223
|
+
})
|
|
2224
|
+
})
|
|
2225
|
+
|
|
2226
|
+
it('correctly provides the parent node in different levels', async () => {
|
|
2227
|
+
const onBeforeNodeProcess = vi.fn()
|
|
2228
|
+
const input = {
|
|
2229
|
+
a: {
|
|
2230
|
+
b: {
|
|
2231
|
+
c: {
|
|
2232
|
+
someNode: 'hello world',
|
|
2233
|
+
},
|
|
2234
|
+
},
|
|
2235
|
+
},
|
|
2236
|
+
d: {
|
|
2237
|
+
$ref: '#/a',
|
|
2238
|
+
},
|
|
2239
|
+
e: {
|
|
2240
|
+
f: {
|
|
2241
|
+
$ref: '#/a/b/c',
|
|
2242
|
+
},
|
|
2243
|
+
},
|
|
2244
|
+
}
|
|
2245
|
+
|
|
2246
|
+
await bundle(input, {
|
|
2247
|
+
plugins: [
|
|
2248
|
+
{
|
|
2249
|
+
type: 'lifecycle',
|
|
2250
|
+
onBeforeNodeProcess,
|
|
2251
|
+
},
|
|
2252
|
+
],
|
|
2253
|
+
treeShake: false,
|
|
2254
|
+
})
|
|
2255
|
+
|
|
2256
|
+
expect(onBeforeNodeProcess).toHaveBeenCalled()
|
|
2257
|
+
|
|
2258
|
+
// First call should be the root with a null parent
|
|
2259
|
+
expect(onBeforeNodeProcess.mock.calls[0][0]).toEqual(input)
|
|
2260
|
+
expect(onBeforeNodeProcess.mock.calls[0][1].parentNode).toEqual(null)
|
|
2261
|
+
|
|
2262
|
+
expect(onBeforeNodeProcess.mock.calls[1][0]).toEqual(input.a)
|
|
2263
|
+
expect(onBeforeNodeProcess.mock.calls[1][1].parentNode).toEqual(input)
|
|
2264
|
+
|
|
2265
|
+
expect(onBeforeNodeProcess.mock.calls[2][0]).toEqual(input.d)
|
|
2266
|
+
expect(onBeforeNodeProcess.mock.calls[2][1].parentNode).toEqual(input)
|
|
2267
|
+
|
|
2268
|
+
expect(onBeforeNodeProcess.mock.calls[3][0]).toEqual(input.e)
|
|
2269
|
+
expect(onBeforeNodeProcess.mock.calls[3][1].parentNode).toEqual(input)
|
|
2270
|
+
|
|
2271
|
+
expect(onBeforeNodeProcess.mock.calls[4][0]).toEqual(input.a.b)
|
|
2272
|
+
expect(onBeforeNodeProcess.mock.calls[4][1].parentNode).toEqual(input.a)
|
|
2273
|
+
|
|
2274
|
+
expect(onBeforeNodeProcess.mock.calls[5][0]).toEqual(input.e.f)
|
|
2275
|
+
expect(onBeforeNodeProcess.mock.calls[5][1].parentNode).toEqual(input.e)
|
|
2276
|
+
|
|
2277
|
+
expect(onBeforeNodeProcess.mock.calls[6][0]).toEqual(input.a.b.c)
|
|
2278
|
+
expect(onBeforeNodeProcess.mock.calls[6][1].parentNode).toEqual(input.a.b)
|
|
2279
|
+
})
|
|
2280
|
+
|
|
2281
|
+
it('correctly provides the parent node on partial bundle for referenced nodes', async () => {
|
|
2282
|
+
const onBeforeNodeProcess = vi.fn()
|
|
2283
|
+
|
|
2284
|
+
const input = {
|
|
2285
|
+
a: {
|
|
2286
|
+
b: 'some-prop',
|
|
2287
|
+
},
|
|
2288
|
+
b: {
|
|
2289
|
+
c: {
|
|
2290
|
+
$ref: '#/a',
|
|
2291
|
+
},
|
|
2292
|
+
},
|
|
2293
|
+
}
|
|
2294
|
+
|
|
2295
|
+
await bundle(input.b, {
|
|
2296
|
+
treeShake: false,
|
|
2297
|
+
root: input,
|
|
2298
|
+
plugins: [
|
|
2299
|
+
{
|
|
2300
|
+
type: 'lifecycle',
|
|
2301
|
+
onBeforeNodeProcess,
|
|
2302
|
+
},
|
|
2303
|
+
],
|
|
2304
|
+
})
|
|
2305
|
+
|
|
2306
|
+
expect(onBeforeNodeProcess).toHaveBeenCalled()
|
|
2307
|
+
expect(onBeforeNodeProcess.mock.calls[0][0]).toEqual(input.b)
|
|
2308
|
+
expect(onBeforeNodeProcess.mock.calls[0][1].parentNode).toEqual(null)
|
|
2309
|
+
|
|
2310
|
+
expect(onBeforeNodeProcess.mock.calls[1][0]).toEqual(input.b.c)
|
|
2311
|
+
expect(onBeforeNodeProcess.mock.calls[1][1].parentNode).toEqual(input.b)
|
|
2312
|
+
|
|
2313
|
+
expect(onBeforeNodeProcess.mock.calls[2][0]).toEqual(input.a)
|
|
2314
|
+
expect(onBeforeNodeProcess.mock.calls[2][1].parentNode).toEqual(input)
|
|
2315
|
+
})
|
|
2316
|
+
})
|
|
1767
2317
|
})
|
|
1768
2318
|
|
|
1769
2319
|
describe('isRemoteUrl', () => {
|