From 9468e58132f4214d699a0b6b33ee4b10e202bca1 Mon Sep 17 00:00:00 2001 From: Ryan Mwangi Date: Mon, 18 Nov 2024 14:04:51 +0300 Subject: [PATCH] test: validate fetchCalendarData reads and parses files accurately --- test/calendarUtil.test.js | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/test/calendarUtil.test.js b/test/calendarUtil.test.js index 91db03b..9580a32 100644 --- a/test/calendarUtil.test.js +++ b/test/calendarUtil.test.js @@ -33,12 +33,20 @@ describe('Calendar Utility Functions', () => { }); // Test case: reading data from a file - it('reads data from a file', async () => { - const testCalendar = { url: './test_calendars/eat_time_zone_event.ics' }; - // Call the fetchCalendarData function with the test calendar object + it('reads and parses data from a file', async () => { + const testCalendar = { url: './test/test_calendars/eat_time_zone_event.ics' }; + + // Call the fetchCalendarData function const result = await fetchCalendarData(testCalendar); - // Assert that the fetched result's data matches the expected file data - expect(ICAL.parse(result.data)).toBe('file data'); - }); + + // Expected parsed output + const expectedParsedData = ICAL.parse( + fs.readFileSync(testCalendar.url, 'utf-8') + ); + + // Assert that the fetched and parsed data matches + expect(ICAL.parse(result.data)).toEqual(expectedParsedData); }); + + }); });