fix(line-endings): normalize line endings to LF for cross-platform consistency- Normalized line endings in generated calendar content to LF.- Updated test assertions to handle line-ending discrepancies.- Ensured compatibility across Windows and UNIX-like systems.
This commit is contained in:
parent
ca52065f66
commit
8965eaa319
|
@ -127,8 +127,9 @@ export function addEventsToCalendar(calendarComponent, results, overrideFlag = f
|
||||||
|
|
||||||
// Save calendar data to file
|
// Save calendar data to file
|
||||||
export function saveCalendarFile(filename, content) {
|
export function saveCalendarFile(filename, content) {
|
||||||
|
const normalizedContent = content.replace(/\r\n/g, '\n').trimEnd(); // Normalize to LF
|
||||||
const filePath = path.join(MERGED_CALENDARS_DIR, filename);
|
const filePath = path.join(MERGED_CALENDARS_DIR, filename);
|
||||||
// console.log(`Saving calendar data to file: ${filePath}`);
|
// console.log(`Saving calendar data to file: ${filePath}`);
|
||||||
fs.writeFileSync(filePath, content);
|
fs.writeFileSync(filePath, normalizedContent);
|
||||||
return filePath;
|
return filePath;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,8 @@ process.chdir(__dirname)
|
||||||
// console.log(process.cwd());
|
// console.log(process.cwd());
|
||||||
const app = require('../src/server').default;
|
const app = require('../src/server').default;
|
||||||
|
|
||||||
|
const normalizeLineEndings = (str) => str.replace(/\r\n/g, '\n').trimEnd();
|
||||||
|
|
||||||
describe('Calendar Merging API', () => {
|
describe('Calendar Merging API', () => {
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
// Start the server
|
// Start the server
|
||||||
|
@ -53,10 +55,17 @@ describe('Calendar Merging API', () => {
|
||||||
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 and compare
|
|
||||||
|
// Load expected output
|
||||||
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);
|
|
||||||
|
// Normalize line endings
|
||||||
|
const normalizedActual = normalizeLineEndings(actualOutput);
|
||||||
|
const normalizedExpected = normalizeLineEndings(expectedOutput);
|
||||||
|
|
||||||
|
//compare
|
||||||
|
expect(normalizedActual).toBe(normalizedExpected);
|
||||||
});
|
});
|
||||||
|
|
||||||
// test('Preserve date-based calendar', async () => {
|
// test('Preserve date-based calendar', async () => {
|
||||||
|
|
Loading…
Reference in New Issue