Skip to content

Commit 2d15fe4

Browse files
committed
Add test for JSON marshaling for Reaction and Reactions - relates to (google#55) (google#1324)
1 parent bbd1028 commit 2d15fe4

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

‎github/reactions_test.go‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,53 @@ import (
1212
"testing"
1313
)
1414

15+
func TestReaction_Marshal(t *testing.T) {
16+
testJSONMarshal(t, &Reaction{}, "{}")
17+
18+
r := &Reaction{
19+
ID: Int64(1),
20+
User: nil,
21+
NodeID: String("n"),
22+
Content: String("+1"),
23+
}
24+
25+
want := `{
26+
"id": 1,
27+
"node_id": "n",
28+
"content": "+1"
29+
}`
30+
31+
testJSONMarshal(t, r, want)
32+
}
33+
34+
func TestReactions_Marshal(t *testing.T) {
35+
testJSONMarshal(t, &Reactions{}, "{}")
36+
37+
r := &Reactions{
38+
TotalCount: Int(1),
39+
PlusOne: Int(1),
40+
MinusOne: Int(1),
41+
Laugh: Int(1),
42+
Confused: Int(1),
43+
Heart: Int(1),
44+
Hooray: Int(1),
45+
URL: String("u"),
46+
}
47+
48+
want := `{
49+
"total_count": 1,
50+
"+1": 1,
51+
"-1": 1,
52+
"laugh": 1,
53+
"confused": 1,
54+
"heart": 1,
55+
"hooray": 1,
56+
"url": "u"
57+
}`
58+
59+
testJSONMarshal(t, r, want)
60+
}
61+
1562
func TestReactionsService_ListCommentReactions(t *testing.T) {
1663
client, mux, _, teardown := setup()
1764
defer teardown()

0 commit comments

Comments
 (0)