-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathget-module-path-for.test.mjs
More file actions
67 lines (58 loc) · 1.81 KB
/
get-module-path-for.test.mjs
File metadata and controls
67 lines (58 loc) · 1.81 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
const { getModulePathFor } = require('./get-module-path-for');
import { describe, test, expect } from 'vitest';
describe('getModulePathFor', () => {
const addonPaths = {
'/User/whomever/some-app/lib/special-sauce': 'special-sauce',
};
const appPaths = {
'/User/whomever/some-app': 'some-app',
};
test('can determine the runtime module id for a specific on disk in-repo addon file', () => {
expect(
getModulePathFor(
'/User/whomever/some-app/lib/special-sauce/addon/components/fire-sauce.js',
addonPaths,
appPaths
)
).toEqual('special-sauce/components/fire-sauce');
expect(
getModulePathFor(
'/User/whomever/some-app/lib/special-sauce/addon-test-support/services/whatever.js',
addonPaths,
appPaths
)
).toEqual('special-sauce/test-support/services/whatever');
expect(
getModulePathFor(
'/User/whomever/some-app/lib/special-sauce/tests/dummy/app/services/fire-sauce.js',
addonPaths,
appPaths
)
).toEqual('dummy/services/fire-sauce');
});
test("does not process files in an in-repo addon's app/ folder", () => {
expect(
getModulePathFor(
'/User/whomever/some-app/lib/special-sauce/app/services/whatever.js',
addonPaths,
appPaths
)
).toEqual(undefined);
});
test('can determine the runtime module id for a file in the app itself', () => {
expect(
getModulePathFor(
'/User/whomever/some-app/app/services/something-here.js',
addonPaths,
appPaths
)
).toEqual('some-app/services/something-here');
expect(
getModulePathFor(
'/User/whomever/some-app/tests/mocks/something-here.js',
addonPaths,
appPaths
)
).toEqual('some-app/tests/mocks/something-here');
});
});