MCPcopy Index your code
hub / github.com/wavetermdev/waveterm / TestParse1

Function TestParse1

pkg/vdom/cssparser/cssparser_test.go:24–57  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

22}
23
24func TestParse1(t *testing.T) {
25 style := `background: url("example;with;semicolons.jpg"); color: red; margin-right: 5px; content: "hello;world";`
26 p := MakeParser(style)
27 parsed, err := p.Parse()
28 if err != nil {
29 t.Fatalf("Parse failed: %v", err)
30 return
31 }
32 expected := map[string]string{
33 "background": `url("example;with;semicolons.jpg")`,
34 "color": "red",
35 "margin-right": "5px",
36 "content": `"hello;world"`,
37 }
38 if err := compareMaps(parsed, expected); err != nil {
39 t.Fatalf("Parsed map does not match expected: %v", err)
40 }
41
42 style = `margin-right: calc(10px + 5px); color: red; font-family: "Arial";`
43 p = MakeParser(style)
44 parsed, err = p.Parse()
45 if err != nil {
46 t.Fatalf("Parse failed: %v", err)
47 return
48 }
49 expected = map[string]string{
50 "margin-right": `calc(10px + 5px)`,
51 "color": "red",
52 "font-family": `"Arial"`,
53 }
54 if err := compareMaps(parsed, expected); err != nil {
55 t.Fatalf("Parsed map does not match expected: %v", err)
56 }
57}
58
59func TestParserErrors(t *testing.T) {
60 style := `hello more: bad;`

Callers

nothing calls this directly

Calls 3

MakeParserFunction · 0.85
compareMapsFunction · 0.85
ParseMethod · 0.80

Tested by

no test coverage detected