From 8881361a1f1c6cb13722652603fe005f09668156 Mon Sep 17 00:00:00 2001 From: Ryan Mwangi Date: Tue, 19 Nov 2024 15:21:19 +0300 Subject: [PATCH] text: create and run test for google-calendar-mininal --- test/calendar.test.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/test/calendar.test.js b/test/calendar.test.js index 71e9823..761e15e 100644 --- a/test/calendar.test.js +++ b/test/calendar.test.js @@ -68,6 +68,39 @@ describe('Calendar Merging API', () => { expect(normalizedActual).toBe(normalizedExpected); }); + test('Preserve google calendar', async () => { + const input = getTestCalendarFilename('google-calendar-minimal.ics'); + const response = await request(server) + .post('/merge') + .send({ + linkGroupName: 'google-calendar-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, 'google-calendar-minimal.ics'); + // console.log('Checking if file exists at:', filePath); + expect(fs.existsSync(filePath)).toBe(true); + + // Load expected output + const expectedOutput = fs.readFileSync(input, 'utf8'); + const actualOutput = fs.readFileSync(filePath, 'utf8'); + + // Normalize line endings + const normalizedActual = normalizeLineEndings(actualOutput); + const normalizedExpected = normalizeLineEndings(expectedOutput); + + //compare + expect(normalizedActual).toBe(normalizedExpected); + }); + + // test('Preserve date-based calendar', async () => { // const input = getTestCalendarFilename('US_Holidays.ics'); // const response = await request(server)