diff options
author | xuri <xuri.me@gmail.com> | 2019-05-24 09:48:14 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-24 09:48:14 +0800 |
commit | 623375780586cbd323dc899e17d7235ac610505f (patch) | |
tree | 25a44aa230fa674960dd5aa45b857b0a45e0c85b /styles_test.go | |
parent | f91f548614a7182ce66d55d10ed311e9b7e08a2a (diff) | |
parent | b1c9884f6d186bd1bfb4fc1d34061856345b8530 (diff) |
Merge pull request #391 from mlh758/390-change-default-font
Add the ability to change the default font
Diffstat (limited to 'styles_test.go')
-rw-r--r-- | styles_test.go | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/styles_test.go b/styles_test.go index 54321bb..decfbb9 100644 --- a/styles_test.go +++ b/styles_test.go @@ -25,7 +25,7 @@ func TestStyleFill(t *testing.T) { xl := NewFile() styleID, err := xl.NewStyle(testCase.format) if err != nil { - t.Fatalf("%v", err) + t.Fatal(err) } styles := xl.stylesReader() @@ -165,3 +165,31 @@ func TestSetConditionalFormat(t *testing.T) { assert.EqualValues(t, testCase.rules, cf[0].CfRule, testCase.label) } } + +func TestNewStyle(t *testing.T) { + f := NewFile() + styleID, err := f.NewStyle(`{"font":{"bold":true,"italic":true,"family":"Berlin Sans FB Demi","size":36,"color":"#777777"}}`) + if err != nil { + t.Fatal(err) + } + styles := f.stylesReader() + fontID := styles.CellXfs.Xf[styleID].FontID + font := styles.Fonts.Font[fontID] + assert.Contains(t, font.Name.Val, "Berlin Sans FB Demi", "Stored font should contain font name") + assert.Equal(t, 2, styles.CellXfs.Count, "Should have 2 styles") +} + +func TestGetDefaultFont(t *testing.T) { + f := NewFile() + s := f.GetDefaultFont() + assert.Equal(t, s, "Calibri", "Default font should be Calibri") +} + +func TestSetDefaultFont(t *testing.T) { + f := NewFile() + f.SetDefaultFont("Ariel") + styles := f.stylesReader() + s := f.GetDefaultFont() + assert.Equal(t, s, "Ariel", "Default font should change to Ariel") + assert.Equal(t, *styles.CellStyles.CellStyle[0].CustomBuiltIn, true) +} |