Skip to content

Commit

Permalink
feat(pr): remove diff comment (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamin-guibert authored Jan 26, 2024
1 parent 611452b commit 0e4a16a
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 1,770 deletions.
43 changes: 1 addition & 42 deletions __tests__/libs/release-notes.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import {
createReleasePullRequestBody,
getDiffMarkdown,
} from "../../src/libs/release-notes";
import { createReleasePullRequestBody } from "../../src/libs/release-notes";

describe("createReleasePullRequestBody()", () => {
it("should return notes", () => {
Expand Down Expand Up @@ -47,41 +44,3 @@ describe("createReleasePullRequestBody()", () => {
expect(result).toEqual("Line 1\n## Line 2\n");
});
});

describe("getDiffMarkdown()", () => {
it("should return diff when adds", () => {
const oldContent = ["Line 1", "Line 2"].join("\n");
const newContent = ["Line 1", "Line 2", "Line 3"].join("\n");

const result = getDiffMarkdown(oldContent, newContent);

expect(result).toEqual("```diff\n+ Line 3\n```");
});

it("should return diff when changes", () => {
const oldContent = ["Line 1", "Line 2", "", "Line 3"].join("\n");
const newContent = ["Line 1", "Line 1a", "", "Line 3"].join("\n");

const result = getDiffMarkdown(oldContent, newContent);

expect(result).toEqual("```diff\n- Line 2\n+ Line 1a\n```");
});

it("should return `null` when no changes", () => {
const oldContent = ["Line 1", "Line 2", "", "Line 3"].join("\n");
const newContent = ["Line 1", "Line 2", "", "Line 3"].join("\n");

const result = getDiffMarkdown(oldContent, newContent);

expect(result).toEqual(null);
});

it("should return `null` when empty", () => {
const oldContent = "";
const newContent = " ";

const result = getDiffMarkdown(oldContent, newContent);

expect(result).toEqual(null);
});
});
18 changes: 3 additions & 15 deletions __tests__/prepare.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -606,13 +606,7 @@ describe("main()", () => {
pull_number: 1,
body: "Release notes\n\n- title (#4)\n- title (#5)\n- title (#6)\n- title (#7)\n\nThe end.",
});
expect(octokit.rest.issues.createComment).toHaveBeenCalledTimes(1);
expect(octokit.rest.issues.createComment).toHaveBeenCalledWith({
owner: "owner",
repo: "repository",
issue_number: 1,
body: "Content has been updated:\n\n```diff\n+ - title (#6)\n+ - title (#7)\n```",
});
expect(octokit.rest.issues.createComment).toHaveBeenCalledTimes(0);
});

it("should prepare when changes (new version)", async () => {
Expand Down Expand Up @@ -691,13 +685,7 @@ describe("main()", () => {
pull_number: 1,
body: "Release notes\n\n- title (#4)\n- title (#5)\n- title (#6)\n- title (#7)\n\nThe end.",
});
expect(octokit.rest.issues.createComment).toHaveBeenCalledTimes(1);
expect(octokit.rest.issues.createComment).toHaveBeenCalledWith({
owner: "owner",
repo: "repository",
issue_number: 1,
body: "Content has been updated:\n\n```diff\n+ - title (#6)\n+ - title (#7)\n```",
});
expect(octokit.rest.issues.createComment).toHaveBeenCalledTimes(0);
});

it("should prepare when only change is pre-release", async () => {
Expand Down Expand Up @@ -762,7 +750,7 @@ describe("main()", () => {
owner: "owner",
repo: "repository",
issue_number: 1,
body: "Version `1.3.0-beta.0` has been manually requested by @actor.\n\nContent has been updated:\n\n```diff\n+ - title (#6)\n+ - title (#7)\n```",
body: "Version `1.3.0-beta.0` has been manually requested by @actor.",
});
});
});
Expand Down
Loading

0 comments on commit 0e4a16a

Please sign in to comment.