]>
git.proxmox.com Git - pve-eslint.git/blob - eslint/tests/lib/cli-engine/formatters/unix.js
2 * @fileoverview Tests for unix-style formatter.
8 //------------------------------------------------------------------------------
10 //------------------------------------------------------------------------------
12 const assert
= require("chai").assert
,
13 formatter
= require("../../../../lib/cli-engine/formatters/unix");
15 //------------------------------------------------------------------------------
17 //------------------------------------------------------------------------------
19 describe("formatter:compact", () => {
20 describe("when passed no messages", () => {
26 it("should return nothing", () => {
27 const result
= formatter(code
);
29 assert
.strictEqual(result
, "");
33 describe("when passed a single message", () => {
37 message
: "Unexpected foo.",
45 it("should return a string in the format filename:line:column: error [Error/rule_id]", () => {
46 const result
= formatter(code
);
48 assert
.strictEqual(result
, "foo.js:5:10: Unexpected foo. [Error/foo]\n\n1 problem");
51 it("should return a string in the format filename:line:column: warning [Warning/rule_id]", () => {
52 code
[0].messages
[0].severity
= 1;
53 const result
= formatter(code
);
55 assert
.strictEqual(result
, "foo.js:5:10: Unexpected foo. [Warning/foo]\n\n1 problem");
59 describe("when passed a fatal error message", () => {
64 message
: "Unexpected foo.",
71 it("should return a string in the format filename:line:column: error [Error/rule_id]", () => {
72 const result
= formatter(code
);
74 assert
.strictEqual(result
, "foo.js:5:10: Unexpected foo. [Error/foo]\n\n1 problem");
78 describe("when passed multiple messages", () => {
82 message
: "Unexpected foo.",
88 message
: "Unexpected bar.",
96 it("should return a string with multiple entries", () => {
97 const result
= formatter(code
);
99 assert
.strictEqual(result
, "foo.js:5:10: Unexpected foo. [Error/foo]\nfoo.js:6:11: Unexpected bar. [Warning/bar]\n\n2 problems");
103 describe("when passed multiple files with 1 message each", () => {
107 message
: "Unexpected foo.",
116 message
: "Unexpected bar.",
124 it("should return a string with multiple entries", () => {
125 const result
= formatter(code
);
127 assert
.strictEqual(result
, "foo.js:5:10: Unexpected foo. [Error/foo]\nbar.js:6:11: Unexpected bar. [Warning/bar]\n\n2 problems");
131 describe("when passed one file not found message", () => {
136 message
: "Couldn't find foo.js."
140 it("should return a string without line and column", () => {
141 const result
= formatter(code
);
143 assert
.strictEqual(result
, "foo.js:0:0: Couldn't find foo.js. [Error]\n\n1 problem");