mirror of
https://github.com/morluto/rea.git
synced 2026-12-06 17:23:37 +08:00
test(cli): share package relationship matchers (#17421)
This commit is contained in:
@@ -7,6 +7,9 @@ import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
||||
import { cliTest } from "../../support/cli/cliFixture.js";
|
||||
import { importReferenceSourceGraph } from "../../support/cli/referenceSource.js";
|
||||
|
||||
const mainRelationship = (to: string, resolution: "internal" | "unresolved") =>
|
||||
expect.objectContaining({ from_path: "main.cjs", to, resolution });
|
||||
|
||||
cliTest(
|
||||
"keeps package selection unknown when its manifest is excluded",
|
||||
async ({ cli }) => {
|
||||
@@ -43,11 +46,7 @@ cliTest(
|
||||
parse_state: "parsed",
|
||||
});
|
||||
expect(graph.relationships).not.toContainEqual(
|
||||
expect.objectContaining({
|
||||
from_path: "main.cjs",
|
||||
to: "pkg/index.js",
|
||||
resolution: "internal",
|
||||
}),
|
||||
mainRelationship("pkg/index.js", "internal"),
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -116,41 +115,17 @@ cliTest(
|
||||
});
|
||||
expect(graph.relationships).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
from_path: "main.cjs",
|
||||
to: "excluded",
|
||||
resolution: "unresolved",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
from_path: "main.cjs",
|
||||
to: "visible/lib/index.js",
|
||||
resolution: "internal",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
from_path: "main.cjs",
|
||||
to: "missing/index.js",
|
||||
resolution: "internal",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
from_path: "main.cjs",
|
||||
to: "ignored",
|
||||
resolution: "unresolved",
|
||||
}),
|
||||
mainRelationship("excluded", "unresolved"),
|
||||
mainRelationship("visible/lib/index.js", "internal"),
|
||||
mainRelationship("missing/index.js", "internal"),
|
||||
mainRelationship("ignored", "unresolved"),
|
||||
]),
|
||||
);
|
||||
expect(graph.relationships).not.toContainEqual(
|
||||
expect.objectContaining({
|
||||
from_path: "main.cjs",
|
||||
to: "excluded/index.js",
|
||||
resolution: "internal",
|
||||
}),
|
||||
mainRelationship("excluded/index.js", "internal"),
|
||||
);
|
||||
expect(graph.relationships).not.toContainEqual(
|
||||
expect.objectContaining({
|
||||
from_path: "main.cjs",
|
||||
to: "ignored/index.js",
|
||||
resolution: "internal",
|
||||
}),
|
||||
mainRelationship("ignored/index.js", "internal"),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user