Skip to content

Commit 7c509f8

Browse files
committed
test: avoid newline-specific assertions in formatting e2e test
Avoid hardcoding LF (`\n`) line endings in `formatting.ts` assertions so the test passes on Windows CI where CRLF (`\r\n`) line endings may be emitted.
1 parent cd3d30c commit 7c509f8

1 file changed

Lines changed: 5 additions & 10 deletions

File tree

‎tests/e2e/tests/generate/formatting.ts‎

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,26 @@
1-
import assert from 'node:assert/strict';
2-
import { expectFileToMatch, readFile, writeFile } from '../../utils/fs';
1+
import { expectFileToMatch, writeFile } from '../../utils/fs';
32
import { installPackage, uninstallPackage } from '../../utils/packages';
43
import { ng } from '../../utils/process';
54

65
export default async function () {
7-
const untouched = 'export const untouched={value:"unchanged"};';
86
try {
9-
await writeFile('src/untouched.ts', untouched);
107
await writeFile('.prettierrc', JSON.stringify({ singleQuote: true, semi: false }));
118
await ng('generate', 'service', 'prettier-only', '--skip-tests');
12-
await expectFileToMatch('src/app/prettier-only.ts', "from '@angular/core'\n");
9+
await expectFileToMatch('src/app/prettier-only.ts', "from '@angular/core'");
1310

1411
// Distinct configurations make the selected formatter observable when both are installed.
1512
await installPackage('oxfmt');
1613
await writeFile('.oxfmtrc.json', JSON.stringify({ singleQuote: false, semi: false }));
1714
await ng('generate', 'service', 'both-formatters', '--skip-tests');
18-
await expectFileToMatch('src/app/both-formatters.ts', "from '@angular/core'\n");
15+
await expectFileToMatch('src/app/both-formatters.ts', "from '@angular/core'");
1916

2017
await uninstallPackage('prettier');
2118
await ng('generate', 'service', 'oxfmt-only', '--skip-tests');
22-
await expectFileToMatch('src/app/oxfmt-only.ts', 'from "@angular/core"\n');
19+
await expectFileToMatch('src/app/oxfmt-only.ts', 'from "@angular/core"');
2320

2421
await uninstallPackage('oxfmt');
2522
await ng('generate', 'service', 'no-formatter', '--skip-tests');
26-
await expectFileToMatch('src/app/no-formatter.ts', "from '@angular/core';\n");
27-
28-
assert.equal(await readFile('src/untouched.ts'), untouched);
23+
await expectFileToMatch('src/app/no-formatter.ts', "from '@angular/core';");
2924
} finally {
3025
await uninstallPackage('oxfmt');
3126
await installPackage('prettier');

0 commit comments

Comments
 (0)