Provides utilities for testing handlers.
test()
test(name: string, callback: () => void): void
import { type GitHubEvent, GitHubReasons } from "stacker/github"; import { test, equal, evalGitHubEvent } from "stacker/testing"; // Base event for tests const baseEvent: GitHubEvent = { title: "Issue", url: "https://github.com/placeholder/placeholder/issues/1", reason: "", type: "Issue", repository: { fullName: "placeholder/placeholder", name: "placeholder", url: "https://github.com/placeholder/placeholder", private: false, description: "A placeholder repository", fork: false, owner: { login: "placeholder", url: "https://github.com/placeholder", type: "User", siteAdmin: false } } }; test("Grafana repository with Subscribed reason", () => { const event: GitHubEvent = { ...baseEvent, reason: GitHubReasons.Subscribed, repository: { ...baseEvent.repository, owner: { ...baseEvent.repository.owner, login: "grafana" }, fullName: "grafana/k6", name: "k6" } }; const { stacks } = evalGitHubEvent(event); equal(stacks, ["work"]); });
evalGitHubEvent()
evalGitHubEvent(event: GitHubEvent): GitHubEvalResult
equal()
equal(a: any, b: any): void
genGitHubEvent()
genGitHubEvent(params: { title: string; reason: string; type: string; repository: { name: string; owner: string; isPrivate: boolean; isFork: boolean; } }): GitHubEvent
GitHubEvalResult
interface GitHubEvalResult { stacks: string[]; }