-
Notifications
You must be signed in to change notification settings - Fork 97
/
formatOutput.test.ts
54 lines (42 loc) 路 1.58 KB
/
formatOutput.test.ts
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
import { formatOutput } from "./formatOutput";
import { EOL } from "os";
describe("formatOutput", () => {
it("formats output as JavaScript for a .js file path", () => {
// Arrange
const outputPath = ".eslintrc.js";
const configuration = { rules: {} };
// Act
const output = formatOutput(outputPath, configuration);
// Assert
expect(output).toBe(
`module.exports = ${JSON.stringify(configuration, undefined, 4)};${EOL}`,
);
});
it("formats output as JSON for a .json file path", () => {
// Arrange
const outputPath = ".eslintrc.json";
const configuration = { rules: {} };
// Act
const output = formatOutput(outputPath, configuration);
// Assert
expect(output).toBe(`${JSON.stringify(configuration, undefined, 4)}${EOL}`);
});
it("formats output as JSON for an unknown dot file path", () => {
// Arrange
const outputPath = ".eslintrc";
const configuration = { rules: {} };
// Act
const output = formatOutput(outputPath, configuration);
// Assert
expect(output).toBe(`${JSON.stringify(configuration, undefined, 4)}${EOL}`);
});
it("formats output as JSON for an unknown raw file path", () => {
// Arrange
const outputPath = "eslintrc";
const configuration = { rules: {} };
// Act
const output = formatOutput(outputPath, configuration);
// Assert
expect(output).toBe(`${JSON.stringify(configuration, undefined, 4)}${EOL}`);
});
});