1
0
Fork 0

test: add test for date based events

This commit is contained in:
Ryan Mwangi 2024-11-25 14:35:55 +03:00
parent 227ec8a211
commit 5b40bf5d75
1 changed files with 27 additions and 27 deletions

View File

@ -15,7 +15,7 @@ const EXPECTED_OUTPUTS_DIR = path.join(__dirname, 'expected_outputs');
let server; let server;
process.chdir(__dirname) process.chdir(__dirname)
// console.log(process.cwd()); console.log(process.cwd());
import app from '../src/server.js'; import app from '../src/server.js';
const normalizeLineEndings = (str) => str.replace(/\r\n/g, '\r\n').trimEnd(); // Normalize to CRLF const normalizeLineEndings = (str) => str.replace(/\r\n/g, '\r\n').trimEnd(); // Normalize to CRLF
@ -59,7 +59,7 @@ describe('Calendar Merging API', () => {
expect(response.status).toBe(200); expect(response.status).toBe(200);
// 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, 'nextcloud-minimal.ics'); const filePath = path.join(CALENDARS_DIR, 'nextcloud-minimal.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 // Load expected output
@ -91,7 +91,7 @@ describe('Calendar Merging API', () => {
expect(response.status).toBe(200); expect(response.status).toBe(200);
// 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, 'google-calendar-minimal.ics'); const filePath = path.join(CALENDARS_DIR, 'google-calendar-minimal.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 // Load expected output
@ -107,30 +107,30 @@ describe('Calendar Merging API', () => {
}); });
// test('Preserve date-based calendar', async () => { test('Preserve date-based calendar', async () => {
// const input = getTestCalendarFilename('US_Holidays.ics'); const input = getTestCalendarFilename('US_Holidays.ics');
// const response = await request(server) const response = await request(server)
// .post('/merge') .post('/merge')
// .send({ .send({
// linkGroupName: 'US Holidays', linkGroupName: 'US Holidays',
// calendars: [ calendars: [
// { {
// url: input, url: input,
// prefix: '', prefix: '',
// override: false, override: false,
// }, },
// ], ],
// }); });
// expect(response.status).toBe(200); expect(response.status).toBe(200);
// // 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, 'US_Holidays.ics'); const filePath = path.join(CALENDARS_DIR, 'US_Holidays.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 = fs.readFileSync(input, 'utf8'); const expectedOutput = fs.readFileSync(input, 'utf8');
// const actualOutput = fs.readFileSync(filePath, 'utf8'); const actualOutput = fs.readFileSync(filePath, 'utf8');
// 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)