Skip to content

Commit 26792ea

Browse files
ericz15jomei
authored andcommitted
Test: add tests for block color property
1 parent 2a903bc commit 26792ea

File tree

5 files changed

+24
-13
lines changed

5 files changed

+24
-13
lines changed

block_test.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,13 @@ func TestBlockClient(t *testing.T) {
8080
Heading2: struct {
8181
RichText []notionapi.RichText `json:"rich_text"`
8282
Children notionapi.Blocks `json:"children,omitempty"`
83+
Color string `json:"color,omitempty"`
8384
}{[]notionapi.RichText{
8485
{
8586
Type: notionapi.ObjectTypeText,
8687
Text: notionapi.Text{Content: "Hello"},
8788
},
88-
}, nil,
89+
}, nil, "",
8990
},
9091
},
9192
},
@@ -121,6 +122,7 @@ func TestBlockClient(t *testing.T) {
121122
PlainText: "AAAAAA",
122123
},
123124
},
125+
Color: "blue",
124126
},
125127
},
126128
},
@@ -238,6 +240,7 @@ func TestBlockClient(t *testing.T) {
238240
Text: notionapi.Text{Content: "Hello"},
239241
},
240242
},
243+
Color: notionapi.ColorYellow.String(),
241244
},
242245
},
243246
want: &notionapi.ParagraphBlock{
@@ -259,6 +262,7 @@ func TestBlockClient(t *testing.T) {
259262
PlainText: "Hello",
260263
},
261264
},
265+
Color: notionapi.ColorYellow.String(),
262266
},
263267
},
264268
wantErr: false,
@@ -344,6 +348,7 @@ func TestBlockArrayUnmarshal(t *testing.T) {
344348
Type: "emoji",
345349
Emoji: &emoji,
346350
},
351+
Color: notionapi.ColorBlue.String(),
347352
},
348353
},
349354
&notionapi.Heading1Block{
@@ -369,6 +374,7 @@ func TestBlockArrayUnmarshal(t *testing.T) {
369374
PlainText: "History 340",
370375
},
371376
},
377+
Color: notionapi.ColorBrownBackground.String(),
372378
},
373379
},
374380
&notionapi.ChildDatabaseBlock{
@@ -423,6 +429,7 @@ func TestBlockArrayUnmarshal(t *testing.T) {
423429
PlainText: "Assignment Submission",
424430
},
425431
},
432+
Color: notionapi.ColorDefault.String(),
426433
},
427434
},
428435
&notionapi.ParagraphBlock{
@@ -448,6 +455,7 @@ func TestBlockArrayUnmarshal(t *testing.T) {
448455
PlainText: "All essays and papers are due in lecture (due dates are listed on the schedule). No electronic copies will be accepted!",
449456
},
450457
},
458+
Color: notionapi.ColorRed.String(),
451459
},
452460
},
453461
},

page_test.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -457,10 +457,7 @@ func TestPageCreateRequest_MarshallJSON(t *testing.T) {
457457
Object: notionapi.ObjectTypeBlock,
458458
Type: notionapi.BlockTypeHeading2,
459459
},
460-
Heading2: struct {
461-
RichText []notionapi.RichText `json:"rich_text"`
462-
Children notionapi.Blocks `json:"children,omitempty"`
463-
}{
460+
Heading2: notionapi.Heading{
464461
RichText: []notionapi.RichText{
465462
{
466463
Type: notionapi.ObjectTypeText,

testdata/block_append_children.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,11 @@
3636
"plain_text": "AAAAAA",
3737
"href": null
3838
}
39-
]
39+
],
40+
"color": "blue"
4041
}
4142
}
4243
],
4344
"next_cursor": null,
4445
"has_more": false
45-
}
46+
}

testdata/block_array_unmarshal.json

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@
4545
"icon": {
4646
"type": "emoji",
4747
"emoji": "📌"
48-
}
48+
},
49+
"color": "blue"
4950
}
5051
}, {
5152
"object": "block",
@@ -76,7 +77,8 @@
7677
"color": "default"
7778
},
7879
"plain_text": "History 340"
79-
}]
80+
}],
81+
"color":"brown_background"
8082
}
8183
}, {
8284
"object": "block",
@@ -140,7 +142,8 @@
140142
"color": "default"
141143
},
142144
"plain_text": "Assignment Submission"
143-
}]
145+
}],
146+
"color":"default"
144147
}
145148
}, {
146149
"object": "block",
@@ -171,6 +174,7 @@
171174
"color": "default"
172175
},
173176
"plain_text": "All essays and papers are due in lecture (due dates are listed on the schedule). No electronic copies will be accepted!"
174-
}]
177+
}],
178+
"color":"red"
175179
}
176-
}]
180+
}]

testdata/block_update.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"plain_text": "Hello",
2626
"href": null
2727
}
28-
]
28+
],
29+
"color": "yellow"
2930
}
3031
}

0 commit comments

Comments
 (0)