forked from jspm/jspm-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathownname.test.ts
53 lines (49 loc) · 1.93 KB
/
ownname.test.ts
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
import assert from "assert";
import { type Scenario, mapDirectory, runScenarios } from "./scenarios";
const filesOwnName = await mapDirectory("test/fixtures/scenario_ownname");
const scenarios: Scenario[] = [
{
files: filesOwnName,
commands: ["jspm install app"],
validationFn: async (files: Map<string, string>) => {
// Installing the own-name package "app" should result in the version of
// es-module-lexer in the import map being upgraded to 1.2.2, since it's a
// transitive dependency of "./app.js".
const map = JSON.parse(files.get("importmap.json"));
assert(
map?.imports?.["es-module-lexer"]?.includes("[email protected]")
);
},
},
{
files: filesOwnName,
commands: ["jspm link ./app.js -o outputmap.json"],
validationFn: async (files: Map<string, string>) => {
// Tracing the local module ./app.js should result in a top-level import
// of [email protected], as that is the version in the input map,
// even though the package.json has a version constraint of ^1. This is
// because we treat the input map as a lockfile:
const map = JSON.parse(files.get("outputmap.json"));
assert(
map?.imports?.["es-module-lexer"]?.includes("[email protected]")
);
},
},
{
files: filesOwnName,
commands: ["jspm link app -o outputmap.json"],
validationFn: async (files: Map<string, string>) => {
// If we trace the own-name package "app" instead, we should get the same
// result, as the package.json has an export for "app" -> "./app.js":
const map = JSON.parse(files.get("outputmap.json"));
// TODO: once we fully implement re-entrant primary scope in the generator
// we should be able to check map.imports rather:
assert(
map?.scopes?.["./"]?.["es-module-lexer"]?.includes(
)
);
},
},
];
runScenarios(scenarios);