Skip to content

Commit

Permalink
fix: clear core.summary mock
Browse files Browse the repository at this point in the history
  • Loading branch information
brenoepics committed Sep 29, 2024
1 parent 939d9f9 commit 54642e3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
11 changes: 11 additions & 0 deletions __tests__/comments.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,14 @@ describe("deleteOldComments", () => {

beforeEach(() => {
vi.clearAllMocks();
Object.defineProperty(core, "summary", {
value: { addRaw: vi.fn(), write: vi.fn() },
writable: true,
configurable: true
});
});


it("should delete old comments with watermark", async () => {
const comments = [
{ id: 1, body: `${watermark} Old comment` },
Expand Down Expand Up @@ -84,6 +90,11 @@ describe("commentOnPullRequest", () => {
(github.getOctokit as Mock).mockReturnValue(mockOctokit);
(core.getInput as Mock).mockReturnValue("token");
github.context.payload = { pull_request: { number: 1 } };
Object.defineProperty(core, "summary", {
value: { addRaw: vi.fn(), write: vi.fn() },
writable: true,
configurable: true
});
Object.defineProperty(github.context, "repo", {
value: { owner: "owner", repo: "repo" },
writable: true
Expand Down
6 changes: 6 additions & 0 deletions __tests__/parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,14 @@ describe("parseAnalysisOutput", () => {

beforeEach(() => {
vi.clearAllMocks();
Object.defineProperty(core, "summary", {
value: { addRaw: vi.fn(), write: vi.fn() },
writable: true,
configurable: true
});
});


it("should parse analysis output successfully", () => {
(fs.readFileSync as Mock).mockReturnValue(mockFileContent);

Expand Down

0 comments on commit 54642e3

Please sign in to comment.