Skip to content

Commit

Permalink
Add test cases for rich text emoji elements without skin_tone
Browse files Browse the repository at this point in the history
  • Loading branch information
calebmckay committed Oct 31, 2024
1 parent 7c493d7 commit f66f1e8
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion block_rich_text_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,16 @@ func TestRichTextSection_UnmarshalJSON(t *testing.T) {
},
nil,
},
{
[]byte(`{"type": "rich_text_section","elements":[{"type": "emoji","name": "+1"}]}`),
RichTextSection{
Type: RTESection,
Elements: []RichTextSectionElement{
&RichTextSectionEmojiElement{Type: RTSEEmoji, Name: "+1"},
},
},
nil,
},
{
[]byte(`{"type": "rich_text_section","elements":[{"type": "emoji","name": "+1","unicode": "1f44d-1f3fb","skin_tone": 2}]}`),
RichTextSection{
Expand Down Expand Up @@ -299,7 +309,7 @@ func TestRichTextList_UnmarshalJSON(t *testing.T) {

func TestRichTextQuote_Marshal(t *testing.T) {
t.Run("rich_text_section", func(t *testing.T) {
const rawRSE = "{\"type\":\"rich_text_section\",\"elements\":[{\"type\":\"text\",\"text\":\"Some Text\"}]}"
const rawRSE = "{\"type\":\"rich_text_section\",\"elements\":[{\"type\":\"text\",\"text\":\"Some Text\"},{\"type\":\"emoji\",\"name\":\"+1\"},{\"type\":\"emoji\",\"name\":\"+1\",\"skin_tone\":2}]}"

var got RichTextSection
if err := json.Unmarshal([]byte(rawRSE), &got); err != nil {
Expand All @@ -309,6 +319,8 @@ func TestRichTextQuote_Marshal(t *testing.T) {
Type: RTESection,
Elements: []RichTextSectionElement{
&RichTextSectionTextElement{Type: RTSEText, Text: "Some Text"},
&RichTextSectionEmojiElement{Type: RTSEEmoji, Name: "+1"},
&RichTextSectionEmojiElement{Type: RTSEEmoji, Name: "+1", SkinTone: 2},
},
}

Expand Down

0 comments on commit f66f1e8

Please sign in to comment.