FeedRepository no longer owns favicons, WebSub subscriber lists or the monitoring counters singleton. Each concern gets its own repository (IconRepository, WebSubSubscriptionRepository, CountersRepository), sharing the key schema via feed-keys. KV key strings are unchanged; counters increment policy stays in utils/stats.ts. Co-Authored-By: Claude Opus 4.7 <[email protected]>
20 lines
803 B
TypeScript
20 lines
803 B
TypeScript
import { describe, it, expect } from "vitest";
|
|
import { createMockEnv } from "../test/setup";
|
|
import { WebSubSubscriptionRepository } from "./websub-subscription-repository";
|
|
import type { Env, WebSubSubscription } from "../types";
|
|
|
|
const mockEnv = () => createMockEnv() as unknown as Env;
|
|
|
|
describe("WebSubSubscriptionRepository", () => {
|
|
it("round-trips subscriptions and counts feeds with subscribers", async () => {
|
|
const repo = new WebSubSubscriptionRepository(mockEnv().EMAIL_STORAGE);
|
|
expect(await repo.get("a.b.42")).toEqual([]);
|
|
const subs: WebSubSubscription[] = [
|
|
{ callbackUrl: "https://r.example/cb", expiresAt: 9999 },
|
|
];
|
|
await repo.save("a.b.42", subs);
|
|
expect(await repo.get("a.b.42")).toEqual(subs);
|
|
expect(await repo.countKeys()).toBe(1);
|
|
});
|
|
});
|