From cbdfdf6c978db48eaaa8dc3637e93bd7dba6d6ae Mon Sep 17 00:00:00 2001 From: Ryan Mwangi Date: Wed, 13 Nov 2024 15:17:17 +0300 Subject: [PATCH] test:update test forhandling timezones --- test/calendar.test.js | 28 +++++++++++++++++++++ test/test_calendars/eat_time_zone_event.ics | 8 ++---- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/test/calendar.test.js b/test/calendar.test.js index 89ec26d..770c076 100644 --- a/test/calendar.test.js +++ b/test/calendar.test.js @@ -120,6 +120,34 @@ describe('Calendar Merging API', () => { expect(actualOutput).toBe(expectedOutput); }); + test('EAT Event', async () => { + const input = loadCalendarFile('eat_time_zone_event.ics'); + const response = await request(server) + .post('/merge') + .send({ + linkGroupName: 'EAT Event', + calendars: [ + { + url: input, + prefix: 'EAT Event', + override: false, + }, + ], + }); + + expect(response.status).toBe(200); + expect(response.body.url).toMatch(/calendar\/EAT_Event/); + + // Check if the file was created in the test directory + const filePath = path.join(CALENDARS_DIR, 'EAT_Event.ics'); + 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 calendar without prefix', async () => { // const response = await request(server) // .post('/merge') diff --git a/test/test_calendars/eat_time_zone_event.ics b/test/test_calendars/eat_time_zone_event.ics index 379be4f..efe9a67 100644 --- a/test/test_calendars/eat_time_zone_event.ics +++ b/test/test_calendars/eat_time_zone_event.ics @@ -1,15 +1,11 @@ BEGIN:VCALENDAR +NAME:EAT Event VERSION:2.0 -PRODID:-//Example Corp//NONSGML Event//EN BEGIN:VEVENT UID:20231108T090000+0300-001@example.com DTSTAMP:20231108T090000+0300 DTSTART:20231108T090000+0300 DTEND:20231108T100000+0300 SUMMARY:EAT Event -DESCRIPTION:This event is scheduled in East Africa Time (UTC+3). -LOCATION:Virtual -STATUS:CONFIRMED -SEQUENCE:0 END:VEVENT -END:VCALENDAR +END:VCALENDAR \ No newline at end of file