|
| 1 | +(function(){ |
| 2 | + "use strict"; |
| 3 | + var Assert = YUITest.Assert; |
| 4 | + |
| 5 | + YUITest.TestRunner.add(new YUITest.TestCase({ |
| 6 | + |
| 7 | + name: "JSON formatter", |
| 8 | + |
| 9 | + "File with no problems should say so": function() { |
| 10 | + var result = { messages: [], stats: [] }, |
| 11 | + actual = CSSLint.getFormatter("json").formatResults(result, "path/to/FILE", {fullPath: "/absolute/path/to/FILE"}); |
| 12 | + Assert.areEqual("{\"messages\":[],\"stats\":[]}", actual); |
| 13 | + }, |
| 14 | + |
| 15 | + "Should have no output when quiet option is specified and no errors": function() { |
| 16 | + var result = { messages: [], stats: [] }, |
| 17 | + actual = CSSLint.getFormatter("json").formatResults(result, "path/to/FILE", {fullPath: "/absolute/path/to/FILE", quiet: "true"}); |
| 18 | + Assert.areEqual("", actual); |
| 19 | + }, |
| 20 | + |
| 21 | + "File with problems should list them": function() { |
| 22 | + var result = { messages: [ |
| 23 | + { type: "warning", line: 1, col: 1, message: "BOGUS", evidence: "ALSO BOGUS", rule: [] }, |
| 24 | + { type: "error", line: 2, col: 1, message: "BOGUS", evidence: "ALSO BOGUS", rule: [] } |
| 25 | + ], stats: [] }, |
| 26 | + expected = "{\"messages\":[{\"type\":\"warning\",\"line\":1,\"col\":1,\"message\":\"BOGUS\",\"evidence\":\"ALSO BOGUS\",\"rule\":[]},{\"type\":\"error\",\"line\":2,\"col\":1,\"message\":\"BOGUS\",\"evidence\":\"ALSO BOGUS\",\"rule\":[]}],\"stats\":[]}", |
| 27 | + actual = CSSLint.getFormatter("json").formatResults(result, "path/to/FILE", {fullPath: "/absolute/path/to/FILE"}); |
| 28 | + Assert.areEqual(expected, actual); |
| 29 | + } |
| 30 | + |
| 31 | + })); |
| 32 | + |
| 33 | +})(); |
0 commit comments