Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
RamIdeas committed Sep 27, 2024
1 parent 107eae2 commit 78009d9
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import { writeFileSync } from "fs";
import dedent from "ts-dedent";
import { beforeEach, describe, it, vitest } from "vitest";
import {
commitAndPush,
generateChangesetHeader,
generateCommitMessage,
getPackageJsonDiff,
gitCommit,
gitPush,
parseDiffForChanges,
writeChangeSet,
} from "../generate-dependabot-pr-changesets";
Expand Down Expand Up @@ -157,10 +158,10 @@ describe("writeChangeSet()", () => {
| some-package | ^0.0.1 | ^0.0.2 |
| @namespace/some-package | 1.3.4 | 1.4.5 |
`;
writeChangeSet("some-prefix", "1234", header, body);
writeChangeSet("1234", "pkgName", header, body);
expect(writeFileSync).toHaveBeenCalledOnce();
expect((writeFileSync as Mock).mock.lastCall?.[0]).toMatchInlineSnapshot(
`".changeset/some-prefix-1234.md"`
`".changeset/dependabot-update-pkgName-1234.md"`
);
expect((writeFileSync as Mock).mock.lastCall?.[1]).toMatchInlineSnapshot(`
"---
Expand Down Expand Up @@ -190,7 +191,8 @@ describe("commitAndPush()", () => {
| ----------------------- | ------ | ------ |
| some-package | ^0.0.1 | ^0.0.2 |
| @namespace/some-package | 1.3.4 | 1.4.5 |`;
commitAndPush(commitMessage);
gitCommit(commitMessage);
gitPush();
expect(spawnSync).toHaveBeenCalledTimes(3);
expect((spawnSync as Mock).mock.calls[0]).toMatchInlineSnapshot(`
[
Expand Down Expand Up @@ -242,8 +244,6 @@ describe("commitAndPush()", () => {
args[0] === "push" ? new Error("Failed to push") : undefined;
return { output: [], error };
});
expect(() =>
commitAndPush("commit message")
).toThrowErrorMatchingInlineSnapshot(`[Error: Failed to push]`);
expect(() => gitPush()).toThrowErrorMatchingInlineSnapshot(`[Error: Failed to push]`);
});
});

0 comments on commit 78009d9

Please sign in to comment.