//Calendar implementation for the HTWK Leipzig timetable. Evaluation and display of the individual dates in iCal format. //Copyright (C) 2024 HTWKalender support@htwkalender.de //This program is free software: you can redistribute it and/or modify //it under the terms of the GNU Affero General Public License as published by //the Free Software Foundation, either version 3 of the License, or //(at your option) any later version. //This program is distributed in the hope that it will be useful, //but WITHOUT ANY WARRANTY; without even the implied warranty of //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //GNU Affero General Public License for more details. //You should have received a copy of the GNU Affero General Public License //along with this program. If not, see . import { expect, test } from "vitest"; import { exportedForTesting } from "@/helpers/ical.ts"; import { CalendarComponent } from "ical"; // colorizeEvents has only the function to colorize the events that are passed to it test("colorizeEventsSameSummary", () => { const events: CalendarComponent[] = [ { type: "VEVENT", summary: "Operations Research", }, { type: "VEVENT", summary: "Operations Research", }, ]; expect(exportedForTesting.colorizeEvents(events)).toEqual([ { summary: "Operations Research", color: "var(--htwk-rot-200)" }, { summary: "Operations Research", color: "var(--htwk-rot-200)" }, ]); }); test("colorizeEventsDifferentSummary", () => { const events: CalendarComponent[] = [ { type: "VEVENT", summary: "Algorithmische Mathematik", }, { type: "VEVENT", summary: "Funktionale Programmierung", }, ]; expect(exportedForTesting.colorizeEvents(events)).toEqual([ { summary: "Algorithmische Mathematik", color: "var(--htwk-rot-200)" }, { summary: "Funktionale Programmierung", color: "var(--htwk-gruen-300)" }, ]); }); test("filterEventsDistinct", () => { const events: CalendarComponent[] = [ { type: "VEVENT", summary: "Operations Research", }, { type: "VEVENT", summary: "Operations Research", }, ]; expect(exportedForTesting.filterEventsDistinct(events)).toEqual([ { type: "VEVENT", summary: "Operations Research" }, ]); }); test("filterEventsDistinctDifferentSummary", () => { const events: CalendarComponent[] = [ { type: "VEVENT", summary: "Algorithmische Mathematik", }, { type: "VEVENT", summary: "Funktionale Programmierung", }, ]; expect(exportedForTesting.filterEventsDistinct(events)).toEqual(events); }); test("extractedColorizedEvents", () => { const events: CalendarComponent[] = [ { type: "VEVENT", summary: "Operations Research", }, { type: "VEVENT", summary: "Operations Research", }, ]; expect(exportedForTesting.extractedColorizedEvents(events)).toEqual([ { summary: "Operations Research", color: "var(--htwk-rot-200)" }, ]); }); test("extractedColorizedEventsDifferentSummary", () => { const events: CalendarComponent[] = [ { type: "VEVENT", summary: "Algorithmische Mathematik", }, { type: "VEVENT", summary: "Funktionale Programmierung", }, ]; expect(exportedForTesting.extractedColorizedEvents(events)).toEqual([ { summary: "Algorithmische Mathematik", color: "var(--htwk-rot-200)" }, { summary: "Funktionale Programmierung", color: "var(--htwk-gruen-300)" }, ]); });