-
Notifications
You must be signed in to change notification settings - Fork 85
Expand file tree
/
Copy pathtest-second-format.js
More file actions
27 lines (24 loc) · 880 Bytes
/
test-second-format.js
File metadata and controls
27 lines (24 loc) · 880 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import * as failedTests from "./failed-format-tests.js";
import { format } from "./run-prettier.js";
async function testSecondFormat(source, formatResult, filename, formatOptions) {
const isUnstableTest = failedTests.isUnstable(filename, formatOptions);
if (
(formatResult.changed || isUnstableTest) &&
// No range and cursor
formatResult.input === source
) {
const { eolVisualizedOutput: firstOutput, output } = formatResult;
const { eolVisualizedOutput: secondOutput } = await format(
output,
formatOptions,
);
// To keep eye on failed tests, this assert never supposed to pass,
// if it fails, just remove the file from `unstableTests`
if (isUnstableTest) {
expect(secondOutput).not.toEqual(firstOutput);
return;
}
expect(secondOutput).toEqual(firstOutput);
}
}
export { testSecondFormat as run };