Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions tests/e2e/tests/generate/formatting.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,26 @@
import assert from 'node:assert/strict';
import { expectFileToMatch, readFile, writeFile } from '../../utils/fs';
import { expectFileToMatch, writeFile } from '../../utils/fs';
import { installPackage, uninstallPackage } from '../../utils/packages';
import { ng } from '../../utils/process';

export default async function () {
const untouched = 'export const untouched={value:"unchanged"};';
try {
await writeFile('src/untouched.ts', untouched);
await writeFile('.prettierrc', JSON.stringify({ singleQuote: true, semi: false }));
await ng('generate', 'service', 'prettier-only', '--skip-tests');
await expectFileToMatch('src/app/prettier-only.ts', "from '@angular/core'\n");
await expectFileToMatch('src/app/prettier-only.ts', "from '@angular/core'");
Comment thread
alan-agius4 marked this conversation as resolved.
Resolved

// Distinct configurations make the selected formatter observable when both are installed.
await installPackage('oxfmt');
await writeFile('.oxfmtrc.json', JSON.stringify({ singleQuote: false, semi: false }));
await ng('generate', 'service', 'both-formatters', '--skip-tests');
await expectFileToMatch('src/app/both-formatters.ts', "from '@angular/core'\n");
await expectFileToMatch('src/app/both-formatters.ts', "from '@angular/core'");
Comment thread
alan-agius4 marked this conversation as resolved.
Resolved

await uninstallPackage('prettier');
await ng('generate', 'service', 'oxfmt-only', '--skip-tests');
await expectFileToMatch('src/app/oxfmt-only.ts', 'from "@angular/core"\n');
await expectFileToMatch('src/app/oxfmt-only.ts', 'from "@angular/core"');
Comment thread
alan-agius4 marked this conversation as resolved.
Resolved

await uninstallPackage('oxfmt');
await ng('generate', 'service', 'no-formatter', '--skip-tests');
await expectFileToMatch('src/app/no-formatter.ts', "from '@angular/core';\n");

assert.equal(await readFile('src/untouched.ts'), untouched);
await expectFileToMatch('src/app/no-formatter.ts', "from '@angular/core';");
Comment thread
alan-agius4 marked this conversation as resolved.
Resolved
} finally {
await uninstallPackage('oxfmt');
await installPackage('prettier');
Expand Down
Loading