Skip to content
This repository was archived by the owner on Dec 16, 2025. It is now read-only.

Commit 6d7e1d3

Browse files
Update image_test.go
1 parent 3d4299e commit 6d7e1d3

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

claat/nodes/image_test.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
package nodes
22

33
import (
4+
"encoding/base64"
45
"testing"
56

67
"github.com/google/go-cmp/cmp"
78
)
89

10+
var testBytes, _ = base64.StdEncoding.DecodeString("R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7")
11+
912
func TestNewImageNode(t *testing.T) {
1013
tests := []struct {
1114
name string
@@ -19,7 +22,7 @@ func TestNewImageNode(t *testing.T) {
1922
},
2023
},
2124
{
22-
name: "NonEmpty",
25+
name: "StandardURL",
2326
inOpts: NewImageNodeOptions{
2427
Src: "https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png",
2528
Width: 1.0,
@@ -34,6 +37,22 @@ func TestNewImageNode(t *testing.T) {
3437
Alt: "bar",
3538
},
3639
},
40+
{
41+
name: "DataURL",
42+
inOpts: NewImageNodeOptions{
43+
Width: 1.0,
44+
Title: "foo",
45+
Alt: "bar",
46+
Bytes: testBytes,
47+
},
48+
out: &ImageNode{
49+
node: node{typ: NodeImage},
50+
Width: 1.0,
51+
Title: "foo",
52+
Alt: "bar",
53+
Bytes: testBytes,
54+
},
55+
},
3756
}
3857
for _, tc := range tests {
3958
t.Run(tc.name, func(t *testing.T) {

0 commit comments

Comments
 (0)