-
Notifications
You must be signed in to change notification settings - Fork 5
/
block_parser_test.go
50 lines (38 loc) · 1.31 KB
/
block_parser_test.go
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
package css
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestParseBlock(t *testing.T) {
css := ParseBlock(`
font-family: "Source Sans Pro", Arial, sans-serif;
font-size: 27px;
line-height: 35px;`)
assert.Equal(t, len(css), 3)
assert.Equal(t, "35px", css[2].Value.Text())
}
func TestParseBlockOneLine(t *testing.T) {
css := ParseBlock("font-family: \"Source Sans Pro\", Arial, sans-serif; font-size: 27px;")
assert.Equal(t, len(css), 2)
assert.Equal(t, "27px", css[1].Value.Text())
assert.Equal(t, "\"Source Sans Pro\", Arial, sans-serif", css[0].Value.Text())
}
func TestParseBlockBlankEnd(t *testing.T) {
css := ParseBlock("font-size: 27px; width: 10px")
assert.Equal(t, len(css), 2)
assert.Equal(t, "27px", css[0].Value.Text())
assert.Equal(t, "10px", css[1].Value.Text())
}
func TestParseBlockInportant(t *testing.T) {
css := ParseBlock("font-size: 27px; width: 10px !important")
assert.Equal(t, len(css), 2)
assert.Equal(t, "27px", css[0].Value.Text())
assert.Equal(t, "10px", css[1].Value.Text())
assert.Equal(t, true, css[1].Important)
}
func TestParseBlockWithBraces(t *testing.T) {
css := ParseBlock("{ font-size: 27px; width: 10px }")
assert.Equal(t, len(css), 2)
assert.Equal(t, "27px", css[0].Value.Text())
assert.Equal(t, "10px", css[1].Value.Text())
}