forked from ryanmwangi/CalMerger
test(calendar): make tests for merged date based calendars pass
This commit is contained in:
parent
5ec6341680
commit
51c4f5c31f
|
@ -17,12 +17,6 @@ const app = await import('../src/server');
|
||||||
|
|
||||||
describe('Calendar Merging API', () => {
|
describe('Calendar Merging API', () => {
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
|
|
||||||
// Clean up the merged calendars directory before tests
|
|
||||||
fs.rmdirSync(CALENDARS_DIR, { recursive: true });
|
|
||||||
if (fs.existsSync(CALENDARS_DIR)) {
|
|
||||||
fs.rmdirSync(CALENDARS_DIR, { recursive: true });
|
|
||||||
}
|
|
||||||
// Start the server
|
// Start the server
|
||||||
server = app.default.listen(0);
|
server = app.default.listen(0);
|
||||||
});
|
});
|
||||||
|
@ -125,37 +119,37 @@ describe('Calendar Merging API', () => {
|
||||||
expect(actualOutput).toBe(expectedOutput);
|
expect(actualOutput).toBe(expectedOutput);
|
||||||
});
|
});
|
||||||
|
|
||||||
// test('Merge date-based calendar', async () => {
|
test('Merge date-based calendar', async () => {
|
||||||
// const response = await request(server)
|
const response = await request(server)
|
||||||
// .post('/merge')
|
.post('/merge')
|
||||||
// .send({
|
.send({
|
||||||
// linkGroupName: 'Date Based Calendar',
|
linkGroupName: 'Date Based Calendar',
|
||||||
// calendars: [
|
calendars: [
|
||||||
// {
|
{
|
||||||
// url: getTestCalendarFilename('holiday_calendar_2023.ics'),
|
url: getTestCalendarFilename('holiday_calendar_2023.ics'),
|
||||||
// prefix: 'holiday_calendar_2023',
|
prefix: 'holiday_calendar_2023',
|
||||||
// override: false,
|
override: false,
|
||||||
// },
|
},
|
||||||
// {
|
{
|
||||||
// url: getTestCalendarFilename('US_Holidays.ics'),
|
url: getTestCalendarFilename('US_Holidays.ics'),
|
||||||
// prefix: 'US_holidays',
|
prefix: 'US_holidays',
|
||||||
// override: false,
|
override: false,
|
||||||
// },
|
},
|
||||||
// ],
|
],
|
||||||
// });
|
});
|
||||||
// expect(response.status).toBe(200);
|
expect(response.status).toBe(200);
|
||||||
// expect(response.body.url).toMatch(new RegExp(`calendar/Date_Based_Calendar`));
|
expect(response.body.url).toMatch(new RegExp(`calendar/Date_Based_Calendar`));
|
||||||
|
|
||||||
// // Check if the file was created in the test directory
|
// Check if the file was created in the test directory
|
||||||
// const filePath = path.join(CALENDARS_DIR, 'Date_Based_Calendar.ics');
|
const filePath = path.join(CALENDARS_DIR, 'Date_Based_Calendar.ics');
|
||||||
// console.log('Checking if file exists at:', filePath);
|
console.log('Checking if file exists at:', filePath);
|
||||||
// expect(fs.existsSync(filePath)).toBe(true);
|
expect(fs.existsSync(filePath)).toBe(true);
|
||||||
|
|
||||||
// // Load expected output and compare
|
// Load expected output and compare
|
||||||
// const expectedOutput = loadExpectedOutput('Date_Based_Calendar.ics');
|
const expectedOutput = loadExpectedOutput('Date_Based_Calendar.ics');
|
||||||
// const actualOutput = fs.readFileSync(filePath, 'utf8');
|
const actualOutput = fs.readFileSync(filePath, 'utf8');
|
||||||
// expect(actualOutput).toBe(expectedOutput);
|
expect(actualOutput).toBe(expectedOutput);
|
||||||
// });
|
});
|
||||||
|
|
||||||
// test('Merge time-based calendar', async () => {
|
// test('Merge time-based calendar', async () => {
|
||||||
// const input = getTestCalendarFilename('work_task_calendar.ics');
|
// const input = getTestCalendarFilename('work_task_calendar.ics');
|
||||||
|
|
|
@ -1,16 +1,21 @@
|
||||||
BEGIN:VCALENDAR
|
BEGIN:VCALENDAR
|
||||||
VERSION:2.0
|
|
||||||
NAME:Date Based Calendar
|
NAME:Date Based Calendar
|
||||||
|
PRODID:-//CalMerge//Calendar Merger 1.0//EN
|
||||||
|
VERSION:2.0
|
||||||
|
CALSCALE:GREGORIAN
|
||||||
BEGIN:VEVENT
|
BEGIN:VEVENT
|
||||||
UID:20231225T000000-001@example.com
|
UID:20231225T000000-001@example.com
|
||||||
|
DTSTART;VALUE=DATE:20231225
|
||||||
|
DTEND;VALUE=DATE:20231226
|
||||||
|
DTSTAMP:20231225T000000Z
|
||||||
SUMMARY:holiday_calendar_2023 Christmas Day
|
SUMMARY:holiday_calendar_2023 Christmas Day
|
||||||
DTSTART:20231225T000000
|
LOCATION:Germany
|
||||||
DTEND:20231226T000000
|
|
||||||
END:VEVENT
|
END:VEVENT
|
||||||
BEGIN:VEVENT
|
BEGIN:VEVENT
|
||||||
UID:20231225T000000-001@example.com
|
UID:20231225T000000-001@example.com
|
||||||
|
DTSTART;VALUE=DATE:20231225
|
||||||
|
DTEND;VALUE=DATE:20231226
|
||||||
|
DTSTAMP:20231225T000000Z
|
||||||
SUMMARY:US_holidays Christmas Day
|
SUMMARY:US_holidays Christmas Day
|
||||||
DTSTART:20231225T000000
|
|
||||||
DTEND:20231226T000000
|
|
||||||
END:VEVENT
|
END:VEVENT
|
||||||
END:VCALENDAR
|
END:VCALENDAR
|
Loading…
Reference in New Issue