1
0
Fork 0
CalMerger/calendar.test.js

38 lines
1.3 KiB
JavaScript
Raw Normal View History

2024-10-29 18:24:44 +00:00
import request from 'supertest';
2024-10-29 18:26:17 +00:00
import express from 'express';
import icalGenerator from 'ical-generator';
import fs from 'fs';
import path from 'path';
2024-10-29 18:27:29 +00:00
const MERGED_CALENDARS_DIR = 'calendar';
describe('Calendar Merging API', () => {
beforeAll(() => {
// Ensure the merged calendars directory exists
if (!fs.existsSync(MERGED_CALENDARS_DIR)) {
fs.mkdirSync(MERGED_CALENDARS_DIR);
}
});
afterAll(() => {
// Clean up the merged calendars directory after tests
fs.rmdirSync(MERGED_CALENDARS_DIR, { recursive: true });
});
2024-10-29 18:33:03 +00:00
test('Merge date-based calendar', async () => {
2024-10-29 18:34:45 +00:00
const response = await request(app)
.post('/merge')
.send({
linkGroupName: 'Date Based Calendar',
calendars: [
{
url: 'https://www.schulferien.org/media/ical/deutschland/ferien_bayern_2023.ics?k=PsL0S2B9rScFMn5PAxtf4OVQjMkWZsqqkK13zEJ0FCW5Q-2xQejfLJYaTN4EdYUsQHLDDbGVnVl93ms7en5vMUISjZ3H9Esu88Vp2ndnL5Q',
prefix: 'Date Event',
override: false,
},
],
});
2024-10-29 18:35:41 +00:00
expect(response.status).toBe(200);
expect(response.body.url).toMatch(/calendar\/Date_Based_Calendar/);
2024-10-29 18:33:03 +00:00
})
});