-
Notifications
You must be signed in to change notification settings - Fork 0
/
bar_test.go
39 lines (34 loc) · 858 Bytes
/
bar_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
package gps
import (
"strings"
"testing"
)
func TestBarSVG(t *testing.T) {
// Test rendering the SVG with default options
bar, err := NewBar()
if err != nil {
t.Fatalf("Expected no error, got %v", err)
}
svg := bar.SVG()
expectedStart := `<svg width="200" height="76"`
if !strings.HasPrefix(svg, expectedStart) {
t.Errorf("Expected SVG to start with %s, got %s", expectedStart, svg)
}
// Test rendering the SVG with custom options
bar, err = NewBar(
func(o *BarOptions) error {
o.Progress = 75
o.ProgressColor = "#ff0000"
o.BackgroundColor = "#0000ff"
return nil
},
)
if err != nil {
t.Fatalf("Expected no error, got %v", err)
}
svg = bar.SVG()
expectedStart = `<svg width="200" height="76"`
if !strings.HasPrefix(svg, expectedStart) {
t.Errorf("Expected SVG to start with %s, got %s", expectedStart, svg)
}
}