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
|
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
// Test prettifyCSS.
"use strict";
const {prettifyCSS} = require("devtools/shared/inspector/css-logic");
const TESTS = [
{ name: "simple test",
input: "div { font-family:'Arial Black', Arial, sans-serif; }",
expected: [
"div {",
"\tfont-family:'Arial Black', Arial, sans-serif;",
"}"
]
},
{ name: "whitespace before open brace",
input: "div{}",
expected: [
"div {",
"}"
]
},
{ name: "minified with trailing newline",
input: "\nbody{background:white;}div{font-size:4em;color:red}span{color:green;}\n",
expected: [
"body {",
"\tbackground:white;",
"}",
"div {",
"\tfont-size:4em;",
"\tcolor:red",
"}",
"span {",
"\tcolor:green;",
"}"
]
},
{ name: "leading whitespace",
input: "\n div{color: red;}",
expected: [
"div {",
"\tcolor: red;",
"}"
]
},
];
function run_test() {
// Note that prettifyCSS.LINE_SEPARATOR is computed lazily, so we
// ensure it is set.
prettifyCSS("");
for (let test of TESTS) {
do_print(test.name);
let input = test.input.split("\n").join(prettifyCSS.LINE_SEPARATOR);
let output = prettifyCSS(input);
let expected = test.expected.join(prettifyCSS.LINE_SEPARATOR) +
prettifyCSS.LINE_SEPARATOR;
equal(output, expected, test.name);
}
}
|