forked from tealeg/xlsx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
style_test.go
66 lines (55 loc) · 1.74 KB
/
style_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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package xlsx
import (
. "gopkg.in/check.v1"
)
type StyleSuite struct{}
var _ = Suite(&StyleSuite{})
func (s *StyleSuite) TestNewStyle(c *C) {
style := NewStyle()
c.Assert(style, NotNil)
}
func (s *StyleSuite) TestNewStyleDefaultts(c *C) {
style := NewStyle()
c.Assert(style.Font, Equals, *DefaultFont())
c.Assert(style.Fill, Equals, *DefaultFill())
c.Assert(style.Border, Equals, *DefaultBorder())
}
func (s *StyleSuite) TestMakeXLSXStyleElements(c *C) {
style := NewStyle()
font := *NewFont(12, "Verdana")
font.Bold = true
font.Italic = true
font.Underline = true
style.Font = font
fill := *NewFill("solid", "00FF0000", "FF000000")
style.Fill = fill
border := *NewBorder("thin", "thin", "thin", "thin")
style.Border = border
style.ApplyBorder = true
style.ApplyFill = true
style.ApplyFont = true
xFont, xFill, xBorder, xCellXf := style.makeXLSXStyleElements()
c.Assert(xFont.Sz.Val, Equals, "12")
c.Assert(xFont.Name.Val, Equals, "Verdana")
c.Assert(xFont.B, NotNil)
c.Assert(xFont.I, NotNil)
c.Assert(xFont.U, NotNil)
c.Assert(xFill.PatternFill.PatternType, Equals, "solid")
c.Assert(xFill.PatternFill.FgColor.RGB, Equals, "00FF0000")
c.Assert(xFill.PatternFill.BgColor.RGB, Equals, "FF000000")
c.Assert(xBorder.Left.Style, Equals, "thin")
c.Assert(xBorder.Right.Style, Equals, "thin")
c.Assert(xBorder.Top.Style, Equals, "thin")
c.Assert(xBorder.Bottom.Style, Equals, "thin")
c.Assert(xCellXf.ApplyBorder, Equals, true)
c.Assert(xCellXf.ApplyFill, Equals, true)
c.Assert(xCellXf.ApplyFont, Equals, true)
}
type FontSuite struct{}
var _ = Suite(&FontSuite{})
func (s *FontSuite) TestNewFont(c *C) {
font := NewFont(12, "Verdana")
c.Assert(font, NotNil)
c.Assert(font.Name, Equals, "Verdana")
c.Assert(font.Size, Equals, 12)
}