Skip to content

Commit

Permalink
Add alt member variable to Image tag. The tag is already supported by…
Browse files Browse the repository at this point in the history
  • Loading branch information
ash-mank committed May 4, 2024
1 parent cf5ec70 commit 52f2006
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions fixtures/image.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"updated_at": "2017-07-24T19:09:43-00:00",
"width": 123,
"height": 456,
"alt": "new alt tag content",
"src": "https:\/\/cdn.shopify.com\/s\/files\/1\/0006\/9093\/3842\/products\/ipod-nano.png?v=1500937783",
"variant_ids": [
808950810,
Expand Down
2 changes: 2 additions & 0 deletions fixtures/images.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"updated_at": "2017-07-24T19:09:43-00:00",
"width": 123,
"height": 456,
"alt": "new alt tag content",
"src": "https:\/\/cdn.shopify.com\/s\/files\/1\/0006\/9093\/3842\/products\/ipod-nano.png?v=1500937783",
"variant_ids": [
808950810,
Expand All @@ -22,6 +23,7 @@
"updated_at": "2017-07-24T19:09:43-04:00",
"width": 123,
"height": 456,
"alt": "new alt tag content 2",
"src": "https:\/\/cdn.shopify.com\/s\/files\/1\/0006\/9093\/3842\/products\/ipod-nano-2.png?v=1500937783",
"variant_ids": [
]
Expand Down
1 change: 1 addition & 0 deletions image.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type Image struct {
Src string `json:"src,omitempty"`
Attachment string `json:"attachment,omitempty"`
Filename string `json:"filename,omitempty"`
Alt string `json:"alt,omitempty"`
VariantIds []uint64 `json:"variant_ids,omitempty"`
AdminGraphqlApiId string `json:"admin_graphql_api_id,omitempty"`
}
Expand Down
5 changes: 5 additions & 0 deletions image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ func imageTests(t *testing.T, image Image) {
t.Errorf("Image.VariantIds[0] returned %+v, expected %+v", image.VariantIds[1], expectedVariantIds[1])
}

expectedAlt := "new alt tag content"
if image.Alt != expectedAlt {
t.Errorf("Image.Alt returned %+v, expected %+v", image.Alt, expectedSrc)
}

// Check that CreatedAt date is set
expectedCreatedAt := time.Date(2017, time.July, 24, 19, 9, 43, 0, time.UTC)
if !expectedCreatedAt.Equal(*image.CreatedAt) {
Expand Down

0 comments on commit 52f2006

Please sign in to comment.