-
-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathformat.test.js
106 lines (83 loc) · 2.42 KB
/
format.test.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import { readFileSync } from "fs";
import * as prettier from "prettier";
import plugin from "../src/plugin.js";
const fixture = readFileSync(
new URL("./fixture.xml", import.meta.url),
"utf-8"
);
function format(content, opts = {}) {
return prettier.format(content, {
...opts,
parser: "xml",
plugins: [plugin]
});
}
test("defaults", async () => {
const formatted = await format(fixture);
expect(formatted).toMatchSnapshot();
});
test("xmlWhitespaceSensitivity => ignore", async () => {
const formatted = await format(fixture, {
xmlWhitespaceSensitivity: "ignore"
});
expect(formatted).toMatchSnapshot();
});
test("bracketSameLine => true", async () => {
const formatted = await format(fixture, {
bracketSameLine: true,
xmlWhitespaceSensitivity: "ignore"
});
expect(formatted).toMatchSnapshot();
});
test("xmlSelfClosingSpace => false", async () => {
const formatted = await format(fixture, {
xmlSelfClosingSpace: false,
xmlWhitespaceSensitivity: "ignore"
});
expect(formatted).toMatchSnapshot();
});
test("bracketSameLine => true, xmlSelfClosingSpace => false", async () => {
const formatted = await format(fixture, {
bracketSameLine: true,
xmlSelfClosingSpace: false,
xmlWhitespaceSensitivity: "ignore"
});
expect(formatted).toMatchSnapshot();
});
test("singleAttributePerLine => true", async () => {
const formatted = await format(fixture, {
singleAttributePerLine: true,
xmlWhitespaceSensitivity: "ignore"
});
expect(formatted).toMatchSnapshot();
});
test("xmlWhitespaceSensitivity => preserve", async () => {
const formatted = await format(fixture, {
xmlWhitespaceSensitivity: "preserve"
});
expect(formatted).toMatchSnapshot();
});
test("xmlSortAttributesByKey => true", async () => {
const formatted = await format(fixture, {
xmlSortAttributesByKey: true
});
expect(formatted).toMatchSnapshot();
});
test("xmlQuoteAttributes => preserve", async () => {
const formatted = await format(fixture, {
xmlQuoteAttributes: "preserve"
});
expect(formatted).toMatchSnapshot();
});
test("xmlQuoteAttributes => single", async () => {
const formatted = await format(fixture, {
xmlQuoteAttributes: "single"
});
expect(formatted).toMatchSnapshot();
});
test("xmlQuoteAttributes => double", async () => {
const formatted = await format(fixture, {
xmlQuoteAttributes: "double"
});
expect(formatted).toMatchSnapshot();
});