Skip to content

Commit

Permalink
feat: feature test for PullRequestReviewerRemoved event done
Browse files Browse the repository at this point in the history
  • Loading branch information
skywarth committed Jun 26, 2024
1 parent 9131b2b commit 1c86ba5
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 1 deletion.
2 changes: 1 addition & 1 deletion test/feature/PullRequest/pullRequestReviewerAdded.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {StrategyTestSetup} from "../strategyTestSetup";
import PullRequestReviewerAdded from "../../../src/ActionHandler/PullRequest/PullRequestReviewerAdded";


import pullRequestReviewerAddedPayload from '../../fixtures/events/pull_request/pull_request.reviewer.added.json';
import pullRequestReviewerAddedPayload from '../../fixtures/events/pull_request/reviewer/pull_request.reviewer.added.json';


describe("Pull Request Opened Tests", () => {
Expand Down
44 changes: 44 additions & 0 deletions test/feature/PullRequest/pullRequestReviewerRemoved.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import {describe, test, afterEach, vi, beforeAll} from "vitest";
import {CaseSlugs} from "../../../src/enums/CaseSlug";
import {StrategyTestSetup} from "../strategyTestSetup";
import PullRequestReviewerRemoved from "../../../src/ActionHandler/PullRequest/PullRequestReviewerRemoved";

import pullRequestReviewerRemovedPayload from '../../fixtures/events/pull_request/reviewer/pull_request.reviewer.removed.json';



describe("Pull Request Opened Tests", () => {
const strategyTestSetup = new StrategyTestSetup();

beforeAll(() => {
strategyTestSetup.beforeAll();
});

afterEach(() => {
strategyTestSetup.afterEach();
});

describe.each([
{
description: "Reviewer removed",
expectedCaseSlug: CaseSlugs.PullRequest.Reviewer.Removed,
}
])('$description', ({ expectedCaseSlug }) => {
test.only('Creates a comment after receiving the event', async () => {

strategyTestSetup.actionStrategyHandleSpy = vi.spyOn(PullRequestReviewerRemoved.prototype as any, 'handle');


await strategyTestSetup.probot.receive({
id: '123',
name: 'pull_request',
payload: pullRequestReviewerRemovedPayload as any,
});


strategyTestSetup.performCommonAssertions(expectedCaseSlug);


});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"action": "review_request_removed",
"pull_request": {
"id": 1,
"number": 555444,
"state": "open",
"title": "Test Pull Request",
"user": {
"login": "test-user"
},
"head": {
"ref": "some-side-branch-123"
},
"base": {
"ref": "master"
},
"body": "This is a test pull request",
"created_at": "2024-01-01T00:00:00Z",
"updated_at": "2024-01-01T00:00:00Z"
},
"requested_reviewer": {
"login": "reviewer-user"
},
"repository": {
"name": "test-repo",
"owner": {
"login": "test-owner"
}
},
"sender": {
"login": "test-user",
"type": "User"
},
"installation": {
"id": 1
},
"isBot": false
}

0 comments on commit 1c86ba5

Please sign in to comment.