Skip to content

Commit 952877e

Browse files
committed
fix: normalize line endings in test files for consistency
- Updated tests to replace Windows-style line endings with Unix-style in the expected content. - Ensured consistency in line endings across multiple test cases to prevent discrepancies during comparisons.
1 parent 6f5977b commit 952877e

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

test/index.test.ts

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ describe('Windsurf-to-Cursor Converter', () => {
1414
let expectedCursorManualContent: string;
1515

1616
beforeAll(async () => {
17-
expectedCursorManualContent = await readFile(cursorManualPath, 'utf-8');
17+
expectedCursorManualContent = (
18+
await readFile(cursorManualPath, 'utf-8')
19+
).replace(/\r\n/g, '\n');
1820
// Create a temporary directory for test outputs
1921
await mkdir(tempTestDir, { recursive: true });
2022
});
@@ -88,10 +90,9 @@ describe('Windsurf-to-Cursor Converter', () => {
8890
// Copy some fixture files to the temp input directory
8991
const windsurfAgentPath = path.join(fixturesDir, 'agent-windsurf.md');
9092
const cursorAgentPath = path.join(fixturesDir, 'agent-cursor.mdc');
91-
const expectedCursorAgentContent = await readFile(
92-
cursorAgentPath,
93-
'utf-8'
94-
);
93+
const expectedCursorAgentContent = (
94+
await readFile(cursorAgentPath, 'utf-8')
95+
).replace(/\r\n/g, '\n');
9596

9697
await writeFile(
9798
path.join(inputDir, 'manual-windsurf.md'),
@@ -206,7 +207,10 @@ describe('CLI (cuws)', () => {
206207

207208
beforeAll(async () => {
208209
// Load content needed specifically for CLI tests
209-
expectedCursorManualContent = await readFile(cursorManualPath, 'utf-8');
210+
// This variable is re-declared in this scope, so it needs normalization here too.
211+
expectedCursorManualContent = (
212+
await readFile(cursorManualPath, 'utf-8')
213+
).replace(/\r\n/g, '\n');
210214
});
211215

212216
const execCli = (
@@ -318,7 +322,9 @@ describe('CLI (cuws)', () => {
318322

319323
beforeAll(async () => {
320324
const cursorAgentPath = path.join(fixturesDir, 'agent-cursor.mdc');
321-
expectedCursorAgentContent = await readFile(cursorAgentPath, 'utf-8');
325+
expectedCursorAgentContent = (
326+
await readFile(cursorAgentPath, 'utf-8')
327+
).replace(/\r\n/g, '\n');
322328
});
323329

324330
beforeEach(async () => {
@@ -496,7 +502,18 @@ describe('CLI (cuws)', () => {
496502
let windsurfManualContent: string;
497503

498504
beforeAll(async () => {
499-
windsurfManualContent = await readFile(inputFile, 'utf-8');
505+
// Normalize windsurfManualContent as well if it's used in comparisons
506+
// where the other side is normalized or expected to be LF.
507+
// The `echo` command on Windows might produce CRLF.
508+
// However, the direct comparison is `stdout.trim()).toEqual(expectedCursorManualContent.trim())`
509+
// and expectedCursorManualContent is already normalized.
510+
// So, this specific one might not need normalization if `echo` on CI produces LF,
511+
// or if `trim()` handles mixed line endings well enough before comparison.
512+
// For safety and consistency, let's normalize it if it's directly used in an echo.
513+
windsurfManualContent = (await readFile(inputFile, 'utf-8')).replace(
514+
/\r\n/g,
515+
'\n'
516+
);
500517
});
501518

502519
it('should convert stdin to stdout', async () => {

0 commit comments

Comments
 (0)