|
1 | 1 | import { FULL_TEST } from "./constants.js"; |
2 | 2 | import { replacePlaceholders } from "./replace-placeholders.js"; |
3 | 3 | import { format } from "./run-prettier.js"; |
4 | | -import consistentEndOfLine from "./utils/consistent-end-of-line.js"; |
5 | | -import createSnapshot from "./utils/create-snapshot.js"; |
6 | | -import visualizeEndOfLine from "./utils/visualize-end-of-line.js"; |
7 | 4 | import * as testAstCompare from "./test-ast-compare.js"; |
8 | 5 | import * as testBom from "./test-bom.js"; |
9 | 6 | import * as testEndOfLine from "./test-end-of-line.js"; |
| 7 | +import * as testFormat from "./test-format.js"; |
10 | 8 | import * as testSecondFormat from "./test-second-format.js"; |
11 | 9 | import * as testBytecodeCompare from "./test-bytecode-compare.js"; |
12 | 10 | import * as testAntlrFormat from "./test-antlr-format.js"; |
@@ -34,40 +32,15 @@ async function testFixture(fixture) { |
34 | 32 | let { code, expectedOutput, parser, formatOptions } = testCase; |
35 | 33 | let formatResult = await testCase.runFormat(); |
36 | 34 |
|
37 | | - // Verify parsers or error tests |
38 | | - if (formatOptions.parser !== parser) { |
39 | | - const runFormat = () => format(code, formatOptions); |
40 | | - |
41 | | - if (shouldThrowOnFormat(name, formatOptions)) { |
42 | | - await expect(runFormat()).rejects.toThrowErrorMatchingSnapshot(); |
43 | | - return; |
44 | | - } |
45 | | - |
46 | | - // Verify parsers format result should be the same as main parser |
47 | | - output = formatResult.outputWithCursor; |
48 | | - formatResult = await runFormat(); |
49 | | - } |
50 | | - |
51 | | - // Make sure output has consistent EOL |
52 | | - expect(formatResult.eolVisualizedOutput).toEqual( |
53 | | - visualizeEndOfLine( |
54 | | - consistentEndOfLine(formatResult.outputWithCursor), |
55 | | - ), |
| 35 | + await testFormat.run( |
| 36 | + code, |
| 37 | + formatResult, |
| 38 | + parser, |
| 39 | + parsers, |
| 40 | + expectedOutput, |
| 41 | + formatOptions, |
56 | 42 | ); |
57 | 43 |
|
58 | | - // The result is assert to equals to `expectedOutput` |
59 | | - if (typeof expectedOutput === "string") { |
60 | | - expect(formatResult.eolVisualizedOutput).toEqual( |
61 | | - visualizeEndOfLine(expectedOutput), |
62 | | - ); |
63 | | - return; |
64 | | - } |
65 | | - |
66 | | - // All parsers have the same result, only snapshot the result from main parser |
67 | | - expect( |
68 | | - createSnapshot(formatResult, { parsers, formatOptions }), |
69 | | - ).toMatchSnapshot(); |
70 | | - |
71 | 44 | if (!FULL_TEST) { |
72 | 45 | return; |
73 | 46 | } |
|
0 commit comments