1
0
Fork 0
mirror of https://code.forgejo.org/actions/git-backporting synced 2025-03-14 22:27:02 +01:00
git-backporting/test/service/git/github/github-service.test.ts
Andrea Lamparelli b3936e019a feat: pull request backporting
feat: backport still open pull requests
2023-01-05 11:41:14 +01:00

40 lines
No EOL
1.3 KiB
TypeScript

import GitServiceFactory from "@bp/service/git/git-service-factory";
import { GitPullRequest, GitServiceType } from "@bp/service/git/git.types";
import GitHubService from "@bp/service/git/github/github-service";
import { mergedPullRequestFixture, repo, targetOwner } from "../../../support/moctokit/moctokit-data";
import { setupMoctokit } from "../../../support/moctokit/moctokit-support";
describe("github service", () => {
let gitService: GitHubService;
beforeAll(() => {
// init git service
GitServiceFactory.init(GitServiceType.GITHUB, "whatever");
});
beforeEach(() => {
// mock github api calls
setupMoctokit();
gitService = GitServiceFactory.getService() as GitHubService;
});
test("get pull request: success", async () => {
const res: GitPullRequest = await gitService.getPullRequest(targetOwner, repo, mergedPullRequestFixture.number);
expect(res.sourceRepo).toEqual({
owner: "fork",
project: "reponame",
cloneUrl: "https://github.com/fork/reponame.git"
});
expect(res.targetRepo).toEqual({
owner: "owner",
project: "reponame",
cloneUrl: "https://github.com/owner/reponame.git"
});
expect(res.title).toBe("PR Title");
expect(res.commits.length).toBe(1);
expect(res.commits).toEqual(["28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc"]);
});
});