From 0c015d9eeaafc49941cb9e0f56efd6825218e19c Mon Sep 17 00:00:00 2001 From: marocchino Date: Sat, 23 Nov 2019 10:44:03 +0900 Subject: [PATCH] test: find & write with comment header --- __tests__/comment.test.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/__tests__/comment.test.ts b/__tests__/comment.test.ts index 5a14561..4a9b92d 100644 --- a/__tests__/comment.test.ts +++ b/__tests__/comment.test.ts @@ -4,17 +4,18 @@ import { updateComment } from "../src/comment"; const repo = {}; -const body = "some message"; it("findPreviousComment", async () => { const comment = { user: { login: "github-actions[bot]" - } + }, + body: "\nprevious message" }; const otherComment = { user: { login: "some-user" - } + }, + body: "lgtm" }; const octokit = { issues: { @@ -35,10 +36,12 @@ it("updateComment", async () => { updateComment: jest.fn(() => Promise.resolve()) } }; - expect(await updateComment(octokit, repo, 456, body)).toBeUndefined(); + expect( + await updateComment(octokit, repo, 456, "hello there") + ).toBeUndefined(); expect(octokit.issues.updateComment).toBeCalledWith({ comment_id: 456, - body + body: "\nhello there" }); }); it("createComment", async () => { @@ -47,9 +50,11 @@ it("createComment", async () => { createComment: jest.fn(() => Promise.resolve()) } }; - expect(await createComment(octokit, repo, 456, body)).toBeUndefined(); + expect( + await createComment(octokit, repo, 456, "hello there") + ).toBeUndefined(); expect(octokit.issues.createComment).toBeCalledWith({ issue_number: 456, - body + body: "\nhello there" }); });