test(calendar): run tests for different calendar instances
This commit is contained in:
parent
51c4f5c31f
commit
92c6fffe64
|
@ -151,177 +151,127 @@ describe('Calendar Merging API', () => {
|
||||||
expect(actualOutput).toBe(expectedOutput);
|
expect(actualOutput).toBe(expectedOutput);
|
||||||
});
|
});
|
||||||
|
|
||||||
// test('Merge time-based calendar', async () => {
|
//test Merge time-based calendar
|
||||||
// const input = getTestCalendarFilename('work_task_calendar.ics');
|
test('Merge time-based calendar', async () => {
|
||||||
// const response = await request(server)
|
const input = getTestCalendarFilename('work_task_calendar.ics');
|
||||||
// .post('/merge')
|
const response = await request(server)
|
||||||
// .send({
|
.post('/merge')
|
||||||
// linkGroupName: 'Time Based Calendar',
|
.send({
|
||||||
// calendars: [
|
linkGroupName: 'Time Based Calendar',
|
||||||
// {
|
calendars: [
|
||||||
// url: input,
|
{
|
||||||
// prefix: 'work_task',
|
url: getTestCalendarFilename('team_meeting_calendar.ics'), // Time-based calendar
|
||||||
// override: false,
|
prefix: 'team_meeting_calendar',
|
||||||
// },
|
override: false,
|
||||||
// ],
|
},
|
||||||
// });
|
{
|
||||||
|
url: getTestCalendarFilename('work_task_calendar.ics'), // Time-based calendar
|
||||||
|
prefix: 'Work_Task',
|
||||||
|
override: false,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
// expect(response.status).toBe(200);
|
expect(response.status).toBe(200);
|
||||||
// expect(response.body.url).toMatch(/calendar\/Time_Based_Calendar/);
|
expect(response.body.url).toMatch(/calendar\/Time_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, 'Time_Based_Calendar.ics');
|
const filePath = path.join(CALENDARS_DIR, 'Time_Based_Calendar.ics');
|
||||||
// expect(fs.existsSync(filePath)).toBe(true);
|
expect(fs.existsSync(filePath)).toBe(true);
|
||||||
|
|
||||||
// // Load expected output and compare
|
// Load expected output and compare
|
||||||
// const expectedOutput = fs.readFileSync(input, 'utf8');
|
const expectedOutput = loadExpectedOutput('Time_Based_Calendar.ics');
|
||||||
// const actualOutput = fs.readFileSync(filePath, 'utf8');
|
const actualOutput = fs.readFileSync(filePath, 'utf8');
|
||||||
// expect(actualOutput).toBe(expectedOutput);
|
expect(actualOutput).toBe(expectedOutput);
|
||||||
// });
|
});
|
||||||
|
|
||||||
// test('EAT Event', async () => {
|
//test Merge calendar without prefix
|
||||||
// const input = getTestCalendarFilename('eat_time_zone_event.ics');
|
test('Merge calendar without prefix', async () => {
|
||||||
// const response = await request(server)
|
const response = await request(server)
|
||||||
// .post('/merge')
|
.post('/merge')
|
||||||
// .send({
|
.send({
|
||||||
// linkGroupName: 'EAT Event',
|
linkGroupName: 'No Prefix Calendar',
|
||||||
// calendars: [
|
calendars: [
|
||||||
// {
|
{
|
||||||
// url: input,
|
url: getTestCalendarFilename('sf_public_holidays.ics'),
|
||||||
// prefix: 'EAT Event',
|
prefix: '',
|
||||||
// override: false,
|
override: false,
|
||||||
// },
|
},
|
||||||
// ],
|
],
|
||||||
// });
|
});
|
||||||
|
|
||||||
// expect(response.status).toBe(200);
|
expect(response.status).toBe(200);
|
||||||
// expect(response.body.url).toMatch(/calendar\/EAT_Event/);
|
expect(response.body.url).toMatch(/calendar\/No_Prefix_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, 'EAT_Event.ics');
|
const filePath = path.join(CALENDARS_DIR, 'No_Prefix_Calendar.ics');
|
||||||
// expect(fs.existsSync(filePath)).toBe(true);
|
expect(fs.existsSync(filePath)).toBe(true);
|
||||||
|
|
||||||
// // Load expected output and compare
|
// Load expected output and compare
|
||||||
// const expectedOutput = fs.readFileSync(input, 'utf8');
|
const expectedOutput = loadExpectedOutput('No_Prefix_Calendar.ics');
|
||||||
// const actualOutput = fs.readFileSync(filePath, 'utf8');
|
const actualOutput = fs.readFileSync(filePath, 'utf8');
|
||||||
// expect(actualOutput).toBe(expectedOutput);
|
expect(actualOutput).toBe(expectedOutput);
|
||||||
// });
|
});
|
||||||
|
|
||||||
// test('Merge calendar without prefix', async () => {
|
//test Merge calendar with override
|
||||||
// const response = await request(server)
|
test('Merge calendar with override', async () => {
|
||||||
// .post('/merge')
|
const response = await request(server)
|
||||||
// .send({
|
.post('/merge')
|
||||||
// linkGroupName: 'No Prefix Calendar',
|
.send({
|
||||||
// calendars: [
|
linkGroupName: 'Override Calendar',
|
||||||
// {
|
calendars: [
|
||||||
// url: getTestCalendarFilename('sf_public_holidays.ics'),
|
{
|
||||||
// prefix: '',
|
url: getTestCalendarFilename('sf_public_holidays.ics'),
|
||||||
// override: false,
|
prefix: 'Override Event',
|
||||||
// },
|
override: true,
|
||||||
// ],
|
},
|
||||||
// });
|
],
|
||||||
|
});
|
||||||
|
|
||||||
// expect(response.status).toBe(200);
|
expect(response.status).toBe(200);
|
||||||
// expect(response.body.url).toMatch(/calendar\/No_Prefix_Calendar/);
|
expect(response.body.url).toMatch(/calendar\/Override_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, 'No_Prefix_Calendar.ics');
|
const filePath = path.join(CALENDARS_DIR, 'Override_Calendar.ics');
|
||||||
// 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('No_Prefix_Calendar.ics');
|
const expectedOutput = loadExpectedOutput('Override_Calendar.ics');
|
||||||
// const actualOutput = fs.readFileSync(filePath, 'utf8');
|
const actualOutput = fs.readFileSync(filePath, 'utf8');
|
||||||
// expect(actualOutput).toBe(expectedOutput);
|
expect(actualOutput).toBe(expectedOutput);
|
||||||
// });
|
});
|
||||||
|
|
||||||
// test('Merge calendar with override', async () => {
|
//test Merge date-based and time-based calendars
|
||||||
// const response = await request(server)
|
test('Merge date-based and time-based calendars', async () => {
|
||||||
// .post('/merge')
|
const response = await request(server)
|
||||||
// .send({
|
.post('/merge')
|
||||||
// linkGroupName: 'Override Calendar',
|
.send({
|
||||||
// calendars: [
|
linkGroupName: 'Merged Date and Time Based Calendar',
|
||||||
// {
|
calendars: [
|
||||||
// url: getTestCalendarFilename('sf_public_holidays.ics'),
|
{
|
||||||
// prefix: 'Override Event',
|
url: getTestCalendarFilename('holiday_calendar_2023.ics'), // Date-based calendar
|
||||||
// override: true,
|
prefix: 'Holiday_2023',
|
||||||
// },
|
override: false,
|
||||||
// ],
|
},
|
||||||
// });
|
{
|
||||||
|
url: getTestCalendarFilename('work_task_calendar.ics'), // Time-based calendar
|
||||||
|
prefix: 'Work_Task',
|
||||||
|
override: false,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
// expect(response.status).toBe(200);
|
expect(response.status).toBe(200);
|
||||||
// expect(response.body.url).toMatch(/calendar\/Override_Calendar/);
|
expect(response.body.url).toMatch(new RegExp('calendar/Merged_Date_and_Time_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, 'Override_Calendar.ics');
|
const filePath = path.join(CALENDARS_DIR, 'Merged_Date_and_Time_Based_Calendar.ics');
|
||||||
// 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('Override_Calendar.ics');
|
const expectedOutput = loadExpectedOutput('Merged_Date_and_Time_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 UTC and EAT time zone calendar', async () => {
|
|
||||||
// const response = await request(server)
|
|
||||||
// .post('/merge')
|
|
||||||
// .send({
|
|
||||||
// linkGroupName: 'UTCEAT Time Zone Calendar',
|
|
||||||
// calendars: [
|
|
||||||
// {
|
|
||||||
// url: getTestCalendarFilename('utc_time_zone_event.ics'),
|
|
||||||
// prefix: 'UTC_Event',
|
|
||||||
// override: false,
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// url: getTestCalendarFilename('eat_time_zone_event.ics'),
|
|
||||||
// prefix: 'EAT_Event',
|
|
||||||
// override: false,
|
|
||||||
// },
|
|
||||||
// ],
|
|
||||||
// });
|
|
||||||
// expect(response.status).toBe(200);
|
|
||||||
// expect(response.body.url).toMatch(new RegExp(`calendar/UTCEAT_Time_Zone_Calendar`));
|
|
||||||
|
|
||||||
// // Check if the file was created in the test directory
|
|
||||||
// const filePath = path.join(CALENDARS_DIR, 'UTCEAT_Time_Zone_Calendar.ics');
|
|
||||||
// expect(fs.existsSync(filePath)).toBe(true);
|
|
||||||
|
|
||||||
// // Load expected output and compare
|
|
||||||
// const expectedOutput = loadExpectedOutput('UTCEAT_Time_Zone_Calendar.ics');
|
|
||||||
// const actualOutput = fs.readFileSync(filePath, 'utf8');
|
|
||||||
// expect(actualOutput).toBe(expectedOutput);
|
|
||||||
// });
|
|
||||||
|
|
||||||
// test('Merge date-based and time-based calendars', async () => {
|
|
||||||
// const response = await request(server)
|
|
||||||
// .post('/merge')
|
|
||||||
// .send({
|
|
||||||
// linkGroupName: 'Merged Date and Time Based Calendar',
|
|
||||||
// calendars: [
|
|
||||||
// {
|
|
||||||
// url: getTestCalendarFilename('holiday_calendar_2023.ics'), // Date-based calendar
|
|
||||||
// prefix: 'Holiday_2023',
|
|
||||||
// override: false,
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// url: getTestCalendarFilename('work_task_calendar.ics'), // Time-based calendar
|
|
||||||
// prefix: 'Work_Task',
|
|
||||||
// override: false,
|
|
||||||
// },
|
|
||||||
// ],
|
|
||||||
// });
|
|
||||||
|
|
||||||
// expect(response.status).toBe(200);
|
|
||||||
// expect(response.body.url).toMatch(new RegExp('calendar/Merged_Date_and_Time_Based_Calendar'));
|
|
||||||
|
|
||||||
// // Check if the file was created in the test directory
|
|
||||||
// const filePath = path.join(CALENDARS_DIR, 'Merged_Date_and_Time_Based_Calendar.ics');
|
|
||||||
// expect(fs.existsSync(filePath)).toBe(true);
|
|
||||||
|
|
||||||
// // Load expected output and compare
|
|
||||||
// const expectedOutput = loadExpectedOutput('Merged_Date_and_Time_Based_Calendar.ics');
|
|
||||||
// const actualOutput = fs.readFileSync(filePath, 'utf8');
|
|
||||||
// expect(actualOutput).toBe(expectedOutput);
|
|
||||||
// });
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,17 +1,21 @@
|
||||||
BEGIN:VCALENDAR
|
BEGIN:VCALENDAR
|
||||||
PRODID:-//Your Product ID//EN
|
|
||||||
VERSION:2.0
|
|
||||||
NAME:Merged Date and Time Based Calendar
|
NAME:Merged Date and Time 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_2023 Christmas Day
|
SUMMARY:Holiday_2023 Christmas Day
|
||||||
DTSTART:20231225T000000
|
LOCATION:Germany
|
||||||
DTEND:20231226T000000
|
|
||||||
END:VEVENT
|
END:VEVENT
|
||||||
BEGIN:VEVENT
|
BEGIN:VEVENT
|
||||||
UID:20231108T090000-001@example.com
|
UID:20231108T090000-001@example.com
|
||||||
|
DTSTART:20231108T090000Z
|
||||||
|
DTEND:20231108T100000Z
|
||||||
|
DTSTAMP:20231108T090000Z
|
||||||
SUMMARY:Work_Task Work Task
|
SUMMARY:Work_Task Work Task
|
||||||
DTSTART:20231108T120000
|
|
||||||
DTEND:20231108T130000
|
|
||||||
END:VEVENT
|
END:VEVENT
|
||||||
END:VCALENDAR
|
END:VCALENDAR
|
|
@ -1,11 +1,14 @@
|
||||||
BEGIN:VCALENDAR
|
BEGIN:VCALENDAR
|
||||||
PRODID:-//Your Product ID//EN
|
|
||||||
VERSION:2.0
|
|
||||||
NAME:No Prefix Calendar
|
NAME:No Prefix 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
|
||||||
SUMMARY: Christmas Day
|
DTSTART;VALUE=DATE:20231225
|
||||||
DTSTART:20231225T000000
|
DTEND;VALUE=DATE:20231226
|
||||||
DTEND:20231226T000000
|
DTSTAMP:20231225T000000Z
|
||||||
|
SUMMARY:Christmas Day
|
||||||
|
LOCATION:San Francisco
|
||||||
END:VEVENT
|
END:VEVENT
|
||||||
END:VCALENDAR
|
END:VCALENDAR
|
|
@ -1,11 +1,13 @@
|
||||||
BEGIN:VCALENDAR
|
BEGIN:VCALENDAR
|
||||||
PRODID:-//Your Product ID//EN
|
|
||||||
VERSION:2.0
|
|
||||||
NAME:Override Calendar
|
NAME:Override 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
|
||||||
SUMMARY:Override Event Christmas Day
|
DTSTART;VALUE=DATE:20231225
|
||||||
DTSTART:20231225T000000
|
DTEND;VALUE=DATE:20231226
|
||||||
DTEND:20231226T000000
|
DTSTAMP:20231225T000000Z
|
||||||
|
SUMMARY:Override Event
|
||||||
END:VEVENT
|
END:VEVENT
|
||||||
END:VCALENDAR
|
END:VCALENDAR
|
|
@ -1,17 +1,21 @@
|
||||||
BEGIN:VCALENDAR
|
BEGIN:VCALENDAR
|
||||||
PRODID:-//Your Product ID//EN
|
|
||||||
VERSION:2.0
|
|
||||||
NAME:Time Based Calendar
|
NAME:Time Based Calendar
|
||||||
|
PRODID:-//CalMerge//Calendar Merger 1.0//EN
|
||||||
|
VERSION:2.0
|
||||||
|
CALSCALE:GREGORIAN
|
||||||
BEGIN:VEVENT
|
BEGIN:VEVENT
|
||||||
UID:20231109T110000-001@example.com
|
UID:20231109T110000-001@example.com
|
||||||
|
DTSTART:20231109T110000Z
|
||||||
|
DTEND:20231109T120000Z
|
||||||
|
DTSTAMP:20231109T110000Z
|
||||||
SUMMARY:team_meeting_calendar Team Meeting
|
SUMMARY:team_meeting_calendar Team Meeting
|
||||||
DTSTART:20231109T140000
|
LOCATION:Virtual
|
||||||
DTEND:20231109T150000
|
|
||||||
END:VEVENT
|
END:VEVENT
|
||||||
BEGIN:VEVENT
|
BEGIN:VEVENT
|
||||||
UID:20231108T090000-001@example.com
|
UID:20231108T090000-001@example.com
|
||||||
SUMMARY:work_task Work Task
|
DTSTART:20231108T090000Z
|
||||||
DTSTART:20231108T120000
|
DTEND:20231108T100000Z
|
||||||
DTEND:20231108T130000
|
DTSTAMP:20231108T090000Z
|
||||||
|
SUMMARY:Work_Task Work Task
|
||||||
END:VEVENT
|
END:VEVENT
|
||||||
END:VCALENDAR
|
END:VCALENDAR
|
|
@ -1,17 +0,0 @@
|
||||||
BEGIN:VCALENDAR
|
|
||||||
PRODID:-//Your Product ID//EN
|
|
||||||
VERSION:2.0
|
|
||||||
NAME:UTCEAT Time Zone Calendar
|
|
||||||
BEGIN:VEVENT
|
|
||||||
UID:20231108T100000Z-001@example.com
|
|
||||||
SUMMARY:UTC_Event UTC Event
|
|
||||||
DTSTART:20231108T130000
|
|
||||||
DTEND:20231108T140000
|
|
||||||
END:VEVENT
|
|
||||||
BEGIN:VEVENT
|
|
||||||
UID:20231108T090000+0300-001@example.com
|
|
||||||
SUMMARY:EAT_Event EAT Event
|
|
||||||
DTSTART:20231108T090000
|
|
||||||
DTEND:20231108T100000
|
|
||||||
END:VEVENT
|
|
||||||
END:VCALENDAR
|
|
|
@ -1,15 +0,0 @@
|
||||||
{
|
|
||||||
"linkGroupName": "UTCEAT Time Zone Calendar",
|
|
||||||
"calendars": [
|
|
||||||
{
|
|
||||||
"url": "C:\\Users\\user\\OneDrive\\Desktop\\Internship_tasks\\final calmerg\\test\\test_calendars\\utc_time_zone_event.ics",
|
|
||||||
"prefix": "UTC_Event",
|
|
||||||
"override": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "C:\\Users\\user\\OneDrive\\Desktop\\Internship_tasks\\final calmerg\\test\\test_calendars\\eat_time_zone_event.ics",
|
|
||||||
"prefix": "EAT_Event",
|
|
||||||
"override": false
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
|
@ -1,11 +0,0 @@
|
||||||
BEGIN:VCALENDAR
|
|
||||||
NAME:EAT Event
|
|
||||||
VERSION:2.0
|
|
||||||
BEGIN:VEVENT
|
|
||||||
UID:20231108T090000+0300-001@example.com
|
|
||||||
DTSTAMP:20231101T090000+03:00
|
|
||||||
DTSTART:20231108T090000+03:00
|
|
||||||
DTEND:20231108T100000+03:00
|
|
||||||
SUMMARY:EAT Event
|
|
||||||
END:VEVENT
|
|
||||||
END:VCALENDAR
|
|
|
@ -1,15 +0,0 @@
|
||||||
BEGIN:VCALENDAR
|
|
||||||
VERSION:2.0
|
|
||||||
PRODID:-//Example Corp//NONSGML Event//EN
|
|
||||||
BEGIN:VEVENT
|
|
||||||
UID:20231108T100000Z-001@example.com
|
|
||||||
DTSTAMP:20231108T100000Z
|
|
||||||
DTSTART:20231108T100000Z
|
|
||||||
DTEND:20231108T110000Z
|
|
||||||
SUMMARY:UTC Event
|
|
||||||
DESCRIPTION:This event is scheduled in UTC.
|
|
||||||
LOCATION:Virtual
|
|
||||||
STATUS:CONFIRMED
|
|
||||||
SEQUENCE:0
|
|
||||||
END:VEVENT
|
|
||||||
END:VCALENDAR
|
|
Loading…
Reference in New Issue