mirror of
https://github.com/ReCloudStudio/WebHooker.git
synced 2026-09-22 16:11:29 +00:00
chore(quality): provider fixtures, formatter snapshots, platform contract tests, CI, CodeQL, dependabot
This commit is contained in:
parent
04fa52db52
commit
320e825bf8
15 changed files with 405 additions and 3 deletions
34
tests/formatter-snapshot.test.ts
Normal file
34
tests/formatter-snapshot.test.ts
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
import { describe, test, expect } from "bun:test";
|
||||
import { formatEvent } from "../server/lib/formatters";
|
||||
import type { NeutralMessage, Route, WebhookEvent } from "../server/lib/types";
|
||||
import { githubPush, githubPullRequest, githubIssues } from "./fixtures";
|
||||
|
||||
const route: Route = {
|
||||
id: "test",
|
||||
name: "Test",
|
||||
enabled: true,
|
||||
filters: [],
|
||||
targets: [{ channelId: "111" }],
|
||||
};
|
||||
|
||||
function event(ev: string, payload: Record<string, unknown>): WebhookEvent {
|
||||
return { event: ev, payload };
|
||||
}
|
||||
|
||||
function stable(msg: NeutralMessage): NeutralMessage {
|
||||
return { ...msg, timestamp: msg.timestamp ? "TIMESTAMP" : msg.timestamp };
|
||||
}
|
||||
|
||||
describe("formatter snapshots", () => {
|
||||
test("push", () => {
|
||||
expect(stable(formatEvent(route, event("push", githubPush)))).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test("pull_request", () => {
|
||||
expect(stable(formatEvent(route, event("pull_request", githubPullRequest)))).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test("issues", () => {
|
||||
expect(stable(formatEvent(route, event("issues", githubIssues)))).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue