import assert from "node:assert/strict"; import test, { describe } from "node:test"; import { slackMany, slackOne } from "./slack.ts"; const event = (overrides: Partial<{ name: string; slug: string; startDate: string }> = {}) => ({ name: "Hack Night", slug: "hack-night", startDate: "2026-06-15T18:00:00Z", endDate: "2026-06-15T20:00:00Z", location: "Boise", lat: "43.615", lon: "-116.202", series: { id: 1, name: "Hack Night" }, image: { path: "/img/hack-night.png" }, ...overrides, }); describe("slackOne", () => { test("includes the name and url of events", () => { for (const { name, slug } of [ { name: "Hack Night", slug: "hack-night" }, { name: "Lunch", slug: "lunch" }, { name: "X", slug: "x" }, ]) { const msg = slackOne(event({ name, slug })); assert.ok(msg.includes(name), `expected ${name} in: ${msg}`); assert.ok( msg.includes(`https://platform.openmeet.net/events/${slug}`), `expected url for ${slug} in: ${msg}`, ); } }); }); describe("slackMany", () => { test("uses the empty-state message when no events", () => { const msg = slackMany([]); assert.ok(msg.includes("No events this week."), "expected 'no events' message from empty list"); }); test("includes each event's name and url", () => { const msg = slackMany([event({ name: "A", slug: "a" }), event({ name: "B", slug: "b" })]); assert.ok(msg.includes("A"), `expected A in: ${msg}`); assert.ok(msg.includes("https://platform.openmeet.net/events/a"), `expected a url in: ${msg}`); assert.ok(msg.includes("B"), `expected B in: ${msg}`); assert.ok(msg.includes("https://platform.openmeet.net/events/b"), `expected b url in: ${msg}`); }); });