summaryrefslogtreecommitdiff
path: root/picture_test.go
diff options
context:
space:
mode:
authorxuri <xuri.me@gmail.com>2020-01-22 01:08:18 +0800
committerxuri <xuri.me@gmail.com>2020-01-22 01:08:18 +0800
commitcbc3fd21b79fbb819c1c341fc825701c04a0b473 (patch)
treee92c0c9e2d84bb59911a131d75b61a77cb0e6f83 /picture_test.go
parente2bd08c9111b0141c66adf232edb2fd729afa63f (diff)
Resolve #455, init delete picture from spreadsheet support
Diffstat (limited to 'picture_test.go')
-rw-r--r--picture_test.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/picture_test.go b/picture_test.go
index ca38f41..fdc6f0d 100644
--- a/picture_test.go
+++ b/picture_test.go
@@ -166,3 +166,18 @@ func TestAddPictureFromBytes(t *testing.T) {
assert.Equal(t, 1, imageCount, "Duplicate image should only be stored once.")
assert.EqualError(t, f.AddPictureFromBytes("SheetN", fmt.Sprint("A", 1), "", "logo", ".png", imgFile), "sheet SheetN is not exist")
}
+
+func TestDeletePicture(t *testing.T) {
+ f, err := OpenFile(filepath.Join("test", "Book1.xlsx"))
+ assert.NoError(t, err)
+ assert.NoError(t, f.DeletePicture("Sheet1", "A1"))
+ assert.NoError(t, f.AddPicture("Sheet1", "P1", filepath.Join("test", "images", "excel.jpg"), ""))
+ assert.NoError(t, f.DeletePicture("Sheet1", "P1"))
+ assert.NoError(t, f.SaveAs(filepath.Join("test", "TestDeletePicture.xlsx")))
+ // Test delete picture on not exists worksheet.
+ assert.EqualError(t, f.DeletePicture("SheetN", "A1"), "sheet SheetN is not exist")
+ // Test delete picture with invalid coordinates.
+ assert.EqualError(t, f.DeletePicture("Sheet1", ""), `cannot convert cell "" to coordinates: invalid cell name ""`)
+ // Test delete picture on no chart worksheet.
+ assert.NoError(t, NewFile().DeletePicture("Sheet1", "A1"))
+}