import assert from "node:assert/strict"; import test from "node:test"; import { clean } from "../src/feeds.js"; import { crocusCalendar, vdnhCalendar, vdnhDetails, } from "../src/family-sources.js"; test("Crocus returns a current exhibition organizer, never a theme or an expired exhibition", () => { // Short public venue markup with the contact fields omitted. function listing(name, period, organizer) { return `
ВетеринарияСайт: Сайт организатора
`; } const body = listing( "Выставки собак всех пород «Евразия 2026»", "14 Ноября 2026 — 15 Ноября 2026", "https://eurasia.rkf.org.ru/", ) + listing("Прошедшая выставка", "14 Ноября 2026", "https://example.org/"); const events = crocusCalendar(body, "2026-11-15", clean); assert.equal(events.length, 1); assert.equal(events[0].url, "https://eurasia.rkf.org.ru/"); assert.match(events[0].excerpt, /2026-11-14 — 2026-11-15/); assert.deepEqual(crocusCalendar(body, "2026-11-16", clean), []); }); test("VDNH reads official Nuxt date references and prioritizes a one-day event", () => { // Public fields of the Nov 15 excursion, with unrelated application nodes removed and indices compacted. const nodes = [ { name: 1, url: 2, schedule: 3, eventThemes: 4 }, "Тематическая экскурсия «Между вдохновением и бурей»", "4102", { show: 5, items: 6 }, [], true, [7, 8], { type: 9, date: 10, week_days: 4 }, { type: 11, date: 4, week_days: 12 }, 2, [13], 3, [14], "15-11-2026", 0, ]; const body = '"; assert.deepEqual( vdnhCalendar(body, "2026-11-15").map((x) => x.url), ["https://vdnh.ru/events/4102/"], ); assert.deepEqual(vdnhCalendar(body, "2026-11-16"), []); }); test("VDNH detail text comes only from the selected event, including booking conditions", () => { const nodes = [ { name: 1, url: 2, constructors: 3, badges: 4, places: 4 }, "Тематическая экскурсия", "4102", [5], [], { content: 6 }, { announcement: 7 }, "

Для посещения необходима регистрация.

", { name: 9, url: 10, constructors: 11 }, "Другое событие", "4156", [12], { content: 13 }, { text: 14 }, "Цена другого мероприятия 5000 рублей.", ]; const body = '"; assert.equal( vdnhDetails(body, "https://vdnh.ru/events/4102/", clean), "Для посещения необходима регистрация.", ); });