generated from Bullrich/parity-action-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added configuration parameter to enable to update every branch and not only PRs that have auto-merge enabled. It will also skip `draft` pull requests (which would not in the case that the auto-merge requirement is set to disabled). Resolves #3
- Loading branch information
Showing
8 changed files
with
128 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { DeepMockProxy, mock, mockDeep, MockProxy } from "jest-mock-extended"; | ||
|
||
import { PullRequestApi } from "../github/pullRequest"; | ||
import { ActionLogger, GitHubClient } from "../github/types"; | ||
|
||
describe("Pull Request API Tests", () => { | ||
let api: PullRequestApi; | ||
let logger: MockProxy<ActionLogger>; | ||
let client: DeepMockProxy<GitHubClient>; | ||
beforeEach(() => { | ||
logger = mock<ActionLogger>(); | ||
client = mockDeep<GitHubClient>(); | ||
|
||
api = new PullRequestApi( | ||
client, | ||
{ owner: "owner", repo: "example" }, | ||
logger, | ||
); | ||
}); | ||
|
||
test("Should filter prs without auto-merge", async () => { | ||
const mockedPrs = [ | ||
{ number: 1, auto_merge: true, title: "one" }, | ||
{ number: 2, auto_merge: false, title: "two" }, | ||
]; | ||
client.paginate.mockResolvedValue(mockedPrs); | ||
const prs = await api.listPRs(true); | ||
expect(prs).toHaveLength(1); | ||
expect(prs).toContainEqual({ | ||
number: mockedPrs[0].number, | ||
title: mockedPrs[0].title, | ||
}); | ||
expect(prs).not.toContainEqual({ | ||
number: mockedPrs[1].number, | ||
title: mockedPrs[1].title, | ||
}); | ||
}); | ||
|
||
test("Should return all prs without filter", async () => { | ||
const mockedPrs = [ | ||
{ number: 1, auto_merge: true, title: "one" }, | ||
{ number: 2, auto_merge: false, title: "two" }, | ||
]; | ||
client.paginate.mockResolvedValue(mockedPrs); | ||
const prs = await api.listPRs(false); | ||
expect(prs).toHaveLength(2); | ||
expect(prs).toEqual([ | ||
{ number: mockedPrs[0].number, title: mockedPrs[0].title }, | ||
{ number: mockedPrs[1].number, title: mockedPrs[1].title }, | ||
]); | ||
}); | ||
|
||
test("Should filter drafts PRs", async () => { | ||
const mockedPrs = [ | ||
{ number: 1, auto_merge: false, title: "one" }, | ||
{ number: 2, auto_merge: false, draft: true, title: "two" }, | ||
]; | ||
client.paginate.mockResolvedValue(mockedPrs); | ||
const prs = await api.listPRs(false); | ||
expect(prs).toHaveLength(1); | ||
expect(prs).toContainEqual({ | ||
number: mockedPrs[0].number, | ||
title: mockedPrs[0].title, | ||
}); | ||
expect(prs).not.toContainEqual({ | ||
number: mockedPrs[1].number, | ||
title: mockedPrs[1].title, | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters