-
Notifications
You must be signed in to change notification settings - Fork 476
Expand file tree
/
Copy pathjson.js
More file actions
54 lines (44 loc) · 1.75 KB
/
Copy pathjson.js
File metadata and controls
54 lines (44 loc) · 1.75 KB
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
(function() {
"use strict";
var Assert = YUITest.Assert;
YUITest.TestRunner.add(new YUITest.TestCase({
name: "JSON formatter",
"File with no problems should return empty string": function() {
var result = {
messages: [],
stats: []
},
actual = CSSLint.getFormatter("json").formatResults(result, "path/to/FILE", {
fullPath: "/absolute/path/to/FILE"
});
Assert.areEqual("", actual);
},
"Files with problems should list them": function() {
var result = {
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: []
};
/*jshint -W108 */
var expected = '[{"filename":"path/to/FILE","results":{"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":[]}}]';
var formatter = CSSLint.getFormatter("json");
var actual = formatter.startFormat() + formatter.formatResults(result, "path/to/FILE", {
fullPath: "/absolute/path/to/FILE"
}) + formatter.endFormat();
Assert.areEqual(expected, actual);
}
}));
})();