astro-ghostcms/.pnpm-store/v3/files/00/ab870c7d9f3ba93fd60e1c7949a...

119 lines
2.9 KiB
Plaintext
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { temporarilySilenceLogs } from "@changesets/test-utils";
import getDependencyGraph from "./get-dependency-graph";
const consoleError = console.error;
beforeEach(() => {
console.error = jest.fn();
});
afterEach(() => {
console.error = consoleError;
});
describe("getting the dependency graph", function () {
it("should skip dependencies specified through the link protocol", function () {
const { graph, valid } = getDependencyGraph({
root: {
dir: ".",
packageJson: { name: "root", version: "1.0.0" },
},
packages: [
{
dir: "foo",
packageJson: {
name: "foo",
version: "1.0.0",
devDependencies: {
bar: "link:../bar",
},
},
},
{
dir: "bar",
packageJson: {
name: "bar",
version: "1.0.0",
},
},
],
tool: "pnpm",
});
expect(graph.get("foo")!.dependencies).toStrictEqual([]);
expect(valid).toBeTruthy();
expect((console.error as any).mock.calls).toMatchInlineSnapshot(`[]`);
});
it("should skip dependencies specified using a tag", function () {
const { graph, valid } = getDependencyGraph({
root: {
dir: ".",
packageJson: { name: "root", version: "1.0.0" },
},
packages: [
{
dir: "examples/foo",
packageJson: {
name: "foo-example",
version: "1.0.0",
dependencies: {
bar: "latest",
},
},
},
{
dir: "packages/bar",
packageJson: {
name: "bar",
version: "1.0.0",
},
},
],
tool: "pnpm",
});
expect(graph.get("foo-example")!.dependencies).toStrictEqual([]);
expect(valid).toBeTruthy();
expect((console.error as any).mock.calls).toMatchInlineSnapshot(`[]`);
});
it(
"should set valid to false if the link protocol is used in a non-dev dep",
temporarilySilenceLogs(() => {
const { valid } = getDependencyGraph({
root: {
dir: ".",
packageJson: { name: "root", version: "1.0.0" },
},
packages: [
{
dir: "foo",
packageJson: {
name: "foo",
version: "1.0.0",
dependencies: {
bar: "link:../bar",
},
},
},
{
dir: "bar",
packageJson: {
name: "bar",
version: "1.0.0",
},
},
],
tool: "pnpm",
});
expect(valid).toBeFalsy();
expect((console.error as any).mock.calls).toMatchInlineSnapshot(`
[
[
"Package "foo" must depend on the current version of "bar": "1.0.0" vs "link:../bar"",
],
]
`);
})
);
});