Skip to content

Commit

Permalink
test: make sure newline is consistent (#3560)
Browse files Browse the repository at this point in the history
Co-authored-by: Johnson Chu <johnsoncodehk@gmail.com>
  • Loading branch information
so1ve and johnsoncodehk committed Sep 15, 2023
1 parent ead6adb commit 2c74284
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/vue-language-service/tests/complete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type * as vscode from 'vscode-languageserver-protocol';

const baseDir = path.resolve(__dirname, '../../vue-test-workspace/complete');
const testDirs = fs.readdirSync(baseDir);
const normalizeNewline = (text: string) => text.replace(/\r\n/g, '\n');

for (const dirName of testDirs) {

Expand Down Expand Up @@ -74,7 +75,7 @@ for (const dirName of testDirs) {

result = result.replaceAll('$0', '').replaceAll('$1', '');

expect(result.replace(/\r\n/g, '\n')).toBe(expectedFileText.replace(/\r\n/g, '\n'));
expect(normalizeNewline(result)).toBe(normalizeNewline(expectedFileText));
});
}
}
Expand Down
3 changes: 2 additions & 1 deletion packages/vue-tsc/tests/dts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const workspace = path.resolve(__dirname, '../../vue-test-workspace/vue-tsc-dts'
const testFiles = readFilesRecursive(workspace);
const ensureTs = (filename: string) => filename.endsWith('.ts') ? filename : filename + '.ts';
const normalizePath = (filename: string) => filename.replace(/\\/g, '/');
const normalizeNewline = (text: string) => text.replace(/\r\n/g, '\n');

describe('vue-tsc-dts', () => {
const compilerOptions: ts.CompilerOptions = {
Expand All @@ -27,7 +28,7 @@ describe('vue-tsc-dts', () => {
const output = service.getEmitOutput(ensureTs(file), true);
for (const outputFile of output.outputFiles) {
it(`Input: ${shortenPath(file)}, Output: ${shortenPath(outputFile.name)}`, () => {
expect(outputFile.text).toMatchSnapshot();
expect(normalizeNewline(outputFile.text)).toMatchSnapshot();
});
}
}
Expand Down

0 comments on commit 2c74284

Please sign in to comment.