forked from Autodesk/hig
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreateExternalDeterminer.test.js
56 lines (49 loc) · 1.35 KB
/
createExternalDeterminer.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
46
47
48
49
50
51
52
53
54
55
56
import createExternalDeterminer from "./createExternalDeterminer";
describe("scripts/createExternalDeterminer", () => {
const externalDependencies = Object.freeze(["foo", "bar", "@scoped/foo"]);
it("creates a function", () => {
const determiner = createExternalDeterminer(externalDependencies);
expect(determiner).toEqual(expect.any(Function));
});
describe("determiner", () => {
let determiner;
beforeEach(() => {
determiner = createExternalDeterminer(externalDependencies);
});
[
{
moduleName: "./relative/module/path",
isExternal: false
},
{
moduleName: "../parent/directory",
isExternal: false
},
{
moduleName: "foo",
isExternal: true
},
{
moduleName: "foo/module-random.css",
isExternal: false
},
{
moduleName: "dependency/module-random.js",
isExternal: false
},
{
moduleName: "@scoped/foo/hello",
isExternal: true
},
{
moduleName: "@scoped/foo",
isExternal: true
}
].forEach(({ moduleName, isExternal }) => {
const prediction = isExternal ? "external" : "not external";
it(`determines that "${moduleName}" is ${prediction}`, () => {
expect(determiner(moduleName)).toEqual(isExternal);
});
});
});
});