Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add a few more tests for top-level resolutions #264

Merged
merged 2 commits into from
Mar 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions test/api/localresolutions.test.js

This file was deleted.

48 changes: 45 additions & 3 deletions test/api/resolutions.test.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,59 @@
import { Generator } from "@jspm/generator";
import assert from "assert";

const generator = new Generator({
// Test primary resolutions:
let generator = new Generator({
mapUrl: import.meta.url,
env: ["production", "browser"],
resolutions: {
semver: "6.2.0",
},
});

await generator.install("@babel/core@7.16.0");
const json = generator.getMap();
await generator.install("semver@latest");
let json = generator.getMap();
assert.ok(json.imports["semver"]);
assert.ok(json.imports["semver"].includes("6.2.0"));

// Test primary resolutions with alias:
generator = new Generator({
mapUrl: import.meta.url,
env: ["production", "browser"],
resolutions: {
alias: "semver@6.2.0",
},
});

await generator.install("alias");
json = generator.getMap();
assert.ok(json.imports["alias"]);
assert.ok(json.imports["alias"].includes("6.2.0"));

// Test secondary resolutions:
generator = new Generator({
mapUrl: import.meta.url,
env: ["production", "browser"],
resolutions: {
semver: "6.2.0",
},
});

await generator.install("@babel/core@7.16.0");
json = generator.getMap();
assert.ok(json.imports["@babel/core"]);
assert.ok(Object.keys(json.scopes["https://ga.jspm.io/"]).length > 20);
assert.ok(json.scopes["https://ga.jspm.io/"]["semver"].includes("6.2.0"));

// Test local resolutions:
generator = new Generator({
baseUrl: new URL("../", import.meta.url),
mapUrl: import.meta.url,
env: ["production", "browser"],
resolutions: {
dep: "./api/local/react1",
},
});

await generator.install({ target: "./api/local/pkg", subpath: "./withdep" });
json = generator.getMap();
assert.strictEqual(json.scopes["./local/"].dep, "./local/react1/react1.js");