18 lines
846 B
TypeScript
18 lines
846 B
TypeScript
// tests/notify.test.ts
|
|
import { describe, it, expect, vi } from "vitest";
|
|
describe("notify message", () => {
|
|
it("baut Erinnerungstext mit Restbetrag", async () => {
|
|
const { buildReminderText } = await import("../lib/notify-text");
|
|
expect(buildReminderText({ name: "Therme", restCents: 2550, ablaufdatum: "01.12.2026" })).toContain("25,50");
|
|
});
|
|
it("sendTelegram ruft Bot-API mit chat_id", async () => {
|
|
const fetchMock = vi.fn().mockResolvedValue({ ok: true, json: async () => ({ ok: true }) });
|
|
vi.stubGlobal("fetch", fetchMock);
|
|
const { sendTelegram } = await import("../lib/telegram");
|
|
process.env.TELEGRAM_BOT_TOKEN = "test-token";
|
|
await sendTelegram("123", "hallo");
|
|
expect(fetchMock).toHaveBeenCalledWith(expect.stringContaining("test-token"), expect.anything());
|
|
vi.unstubAllGlobals();
|
|
});
|
|
});
|