Debian Codegraph @

block_section_test.go

raw symbols SCIP
1 package slack
2
3 import (
4 "testing"
5
6 "github.com/stretchr/testify/assert"
7 )
8
9 func TestNewSectionBlock(t *testing.T) {
10
11 textInfo := NewTextBlockObject("mrkdwn", "*<fakeLink.toHotelPage.com|The Ritz-Carlton New Orleans>*\n★★★★★\n$340 per night\nRated: 9.1 - Excellent", false, false)
12
13 sectionBlock := NewSectionBlock(textInfo, nil, nil, SectionBlockOptionBlockID("test_block"))
14 assert.Equal(t, string(sectionBlock.Type), "section")
15 assert.Equal(t, sectionBlock.BlockID, "test_block")
16 assert.Equal(t, len(sectionBlock.Fields), 0)
17 assert.Nil(t, sectionBlock.Accessory)
18 assert.Equal(t, sectionBlock.Text.Type, "mrkdwn")
19 assert.Contains(t, sectionBlock.Text.Text, "New Orleans")
20
21 }
22
23 func TestNewBlockSectionContainsAddedTextBlockAndAccessory(t *testing.T) {
24 textBlockObject := NewTextBlockObject("mrkdwn", "You have a new test: *Hi there* :wave:", true, false)
25 conflictImage := NewImageBlockElement("https://api.slack.com/img/blocks/bkb_template_images/notificationsWarningIcon.png", "notifications warning icon")
26 sectionBlock := NewSectionBlock(textBlockObject, nil, NewAccessory(conflictImage))
27
28 assert.Equal(t, sectionBlock.BlockType(), MBTSection)
29 assert.Equal(t, len(sectionBlock.BlockID), 0)
30 textBlockInSection := sectionBlock.Text
31 assert.Equal(t, textBlockInSection.Text, textBlockObject.Text)
32 assert.Equal(t, textBlockInSection.Type, textBlockObject.Type)
33 assert.True(t, textBlockInSection.Emoji)
34 assert.False(t, textBlockInSection.Verbatim)
35 assert.Equal(t, sectionBlock.Accessory.ImageElement, conflictImage)
36 }