forked from prettier/prettier
/
format.js
35 lines (29 loc) · 870 Bytes
/
format.js
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
28
29
30
31
32
33
34
35
"use strict";
const prettier = require("prettier/local");
test("yaml parser should handle CRLF correctly", () => {
const input = "a:\r\n 123\r\n";
expect(
// use JSON.stringify to observe CRLF
JSON.stringify(prettier.format(input, { parser: "yaml" }))
).toMatchSnapshot();
});
test("typescript parser should throw the first error when both JSX and non-JSX mode failed", () => {
const input = `
import React from "react";
const App = () => (
<div className="App">
</div>
);
label:
`;
expect(() =>
prettier.format(input, { parser: "typescript" })
).toThrowErrorMatchingSnapshot();
});
test("html parser should handle CRLF correctly", () => {
const input = "<!--\r\n test\r\n test\r\n-->";
expect(
// use JSON.stringify to observe CRLF
JSON.stringify(prettier.format(input, { parser: "html" }))
).toMatchSnapshot();
});