cairn work
This commit is contained in:
34
src/server/api/routers/apple-notifications.test.ts
Normal file
34
src/server/api/routers/apple-notifications.test.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { describe, it, expect, vi } from "vitest";
|
||||
import { appRouter } from "~/server/api/root";
|
||||
import { createTRPCContext } from "~/server/api/utils";
|
||||
|
||||
vi.mock("~/server/apple-notification", () => ({
|
||||
verifyAppleNotification: async () => ({
|
||||
notification_type: "consent-revoked",
|
||||
sub: "apple-sub",
|
||||
email: "test@apple.com",
|
||||
event_time: Date.now()
|
||||
})
|
||||
}));
|
||||
|
||||
vi.mock("~/server/apple-notification-store", () => ({
|
||||
storeAppleNotificationUser: async () => undefined
|
||||
}));
|
||||
|
||||
vi.mock("~/server/session-helpers", () => ({
|
||||
getAuthSession: async () => ({ userId: "admin", isAdmin: true })
|
||||
}));
|
||||
|
||||
describe("apple notification router", () => {
|
||||
it("verifies and stores notifications", async () => {
|
||||
const caller = appRouter.createCaller(
|
||||
await createTRPCContext({ nativeEvent: { node: { req: {} } } } as any)
|
||||
);
|
||||
|
||||
const result = await caller.appleNotifications.verifyAndStore.mutate({
|
||||
signedPayload: "test"
|
||||
});
|
||||
|
||||
expect(result.success).toBe(true);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user