Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 1f85c01

Browse files
committedAug 29, 2021
add more tests
1 parent fc176c4 commit 1f85c01

File tree

2 files changed

+30
-13
lines changed

2 files changed

+30
-13
lines changed
 

‎test/es-module/test-esm-dynamic-import-assertion.mjs

+21-13
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,40 @@
22
import '../common/index.mjs';
33
import { rejects, strictEqual } from 'assert';
44

5-
const jsModuleUrl = 'data:text/javascript,export{}';
5+
const jsModuleDataUrl = 'data:text/javascript,export{}';
66

77
await rejects(
8-
import(`data:text/javascript,import${JSON.stringify(jsModuleUrl)}assert{type:"json"}`),
8+
import(`data:text/javascript,import${JSON.stringify(jsModuleDataUrl)}assert{type:"json"}`),
99
{ code: 'ERR_FAILED_IMPORT_ASSERTION' }
1010
);
1111

1212
await rejects(
13-
import(jsModuleUrl, {assert:{type:'json'}}),
13+
import(jsModuleDataUrl, { assert: { type: 'json' } }),
1414
{ code: 'ERR_FAILED_IMPORT_ASSERTION' }
1515
);
1616

1717
{
18-
const secret = await import(
19-
'../fixtures/experimental.json',
20-
{assert: { type: 'json' }}
21-
);
18+
const [secret0, secret1] = await Promise.all([
19+
import('../fixtures/experimental.json'),
20+
import(
21+
'../fixtures/experimental.json',
22+
{ assert: { type: 'json' } }
23+
),
24+
]);
2225

23-
strictEqual(secret.default.ofLife, 42);
26+
strictEqual(secret0.default.ofLife, 42);
27+
strictEqual(secret1.default.ofLife, 42);
2428
}
2529

2630
{
27-
const secret = await import(
28-
'data:application/json,{"ofLife":42}',
29-
{assert: { type: 'json' }}
30-
);
31+
const [secret0, secret1] = await Promise.all([
32+
import('data:application/json,{"ofLife":42}'),
33+
import(
34+
'data:application/json,{"ofLife":42}',
35+
{ assert: { type: 'json' } }
36+
),
37+
]);
3138

32-
strictEqual(secret.default.ofLife, 42);
39+
strictEqual(secret0.default.ofLife, 42);
40+
strictEqual(secret1.default.ofLife, 42);
3341
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Flags: --experimental-json-modules
2+
import '../common/index.mjs';
3+
import { strictEqual } from 'assert';
4+
5+
import secret0 from '../fixtures/experimental.json' assert { type: 'json' };
6+
import secret1 from '../fixtures/experimental.json';
7+
8+
strictEqual(secret0.ofLife, 42);
9+
strictEqual(secret1.ofLife, 42);

0 commit comments

Comments
 (0)
Please sign in to comment.