Skip to content

Commit

Permalink
test(lib/update): add tests for ignore and only options
Browse files Browse the repository at this point in the history
  • Loading branch information
hasundue committed Nov 21, 2023
1 parent a6df7f8 commit d1cfca0
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 0 deletions.
24 changes: 24 additions & 0 deletions lib/update_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,30 @@ describe("DependencyUpdate", () => {
await assertUpdateSnapshot(t, update);
}
});
it("ignore a dependency", async (t) => {
const updates = await DependencyUpdate.collect(
"./test/data/multiple_imports.ts",
{
ignore: (dep) => dep.name === "node-emoji",
},
);
assertEquals(updates.length, 2);
for (const update of updates) {
await assertUpdateSnapshot(t, update);
}
});
it("only update a specified dependency", async (t) => {
const updates = await DependencyUpdate.collect(
"./test/data/multiple_imports.ts",
{
only: (dep) => dep.name.includes("deno_graph"),
},
);
assertEquals(updates.length, 1);
for (const update of updates) {
await assertUpdateSnapshot(t, update);
}
});
});

describe("getVersionChange()", () => {
Expand Down
90 changes: 90 additions & 0 deletions test/snapshots/update_test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -389,3 +389,93 @@ snapshot[`DependencyUpdate > collect() > updated import and outdated export 1`]
},
}
`;

snapshot[`DependencyUpdate > collect() > ignore a dependency 1`] = `
{
code: {
span: {
end: {
character: 71,
line: 0,
},
start: {
character: 23,
line: 0,
},
},
specifier: "https://deno.land/std@0.200.0/assert/assert.ts",
},
from: {
name: "deno.land/std",
path: "/assert/assert.ts",
scheme: "https://",
version: "0.200.0",
},
to: {
name: "deno.land/std",
path: "/assert/assert.ts",
scheme: "https://",
version: "123.456.789",
},
}
`;

snapshot[`DependencyUpdate > collect() > ignore a dependency 2`] = `
{
code: {
span: {
end: {
character: 74,
line: 1,
},
start: {
character: 28,
line: 1,
},
},
specifier: "https://deno.land/x/deno_graph@0.50.0/mod.ts",
},
from: {
name: "deno.land/x/deno_graph",
path: "/mod.ts",
scheme: "https://",
version: "0.50.0",
},
to: {
name: "deno.land/x/deno_graph",
path: "/mod.ts",
scheme: "https://",
version: "123.456.789",
},
}
`;

snapshot[`DependencyUpdate > collect() > only update a specified dependency 1`] = `
{
code: {
span: {
end: {
character: 74,
line: 1,
},
start: {
character: 28,
line: 1,
},
},
specifier: "https://deno.land/x/deno_graph@0.50.0/mod.ts",
},
from: {
name: "deno.land/x/deno_graph",
path: "/mod.ts",
scheme: "https://",
version: "0.50.0",
},
to: {
name: "deno.land/x/deno_graph",
path: "/mod.ts",
scheme: "https://",
version: "123.456.789",
},
}
`;

0 comments on commit d1cfca0

Please sign in to comment.