forked from tealeg/xlsx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
style_test.go
71 lines (60 loc) · 1.98 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
67
68
69
70
71
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) TestNewStyleDefaults(c *C) {
style := NewStyle()
c.Assert(style.Font, Equals, *DefaulFont())
c.Assert(style.Fill, Equals, *DefaulFill())
c.Assert(style.Border, Equals, *DefaulBorder())
}
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, xCellStyleXf, xCellXf := style.makeXLSXStyleElements()
// c.Assert(xNumFmt.NumFmtId, Equals, 164)
// c.Assert(xNumFmt.FormatCode, Equals, "GENERAL")
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(xCellStyleXf.ApplyBorder, Equals, true)
c.Assert(xCellStyleXf.ApplyFill, Equals, true)
c.Assert(xCellStyleXf.ApplyFont, Equals, true)
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)
}