Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(pr): remove diff comment #103

Merged
merged 1 commit into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading