diff options
author | xuri <xuri.me@gmail.com> | 2020-03-10 00:04:23 +0800 |
---|---|---|
committer | xuri <xuri.me@gmail.com> | 2020-03-10 00:04:23 +0800 |
commit | 9e2318cefa4ebaa7bf6b1dbc95b30ad7a32366b1 (patch) | |
tree | 5662b564bb64068e0f60f1ade1dd5679f9df3974 /styles_test.go | |
parent | 2ccb8f62edd5d1ce039e663591964b9066fd2f4e (diff) |
Resolve #470, export Style structs to allow create the style for cells by given JSON or structure
Diffstat (limited to 'styles_test.go')
-rw-r--r-- | styles_test.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/styles_test.go b/styles_test.go index 4e9b411..5a9a771 100644 --- a/styles_test.go +++ b/styles_test.go @@ -191,6 +191,8 @@ func TestNewStyle(t *testing.T) { font := styles.Fonts.Font[fontID] assert.Contains(t, *font.Name.Val, "Times New Roman", "Stored font should contain font name") assert.Equal(t, 2, styles.CellXfs.Count, "Should have 2 styles") + _, err = f.NewStyle(&Style{}) + assert.NoError(t, err) } func TestGetDefaultFont(t *testing.T) { @@ -207,3 +209,24 @@ func TestSetDefaultFont(t *testing.T) { assert.Equal(t, s, "Ariel", "Default font should change to Ariel") assert.Equal(t, *styles.CellStyles.CellStyle[0].CustomBuiltIn, true) } + +func TestStylesReader(t *testing.T) { + f := NewFile() + // Test read styles with unsupport charset. + f.Styles = nil + f.XLSX["xl/styles.xml"] = MacintoshCyrillicCharset + assert.EqualValues(t, new(xlsxStyleSheet), f.stylesReader()) +} + +func TestThemeReader(t *testing.T) { + f := NewFile() + // Test read theme with unsupport charset. + f.XLSX["xl/theme/theme1.xml"] = MacintoshCyrillicCharset + assert.EqualValues(t, new(xlsxTheme), f.themeReader()) +} + +func TestSetCellStyle(t *testing.T) { + f := NewFile() + // Test set cell style on not exists worksheet. + assert.EqualError(t, f.SetCellStyle("SheetN", "A1", "A2", 1), "sheet SheetN is not exist") +} |