From 4032e2c49d77f7890962a856e094b38bea0868a3 Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Tue, 12 Nov 2024 16:20:53 +0100 Subject: [PATCH] test: preserve date-based calendar --- test/calendar.test.js | 25 +++++++++++++++++++ test/expected_outputs/Date_Based_Calendar.ics | 3 +-- test/test_calendars/US_Holidays.ics | 6 +---- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/test/calendar.test.js b/test/calendar.test.js index ba38d1d..3f5bf10 100644 --- a/test/calendar.test.js +++ b/test/calendar.test.js @@ -34,6 +34,31 @@ describe('Calendar Merging API', () => { return fs.readFileSync(path.join(EXPECTED_OUTPUTS_DIR, filename), 'utf8'); }; + test('Preserve date-based calendar', async () => { + const input = loadCalendarFile('US_Holidays.ics'); + const response = await request(server) + .post('/merge') + .send({ + linkGroupName: 'US Holidays', + 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, 'US_Holidays.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('Merge date-based calendar', async () => { const response = await request(server) .post('/merge') diff --git a/test/expected_outputs/Date_Based_Calendar.ics b/test/expected_outputs/Date_Based_Calendar.ics index 601e75d..d54023b 100644 --- a/test/expected_outputs/Date_Based_Calendar.ics +++ b/test/expected_outputs/Date_Based_Calendar.ics @@ -1,5 +1,4 @@ BEGIN:VCALENDAR -PRODID:-//Your Product ID//EN VERSION:2.0 NAME:Date Based Calendar BEGIN:VEVENT @@ -14,4 +13,4 @@ SUMMARY:US_holidays Christmas Day DTSTART:20231225T000000 DTEND:20231226T000000 END:VEVENT -END:VCALENDAR \ No newline at end of file +END:VCALENDAR diff --git a/test/test_calendars/US_Holidays.ics b/test/test_calendars/US_Holidays.ics index 8d20aa7..d8ace67 100644 --- a/test/test_calendars/US_Holidays.ics +++ b/test/test_calendars/US_Holidays.ics @@ -1,15 +1,11 @@ BEGIN:VCALENDAR +NAME:US Holidays VERSION:2.0 -PRODID:-//Example Corp//NONSGML Event//EN BEGIN:VEVENT UID:20231225T000000-001@example.com DTSTAMP:20231225T000000Z DTSTART;VALUE=DATE:20231225 DTEND;VALUE=DATE:20231226 SUMMARY:Christmas Day -DESCRIPTION:Public holiday for Christmas in The US. -LOCATION:San Francisco -STATUS:CONFIRMED -SEQUENCE:0 END:VEVENT END:VCALENDAR -- 2.40.1