Skip to content

Commit

Permalink
Test: add tests for block color property
Browse files Browse the repository at this point in the history
  • Loading branch information
ericz15 authored and jomei committed Aug 8, 2022
1 parent 2a903bc commit 26792ea
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 13 deletions.
10 changes: 9 additions & 1 deletion block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,13 @@ func TestBlockClient(t *testing.T) {
Heading2: struct {
RichText []notionapi.RichText `json:"rich_text"`
Children notionapi.Blocks `json:"children,omitempty"`
Color string `json:"color,omitempty"`
}{[]notionapi.RichText{
{
Type: notionapi.ObjectTypeText,
Text: notionapi.Text{Content: "Hello"},
},
}, nil,
}, nil, "",
},
},
},
Expand Down Expand Up @@ -121,6 +122,7 @@ func TestBlockClient(t *testing.T) {
PlainText: "AAAAAA",
},
},
Color: "blue",
},
},
},
Expand Down Expand Up @@ -238,6 +240,7 @@ func TestBlockClient(t *testing.T) {
Text: notionapi.Text{Content: "Hello"},
},
},
Color: notionapi.ColorYellow.String(),
},
},
want: &notionapi.ParagraphBlock{
Expand All @@ -259,6 +262,7 @@ func TestBlockClient(t *testing.T) {
PlainText: "Hello",
},
},
Color: notionapi.ColorYellow.String(),
},
},
wantErr: false,
Expand Down Expand Up @@ -344,6 +348,7 @@ func TestBlockArrayUnmarshal(t *testing.T) {
Type: "emoji",
Emoji: &emoji,
},
Color: notionapi.ColorBlue.String(),
},
},
&notionapi.Heading1Block{
Expand All @@ -369,6 +374,7 @@ func TestBlockArrayUnmarshal(t *testing.T) {
PlainText: "History 340",
},
},
Color: notionapi.ColorBrownBackground.String(),
},
},
&notionapi.ChildDatabaseBlock{
Expand Down Expand Up @@ -423,6 +429,7 @@ func TestBlockArrayUnmarshal(t *testing.T) {
PlainText: "Assignment Submission",
},
},
Color: notionapi.ColorDefault.String(),
},
},
&notionapi.ParagraphBlock{
Expand All @@ -448,6 +455,7 @@ func TestBlockArrayUnmarshal(t *testing.T) {
PlainText: "All essays and papers are due in lecture (due dates are listed on the schedule). No electronic copies will be accepted!",
},
},
Color: notionapi.ColorRed.String(),
},
},
},
Expand Down
5 changes: 1 addition & 4 deletions page_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -457,10 +457,7 @@ func TestPageCreateRequest_MarshallJSON(t *testing.T) {
Object: notionapi.ObjectTypeBlock,
Type: notionapi.BlockTypeHeading2,
},
Heading2: struct {
RichText []notionapi.RichText `json:"rich_text"`
Children notionapi.Blocks `json:"children,omitempty"`
}{
Heading2: notionapi.Heading{
RichText: []notionapi.RichText{
{
Type: notionapi.ObjectTypeText,
Expand Down
5 changes: 3 additions & 2 deletions testdata/block_append_children.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@
"plain_text": "AAAAAA",
"href": null
}
]
],
"color": "blue"
}
}
],
"next_cursor": null,
"has_more": false
}
}
14 changes: 9 additions & 5 deletions testdata/block_array_unmarshal.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
"icon": {
"type": "emoji",
"emoji": "📌"
}
},
"color": "blue"
}
}, {
"object": "block",
Expand Down Expand Up @@ -76,7 +77,8 @@
"color": "default"
},
"plain_text": "History 340"
}]
}],
"color":"brown_background"
}
}, {
"object": "block",
Expand Down Expand Up @@ -140,7 +142,8 @@
"color": "default"
},
"plain_text": "Assignment Submission"
}]
}],
"color":"default"
}
}, {
"object": "block",
Expand Down Expand Up @@ -171,6 +174,7 @@
"color": "default"
},
"plain_text": "All essays and papers are due in lecture (due dates are listed on the schedule). No electronic copies will be accepted!"
}]
}],
"color":"red"
}
}]
}]
3 changes: 2 additions & 1 deletion testdata/block_update.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"plain_text": "Hello",
"href": null
}
]
],
"color": "yellow"
}
}

0 comments on commit 26792ea

Please sign in to comment.