Compare commits
3 Commits
782e62d56d
...
bed3e47f8e
Author | SHA1 | Date |
---|---|---|
xeruf | bed3e47f8e | |
xeruf | 1f19d8cf1f | |
xeruf | 77e6963118 |
|
@ -1 +1,2 @@
|
|||
* text=auto eol=lf
|
||||
*.ics text eol=crlf
|
||||
|
|
|
@ -3,7 +3,7 @@ import express from 'express';
|
|||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
const CALENDARS_DIR = path.join(__dirname, 'calendar')
|
||||
const CALENDARS_DIR = path.join(__dirname, 'calendar');
|
||||
const TEST_CALENDARS_DIR = path.join(__dirname, 'test_calendars');
|
||||
const EXPECTED_OUTPUTS_DIR = path.join(__dirname, 'expected_outputs');
|
||||
|
||||
|
@ -26,7 +26,7 @@ describe('Calendar Merging API', () => {
|
|||
await new Promise(resolve => setTimeout(resolve, 100));
|
||||
});
|
||||
|
||||
const loadCalendarFile = (filename) => {
|
||||
const getTestCalendarFilename = (filename) => {
|
||||
return path.join(TEST_CALENDARS_DIR, filename);
|
||||
};
|
||||
|
||||
|
@ -34,8 +34,33 @@ describe('Calendar Merging API', () => {
|
|||
return fs.readFileSync(path.join(EXPECTED_OUTPUTS_DIR, filename), 'utf8');
|
||||
};
|
||||
|
||||
test('Preserve nextcloud calendar', async () => {
|
||||
const input = getTestCalendarFilename('nextcloud-minimal.ics');
|
||||
const response = await request(server)
|
||||
.post('/merge')
|
||||
.send({
|
||||
linkGroupName: 'nextcloud-minimal',
|
||||
calendars: [
|
||||
{
|
||||
url: input,
|
||||
prefix: '',
|
||||
override: false,
|
||||
},
|
||||
],
|
||||
});
|
||||
expect(response.status).toBe(200);
|
||||
// Check if the file was created in the test directory
|
||||
const filePath = path.join(CALENDARS_DIR, 'nextcloud-minimal.ics');
|
||||
console.log('Checking if file exists at:', filePath);
|
||||
expect(fs.existsSync(filePath)).toBe(true);
|
||||
// Load expected output and compare
|
||||
const expectedOutput = fs.readFileSync(input, 'utf8');
|
||||
const actualOutput = fs.readFileSync(filePath, 'utf8');
|
||||
expect(actualOutput).toBe(expectedOutput);
|
||||
});
|
||||
|
||||
test('Preserve date-based calendar', async () => {
|
||||
const input = loadCalendarFile('US_Holidays.ics');
|
||||
const input = getTestCalendarFilename('US_Holidays.ics');
|
||||
const response = await request(server)
|
||||
.post('/merge')
|
||||
.send({
|
||||
|
@ -57,7 +82,6 @@ describe('Calendar Merging API', () => {
|
|||
const expectedOutput = fs.readFileSync(input, 'utf8');
|
||||
const actualOutput = fs.readFileSync(filePath, 'utf8');
|
||||
expect(actualOutput).toBe(expectedOutput);
|
||||
|
||||
});
|
||||
|
||||
// test('Merge date-based calendar', async () => {
|
||||
|
@ -67,12 +91,12 @@ describe('Calendar Merging API', () => {
|
|||
// linkGroupName: 'Date Based Calendar',
|
||||
// calendars: [
|
||||
// {
|
||||
// url: loadCalendarFile('holiday_calendar_2023.ics'),
|
||||
// url: getTestCalendarFilename('holiday_calendar_2023.ics'),
|
||||
// prefix: 'holiday_calendar_2023',
|
||||
// override: false,
|
||||
// },
|
||||
// {
|
||||
// url: loadCalendarFile('US_Holidays.ics'),
|
||||
// url: getTestCalendarFilename('US_Holidays.ics'),
|
||||
// prefix: 'US_holidays',
|
||||
// override: false,
|
||||
// },
|
||||
|
@ -93,7 +117,7 @@ describe('Calendar Merging API', () => {
|
|||
// });
|
||||
|
||||
test('Merge time-based calendar', async () => {
|
||||
const input = loadCalendarFile('work_task_calendar.ics');
|
||||
const input = getTestCalendarFilename('work_task_calendar.ics');
|
||||
const response = await request(server)
|
||||
.post('/merge')
|
||||
.send({
|
||||
|
@ -121,7 +145,7 @@ describe('Calendar Merging API', () => {
|
|||
});
|
||||
|
||||
test('EAT Event', async () => {
|
||||
const input = loadCalendarFile('eat_time_zone_event.ics');
|
||||
const input = getTestCalendarFilename('eat_time_zone_event.ics');
|
||||
const response = await request(server)
|
||||
.post('/merge')
|
||||
.send({
|
||||
|
@ -155,7 +179,7 @@ describe('Calendar Merging API', () => {
|
|||
// linkGroupName: 'No Prefix Calendar',
|
||||
// calendars: [
|
||||
// {
|
||||
// url: loadCalendarFile('sf_public_holidays.ics'),
|
||||
// url: getTestCalendarFilename('sf_public_holidays.ics'),
|
||||
// prefix: '',
|
||||
// override: false,
|
||||
// },
|
||||
|
@ -182,7 +206,7 @@ describe('Calendar Merging API', () => {
|
|||
// linkGroupName: 'Override Calendar',
|
||||
// calendars: [
|
||||
// {
|
||||
// url: loadCalendarFile('sf_public_holidays.ics'),
|
||||
// url: getTestCalendarFilename('sf_public_holidays.ics'),
|
||||
// prefix: 'Override Event',
|
||||
// override: true,
|
||||
// },
|
||||
|
@ -209,12 +233,12 @@ describe('Calendar Merging API', () => {
|
|||
// linkGroupName: 'UTCEAT Time Zone Calendar',
|
||||
// calendars: [
|
||||
// {
|
||||
// url: loadCalendarFile('utc_time_zone_event.ics'),
|
||||
// url: getTestCalendarFilename('utc_time_zone_event.ics'),
|
||||
// prefix: 'UTC_Event',
|
||||
// override: false,
|
||||
// },
|
||||
// {
|
||||
// url: loadCalendarFile('eat_time_zone_event.ics'),
|
||||
// url: getTestCalendarFilename('eat_time_zone_event.ics'),
|
||||
// prefix: 'EAT_Event',
|
||||
// override: false,
|
||||
// },
|
||||
|
@ -240,12 +264,12 @@ describe('Calendar Merging API', () => {
|
|||
// linkGroupName: 'Merged Date and Time Based Calendar',
|
||||
// calendars: [
|
||||
// {
|
||||
// url: loadCalendarFile('holiday_calendar_2023.ics'), // Date-based calendar
|
||||
// url: getTestCalendarFilename('holiday_calendar_2023.ics'), // Date-based calendar
|
||||
// prefix: 'Holiday_2023',
|
||||
// override: false,
|
||||
// },
|
||||
// {
|
||||
// url: loadCalendarFile('work_task_calendar.ics'), // Time-based calendar
|
||||
// url: getTestCalendarFilename('work_task_calendar.ics'), // Time-based calendar
|
||||
// prefix: 'Work_Task',
|
||||
// override: false,
|
||||
// },
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import ICAL from '../src/lib/ical.timezones';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import axios from 'axios';
|
||||
|
||||
// Describe the test suite for Calendar Utility Functions
|
||||
|
@ -34,19 +35,16 @@ describe('Calendar Utility Functions', () => {
|
|||
|
||||
// Test case: reading data from a file
|
||||
it('reads and parses data from a file', async () => {
|
||||
const testCalendar = { url: './test/test_calendars/eat_time_zone_event.ics' };
|
||||
const testCalendar = { url: path.join(__dirname, 'test_calendars', 'nextcloud.ics'), };
|
||||
|
||||
// Call the fetchCalendarData function
|
||||
const result = await fetchCalendarData(testCalendar);
|
||||
|
||||
// Expected parsed output
|
||||
const expectedParsedData = ICAL.parse(
|
||||
fs.readFileSync(testCalendar.url, 'utf-8')
|
||||
);
|
||||
|
||||
const parsed = ICAL.parse(result.data);
|
||||
const component = new ICAL.Component(parsed);
|
||||
const firstEvent = new ICAL.Event(component.getAllSubcomponents('vevent')[0]);
|
||||
// Assert that the fetched and parsed data matches
|
||||
expect(ICAL.parse(result.data)).toEqual(expectedParsedData);
|
||||
});
|
||||
|
||||
expect(firstEvent.startDate.toJSON()).toEqual({"day": 20, "hour": 21, "isDate": false, "minute": 15, "month": 11, "second": 0, "timezone": "Europe/Berlin", "year": 2024});
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
BEGIN:VCALENDAR
|
||||
VERSION:2.0
|
||||
CALSCALE:GREGORIAN
|
||||
PRODID:-//SabreDAV//SabreDAV//EN
|
||||
BEGIN:VTIMEZONE
|
||||
TZID:Europe/Berlin
|
||||
BEGIN:DAYLIGHT
|
||||
TZOFFSETFROM:+0100
|
||||
TZOFFSETTO:+0200
|
||||
TZNAME:CEST
|
||||
DTSTART:19700329T020000
|
||||
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU
|
||||
END:DAYLIGHT
|
||||
BEGIN:STANDARD
|
||||
TZOFFSETFROM:+0200
|
||||
TZOFFSETTO:+0100
|
||||
TZNAME:CET
|
||||
DTSTART:19701025T030000
|
||||
RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU
|
||||
END:STANDARD
|
||||
END:VTIMEZONE
|
||||
BEGIN:VEVENT
|
||||
DTEND;TZID=Europe/Berlin:20241120T215000
|
||||
DTSTAMP:20241113T212909Z
|
||||
DTSTART;TZID=Europe/Berlin:20241120T211500
|
||||
LOCATION:FaceTime
|
||||
RRULE:FREQ=WEEKLY;BYDAY=WE
|
||||
SEQUENCE:0
|
||||
SUMMARY:JR Weekly Check-In
|
||||
UID:5f4ad965-16a8-48eb-8233-78bf93a8b35e
|
||||
END:VEVENT
|
||||
END:VCALENDAR
|
|
@ -0,0 +1,131 @@
|
|||
BEGIN:VCALENDAR
|
||||
VERSION:2.0
|
||||
CALSCALE:GREGORIAN
|
||||
PRODID:-//SabreDAV//SabreDAV//EN
|
||||
X-WR-CALNAME:Progodyssey Ryan (stackspin-a51baefe-70df-4cce-9be1-048354b619
|
||||
b8)
|
||||
X-APPLE-CALENDAR-COLOR:#ddcb55
|
||||
REFRESH-INTERVAL;VALUE=DURATION:PT4H
|
||||
X-PUBLISHED-TTL:PT4H
|
||||
BEGIN:VTIMEZONE
|
||||
TZID:Europe/Berlin
|
||||
BEGIN:DAYLIGHT
|
||||
TZOFFSETFROM:+0100
|
||||
TZOFFSETTO:+0200
|
||||
TZNAME:CEST
|
||||
DTSTART:19700329T020000
|
||||
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU
|
||||
END:DAYLIGHT
|
||||
BEGIN:STANDARD
|
||||
TZOFFSETFROM:+0200
|
||||
TZOFFSETTO:+0100
|
||||
TZNAME:CET
|
||||
DTSTART:19701025T030000
|
||||
RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU
|
||||
END:STANDARD
|
||||
END:VTIMEZONE
|
||||
BEGIN:VEVENT
|
||||
CREATED:20241113T212909Z
|
||||
DTEND;TZID=Europe/Berlin:20241120T215000
|
||||
DTSTAMP:20241113T212909Z
|
||||
DTSTART;TZID=Europe/Berlin:20241120T211500
|
||||
LAST-MODIFIED:20241113T212909Z
|
||||
LOCATION:FaceTime
|
||||
RRULE:FREQ=WEEKLY;BYDAY=WE
|
||||
SEQUENCE:0
|
||||
STATUS:CONFIRMED
|
||||
SUMMARY:JR Weekly Check-In
|
||||
TRANSP:OPAQUE
|
||||
UID:5f4ad965-16a8-48eb-8233-78bf93a8b35e
|
||||
RELATED-TO;RELTYPE=SIBLING:17cf7d22-9bee-4a8e-9023-878b1a1b73a0
|
||||
BEGIN:VALARM
|
||||
ACKNOWLEDGED:20241113T202052Z
|
||||
ACTION:DISPLAY
|
||||
DESCRIPTION:This is an event reminder.
|
||||
TRIGGER:-PT20M
|
||||
UID:99250427-AB45-4111-A999-DB417FC290D1
|
||||
X-WR-ALARMUID:99250427-AB45-4111-A999-DB417FC290D1
|
||||
SUMMARY:JR Weekly Check-In
|
||||
END:VALARM
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
CREATED:20241113T213036Z
|
||||
DTEND;TZID=Europe/Berlin:20241204T212500
|
||||
DTSTAMP:20241113T213036Z
|
||||
DTSTART;TZID=Europe/Berlin:20241204T203000
|
||||
LAST-MODIFIED:20241113T213036Z
|
||||
LOCATION:FaceTime
|
||||
SEQUENCE:1
|
||||
STATUS:CONFIRMED
|
||||
SUMMARY:JR Weekly Check-In
|
||||
TRANSP:OPAQUE
|
||||
UID:5f4ad965-16a8-48eb-8233-78bf93a8b35e
|
||||
RELATED-TO;RELTYPE=SIBLING:17cf7d22-9bee-4a8e-9023-878b1a1b73a0
|
||||
RECURRENCE-ID;TZID=Europe/Berlin:20241204T211500
|
||||
BEGIN:VALARM
|
||||
ACKNOWLEDGED:20241113T202052Z
|
||||
ACTION:DISPLAY
|
||||
DESCRIPTION:This is an event reminder.
|
||||
TRIGGER:-PT20M
|
||||
UID:99250427-AB45-4111-A999-DB417FC290D1
|
||||
X-WR-ALARMUID:99250427-AB45-4111-A999-DB417FC290D1
|
||||
SUMMARY:JR Weekly Check-In
|
||||
END:VALARM
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
CREATED:20241107T101403Z
|
||||
DTEND;TZID=Europe/Berlin:20241111T134500
|
||||
DTSTAMP:20241118T103806Z
|
||||
DTSTART;TZID=Europe/Berlin:20241111T121500
|
||||
LAST-MODIFIED:20241118T103803Z
|
||||
LOCATION:https://call.element.io/room/#/progodyssey?password=bU95nPdV2u-BGJ
|
||||
4zw9cPGw&roomId=%21QsGQUxdyuMfGKhGvNH%3Acall.ems.host
|
||||
RRULE:FREQ=WEEKLY;BYDAY=MO
|
||||
SEQUENCE:4
|
||||
STATUS:CONFIRMED
|
||||
SUMMARY:JR Coprogramming Session
|
||||
TRANSP:OPAQUE
|
||||
UID:8c251542-6cbf-4396-b83d-490be79c97a9
|
||||
BEGIN:VALARM
|
||||
ACKNOWLEDGED:20241118T103803Z
|
||||
ACTION:DISPLAY
|
||||
DESCRIPTION:This is an event reminder.
|
||||
SUMMARY:Coprogramming Session
|
||||
TRIGGER:-PT1H
|
||||
UID:55C3B462-E182-4A2B-A500-3F249FC860C2
|
||||
X-WR-ALARMUID:55C3B462-E182-4A2B-A500-3F249FC860C2
|
||||
END:VALARM
|
||||
BEGIN:VALARM
|
||||
ACTION:DISPLAY
|
||||
DESCRIPTION:Reminder
|
||||
TRIGGER:-PT1H
|
||||
UID:9AABB2AB-A755-4723-87CF-10B119670E7F
|
||||
X-APPLE-DEFAULT-ALARM:TRUE
|
||||
X-WR-ALARMUID:9AABB2AB-A755-4723-87CF-10B119670E7F
|
||||
END:VALARM
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
CREATED:20241107T101605Z
|
||||
DTEND;TZID=Europe/Berlin:20241113T215500
|
||||
DTSTAMP:20241113T212909Z
|
||||
DTSTART;TZID=Europe/Berlin:20241113T213000
|
||||
LAST-MODIFIED:20241113T212909Z
|
||||
LOCATION:FaceTime
|
||||
RRULE:FREQ=WEEKLY;BYDAY=WE;UNTIL=20241120T202959Z
|
||||
SEQUENCE:4
|
||||
STATUS:CONFIRMED
|
||||
SUMMARY:JR Weekly Check-In
|
||||
TRANSP:OPAQUE
|
||||
UID:17cf7d22-9bee-4a8e-9023-878b1a1b73a0
|
||||
RELATED-TO;RELTYPE=SIBLING:5f4ad965-16a8-48eb-8233-78bf93a8b35e
|
||||
BEGIN:VALARM
|
||||
ACKNOWLEDGED:20241113T202052Z
|
||||
ACTION:DISPLAY
|
||||
DESCRIPTION:This is an event reminder.
|
||||
SUMMARY:JR Weekly Check-In
|
||||
TRIGGER:-PT20M
|
||||
UID:99250427-AB45-4111-A999-DB417FC290D1
|
||||
X-WR-ALARMUID:99250427-AB45-4111-A999-DB417FC290D1
|
||||
END:VALARM
|
||||
END:VEVENT
|
||||
END:VCALENDAR
|
Loading…
Reference in New Issue