diff options
author | xuri <xuri.me@gmail.com> | 2019-01-10 10:56:07 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-10 10:56:07 +0800 |
commit | b0ed4c12d2cced29d82e8a4af47f7b42f555ca8c (patch) | |
tree | 5a1b3ddba1f5ed5e88b7b80ef6a332cf001a8498 /styles_test.go | |
parent | 055d3fadf289f98a1f3cae3fe5177ccc5ea3509d (diff) | |
parent | 5dd00b9a004d5a7bc867ed09387cbd88fed240e4 (diff) |
Merge pull request #332 from mmitton/331_style_fill
Do not create a blank fill if no fill is specified in the style format
Diffstat (limited to 'styles_test.go')
-rw-r--r-- | styles_test.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/styles_test.go b/styles_test.go index baa66f0..c6fbbef 100644 --- a/styles_test.go +++ b/styles_test.go @@ -6,6 +6,40 @@ import ( "github.com/stretchr/testify/assert" ) +func TestStyleFill(t *testing.T) { + cases := []struct { + label string + format string + expectFill bool + }{{ + label: "no_fill", + format: `{"alignment":{"wrap_text":true}}`, + expectFill: false, + }, { + label: "fill", + format: `{"fill":{"type":"pattern","pattern":1,"color":["#000000"]}}`, + expectFill: true, + }} + + for _, testCase := range cases { + xl := NewFile() + const sheet = "Sheet1" + + styleID, err := xl.NewStyle(testCase.format) + if err != nil { + t.Fatalf("%v", err) + } + + styles := xl.stylesReader() + style := styles.CellXfs.Xf[styleID] + if testCase.expectFill { + assert.NotEqual(t, style.FillID, 0, testCase.label) + } else { + assert.Equal(t, style.FillID, 0, testCase.label) + } + } +} + func TestSetConditionalFormat(t *testing.T) { cases := []struct { label string |