@@ -233,9 +233,7 @@ class RichTextBlockTest {
233
233
broadcast(BroadcastRange .EVERYONE )
234
234
}
235
235
}
236
- }
237
236
238
- richText {
239
237
richTextList {
240
238
style(ListStyle .BULLET )
241
239
indent(1 )
@@ -244,9 +242,7 @@ class RichTextBlockTest {
244
242
color(" #C0FFEE" )
245
243
}
246
244
}
247
- }
248
245
249
- richText {
250
246
richTextList {
251
247
style(ListStyle .ORDERED )
252
248
indent(0 )
@@ -259,25 +255,23 @@ class RichTextBlockTest {
259
255
LimitedTextStyle .builder().bold(true ).italic(true ).clientHighlight(true ).build())
260
256
}
261
257
}
262
- }
263
258
264
- richText {
265
- richTextSection {
266
- date(1720710212 , " {date_num} at {time}" , fallback = " timey" )
259
+ richTextList {
260
+ style(ListStyle .BULLET )
261
+ offset(0 )
262
+ richTextSection {
263
+ date(1720710212 , " {date_num} at {time}" , fallback = " timey" )
264
+ }
267
265
}
268
- }
269
266
270
- richText {
271
267
richTextSection {
272
268
emoji(" basketball" )
273
269
text(" " )
274
270
emoji(" snowboarder" )
275
271
text(" " )
276
272
emoji(" checkered_flag" )
277
273
}
278
- }
279
274
280
- richText {
281
275
richTextQuote {
282
276
border(1 )
283
277
link(" https://api.slack.com" )
@@ -289,18 +283,19 @@ class RichTextBlockTest {
289
283
link(" https://api.slack.com" , " Slack API" ,
290
284
style = TextStyle .builder().strike(true ).code(true ).clientHighlight(true ).build())
291
285
}
292
- }
293
286
294
- richText {
295
287
richTextSection {
296
288
user(" U12345678" )
297
289
}
298
- }
299
290
300
- richText {
301
291
richTextSection {
302
292
usergroup(" S0123456789" )
303
293
}
294
+
295
+ richTextPreformatted {
296
+ border(1 )
297
+ text(" preformatted" )
298
+ }
304
299
}
305
300
}
306
301
val original = """
@@ -343,12 +338,7 @@ class RichTextBlockTest {
343
338
"style": "bullet",
344
339
"indent": 0,
345
340
"border": 0
346
- }
347
- ]
348
- },
349
- {
350
- "type": "rich_text",
351
- "elements": [
341
+ },
352
342
{
353
343
"type": "rich_text_list",
354
344
"elements": [
@@ -365,12 +355,7 @@ class RichTextBlockTest {
365
355
"style": "bullet",
366
356
"indent": 1,
367
357
"border": 0
368
- }
369
- ]
370
- },
371
- {
372
- "type": "rich_text",
373
- "elements": [
358
+ },
374
359
{
375
360
"type": "rich_text_list",
376
361
"elements": [
@@ -404,28 +389,25 @@ class RichTextBlockTest {
404
389
"style": "ordered",
405
390
"indent": 0,
406
391
"border": 1
407
- }
408
- ]
409
- },
410
- {
411
- "type": "rich_text",
412
- "elements": [
392
+ },
413
393
{
414
- "type": "rich_text_section ",
394
+ "type": "rich_text_list ",
415
395
"elements": [
416
396
{
417
- "type": "date",
418
- "timestamp": 1720710212,
419
- "format": "{date_num} at {time}",
420
- "fallback": "timey"
397
+ "type": "rich_text_section",
398
+ "elements": [
399
+ {
400
+ "type": "date",
401
+ "timestamp": 1720710212,
402
+ "format": "{date_num} at {time}",
403
+ "fallback": "timey"
404
+ }
405
+ ]
421
406
}
422
- ]
423
- }
424
- ]
425
- },
426
- {
427
- "type": "rich_text",
428
- "elements": [
407
+ ],
408
+ "style": "bullet",
409
+ "offset": 0
410
+ },
429
411
{
430
412
"type": "rich_text_section",
431
413
"elements": [
@@ -450,12 +432,7 @@ class RichTextBlockTest {
450
432
"name": "checkered_flag"
451
433
}
452
434
]
453
- }
454
- ]
455
- },
456
- {
457
- "type": "rich_text",
458
- "elements": [
435
+ },
459
436
{
460
437
"type": "rich_text_quote",
461
438
"elements": [
@@ -501,12 +478,7 @@ class RichTextBlockTest {
501
478
}
502
479
],
503
480
"border": 1
504
- }
505
- ]
506
- },
507
- {
508
- "type": "rich_text",
509
- "elements": [
481
+ },
510
482
{
511
483
"type": "rich_text_section",
512
484
"elements": [
@@ -515,12 +487,7 @@ class RichTextBlockTest {
515
487
"user_id": "U12345678"
516
488
}
517
489
]
518
- }
519
- ]
520
- },
521
- {
522
- "type": "rich_text",
523
- "elements": [
490
+ },
524
491
{
525
492
"type": "rich_text_section",
526
493
"elements": [
@@ -529,6 +496,16 @@ class RichTextBlockTest {
529
496
"usergroup_id": "S0123456789"
530
497
}
531
498
]
499
+ },
500
+ {
501
+ "type": "rich_text_preformatted",
502
+ "elements": [
503
+ {
504
+ "type": "text",
505
+ "text": "preformatted"
506
+ }
507
+ ],
508
+ "border": 1
532
509
}
533
510
]
534
511
}
@@ -541,4 +518,61 @@ class RichTextBlockTest {
541
518
assertEquals(expected, actual, " \n " + expected.toString() + " \n " + actual.toString())
542
519
}
543
520
521
+ @Test
522
+ fun dslWithElements () {
523
+ val blocksWithElements = withBlocks {
524
+ richText {
525
+ elements {
526
+ richTextSection {
527
+ elements {
528
+ text(" section" )
529
+ }
530
+ }
531
+ richTextList {
532
+ style(ListStyle .BULLET )
533
+ elements {
534
+ richTextSection {
535
+ elements {
536
+ text(" list" )
537
+ }
538
+ }
539
+ }
540
+ }
541
+ richTextPreformatted {
542
+ elements {
543
+ text(" preformatted" )
544
+ }
545
+ }
546
+ richTextQuote {
547
+ elements {
548
+ text(" quote" )
549
+ }
550
+ }
551
+ }
552
+ }
553
+ }
554
+ val original = withBlocks {
555
+ richText {
556
+ richTextSection {
557
+ text(" section" )
558
+ }
559
+ richTextList {
560
+ style(ListStyle .BULLET )
561
+ richTextSection {
562
+ text(" list" )
563
+ }
564
+ }
565
+ richTextPreformatted {
566
+ text(" preformatted" )
567
+ }
568
+ richTextQuote {
569
+ text(" quote" )
570
+ }
571
+ }
572
+ }
573
+ val expected = gson.toJsonTree(original)
574
+ val actual = gson.toJsonTree(blocksWithElements)
575
+ assertEquals(expected, actual, " \n " + expected.toString() + " \n " + actual.toString())
576
+ }
577
+
544
578
}
0 commit comments