Skip to content

Commit

Permalink
Increase coverage of RichTextBlockTest
Browse files Browse the repository at this point in the history
  • Loading branch information
KENNYSOFT committed Sep 19, 2024
1 parent ab49bd2 commit c4fd8ae
Showing 1 changed file with 98 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,7 @@ class RichTextBlockTest {
broadcast(BroadcastRange.EVERYONE)
}
}
}

richText {
richTextList {
style(ListStyle.BULLET)
indent(1)
Expand All @@ -244,9 +242,7 @@ class RichTextBlockTest {
color("#C0FFEE")
}
}
}

richText {
richTextList {
style(ListStyle.ORDERED)
indent(0)
Expand All @@ -259,25 +255,23 @@ class RichTextBlockTest {
LimitedTextStyle.builder().bold(true).italic(true).clientHighlight(true).build())
}
}
}

richText {
richTextSection {
date(1720710212, "{date_num} at {time}", fallback = "timey")
richTextList {
style(ListStyle.BULLET)
offset(0)
richTextSection {
date(1720710212, "{date_num} at {time}", fallback = "timey")
}
}
}

richText {
richTextSection {
emoji("basketball")
text(" ")
emoji("snowboarder")
text(" ")
emoji("checkered_flag")
}
}

richText {
richTextQuote {
border(1)
link("https://api.slack.com")
Expand All @@ -289,18 +283,19 @@ class RichTextBlockTest {
link("https://api.slack.com", "Slack API",
style = TextStyle.builder().strike(true).code(true).clientHighlight(true).build())
}
}

richText {
richTextSection {
user("U12345678")
}
}

richText {
richTextSection {
usergroup("S0123456789")
}

richTextPreformatted {
border(1)
text("preformatted")
}
}
}
val original = """
Expand Down Expand Up @@ -343,12 +338,7 @@ class RichTextBlockTest {
"style": "bullet",
"indent": 0,
"border": 0
}
]
},
{
"type": "rich_text",
"elements": [
},
{
"type": "rich_text_list",
"elements": [
Expand All @@ -365,12 +355,7 @@ class RichTextBlockTest {
"style": "bullet",
"indent": 1,
"border": 0
}
]
},
{
"type": "rich_text",
"elements": [
},
{
"type": "rich_text_list",
"elements": [
Expand Down Expand Up @@ -404,28 +389,25 @@ class RichTextBlockTest {
"style": "ordered",
"indent": 0,
"border": 1
}
]
},
{
"type": "rich_text",
"elements": [
},
{
"type": "rich_text_section",
"type": "rich_text_list",
"elements": [
{
"type": "date",
"timestamp": 1720710212,
"format": "{date_num} at {time}",
"fallback": "timey"
"type": "rich_text_section",
"elements": [
{
"type": "date",
"timestamp": 1720710212,
"format": "{date_num} at {time}",
"fallback": "timey"
}
]
}
]
}
]
},
{
"type": "rich_text",
"elements": [
],
"style": "bullet",
"offset": 0
},
{
"type": "rich_text_section",
"elements": [
Expand All @@ -450,12 +432,7 @@ class RichTextBlockTest {
"name": "checkered_flag"
}
]
}
]
},
{
"type": "rich_text",
"elements": [
},
{
"type": "rich_text_quote",
"elements": [
Expand Down Expand Up @@ -501,12 +478,7 @@ class RichTextBlockTest {
}
],
"border": 1
}
]
},
{
"type": "rich_text",
"elements": [
},
{
"type": "rich_text_section",
"elements": [
Expand All @@ -515,12 +487,7 @@ class RichTextBlockTest {
"user_id": "U12345678"
}
]
}
]
},
{
"type": "rich_text",
"elements": [
},
{
"type": "rich_text_section",
"elements": [
Expand All @@ -529,6 +496,16 @@ class RichTextBlockTest {
"usergroup_id": "S0123456789"
}
]
},
{
"type": "rich_text_preformatted",
"elements": [
{
"type": "text",
"text": "preformatted"
}
],
"border": 1
}
]
}
Expand All @@ -541,4 +518,61 @@ class RichTextBlockTest {
assertEquals(expected, actual, "\n" + expected.toString() + "\n" + actual.toString())
}

@Test
fun dslWithElements() {
val blocksWithElements = withBlocks {
richText {
elements {
richTextSection {
elements {
text("section")
}
}
richTextList {
style(ListStyle.BULLET)
elements {
richTextSection {
elements {
text("list")
}
}
}
}
richTextPreformatted {
elements {
text("preformatted")
}
}
richTextQuote {
elements {
text("quote")
}
}
}
}
}
val original = withBlocks {
richText {
richTextSection {
text("section")
}
richTextList {
style(ListStyle.BULLET)
richTextSection {
text("list")
}
}
richTextPreformatted {
text("preformatted")
}
richTextQuote {
text("quote")
}
}
}
val expected = gson.toJsonTree(original)
val actual = gson.toJsonTree(blocksWithElements)
assertEquals(expected, actual, "\n" + expected.toString() + "\n" + actual.toString())
}

}

0 comments on commit c4fd8ae

Please sign in to comment.