-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtest.js
45 lines (43 loc) · 1.25 KB
/
test.js
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
import test from "ava";
import rollupPluginRewriteImport from "./index";
function rollupTestMacro(t, input, expected) {
const { renderChunk } = rollupPluginRewriteImport("example/");
const processedInput = renderChunk(input);
const expectedResult = expected
? {
code: expected
}
: expected;
t.deepEqual(processedInput, expectedResult);
}
rollupTestMacro.title = (_, input, expected) =>
`${input} becomes ${expected}`.trim();
test(
rollupTestMacro,
'import _ from "lodash";',
'import _ from "example/lodash";'
);
test(
rollupTestMacro,
'import _ from "lodash"',
'import _ from "example/lodash"'
);
test(rollupTestMacro, 'import "side-effect";', 'import "example/side-effect";');
test(rollupTestMacro, 'import "side-effect"', 'import "example/side-effect"');
test(
rollupTestMacro,
'import("side-effect");',
'import("example/side-effect");'
);
test(rollupTestMacro, 'import("side-effect")', 'import("example/side-effect")');
test(
rollupTestMacro,
'const _ = await import("lodash");',
'const _ = await import("example/lodash");'
);
test(
rollupTestMacro,
'const _ = await import("lodash")',
'const _ = await import("example/lodash")'
);
test(rollupTestMacro, 'let variable = importLikeFunctionName("test")', null);