- pnpm workspace, shared tsconfig, vitest - common: ids, money (USDC base-unit math), Result/SettleKitError, time - domain types: product, customer, payment, entitlement, delivery, integration - 13 passing contract tests
29 lines
1018 B
TypeScript
29 lines
1018 B
TypeScript
import { describe, expect, it } from "vitest";
|
|
import type { GitHubRepoAccessGrant } from "@settlekit/common";
|
|
import { syncGitHubRepoGrant, type GitHubAccessClient } from "../src/index.js";
|
|
|
|
describe("syncGitHubRepoGrant", () => {
|
|
it("marks grants active when GitHub reports permission", async () => {
|
|
const client: GitHubAccessClient = {
|
|
async inviteRepoCollaborator() { return {}; },
|
|
async removeRepoCollaborator() {},
|
|
async addTeamMembership() {},
|
|
async removeTeamMembership() {},
|
|
async getRepoCollaboratorPermission() { return "read"; },
|
|
};
|
|
const grant = {
|
|
id: "ghra_1",
|
|
organizationId: "org_1",
|
|
installationId: 1,
|
|
customerId: "cus_1",
|
|
entitlementId: "ent_1",
|
|
repoOwner: "seller",
|
|
repoName: "repo",
|
|
githubUsername: "buyer",
|
|
status: "invited",
|
|
createdAt: "2026-01-01T00:00:00.000Z",
|
|
} satisfies GitHubRepoAccessGrant;
|
|
expect((await syncGitHubRepoGrant(client, grant)).status).toBe("active");
|
|
});
|
|
});
|