forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-esm-loader-stringify-text.mjs
More file actions
50 lines (49 loc) · 1.39 KB
/
test-esm-loader-stringify-text.mjs
File metadata and controls
50 lines (49 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Flags: --experimental-loader ./test/fixtures/es-module-loaders/string-sources.mjs
import { mustCall, mustNotCall } from '../common/index.mjs';
import assert from 'assert';
import('test:Array').then(
mustNotCall('Should not accept Arrays'),
mustCall((e) => {
assert.strictEqual(e.code, 'ERR_INVALID_RETURN_PROPERTY_VALUE');
})
);
import('test:ArrayBuffer').then(
mustCall(),
mustNotCall('Should accept ArrayBuffers'),
);
import('test:null').then(
mustNotCall('Should not accept null'),
mustCall((e) => {
assert.strictEqual(e.code, 'ERR_INVALID_RETURN_PROPERTY_VALUE');
})
);
import('test:Object').then(
mustNotCall('Should not stringify or valueOf Objects'),
mustCall((e) => {
assert.strictEqual(e.code, 'ERR_INVALID_RETURN_PROPERTY_VALUE');
})
);
import('test:SharedArrayBuffer').then(
mustCall(),
mustNotCall('Should accept SharedArrayBuffers'),
);
import('test:string').then(
mustCall(),
mustNotCall('Should accept strings'),
);
import('test:String').then(
mustNotCall('Should not accept wrapper Strings'),
mustCall((e) => {
assert.strictEqual(e.code, 'ERR_INVALID_RETURN_PROPERTY_VALUE');
})
);
import('test:Uint8Array').then(
mustCall(),
mustNotCall('Should accept Uint8Arrays'),
);
import('test:undefined').then(
mustNotCall('Should not accept undefined'),
mustCall((e) => {
assert.strictEqual(e.code, 'ERR_INVALID_RETURN_PROPERTY_VALUE');
})
);