Skip to content

Commit

Permalink
Adapt block tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alyosha authored and james-lawrence committed May 8, 2019
1 parent 4685e4c commit 798dc26
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion block_action_test.go
Expand Up @@ -14,6 +14,6 @@ func TestNewActionBlock(t *testing.T) {
actionBlock := NewActionBlock("test", approveBtn)
assert.Equal(t, string(actionBlock.Type), "actions")
assert.Equal(t, actionBlock.BlockID, "test")
assert.Equal(t, len(actionBlock.Elements), 1)
assert.Equal(t, len(actionBlock.Elements.ButtonElements), 1)

}
12 changes: 9 additions & 3 deletions block_context_test.go
Expand Up @@ -8,12 +8,18 @@ import (

func TestNewContextBlock(t *testing.T) {

locationPinImage := NewImageBlockObject("https://api.slack.com/img/blocks/bkb_template_images/tripAgentLocationMarker.png", "Location Pin Icon")
locationPinImage := NewImageBlockElement("https://api.slack.com/img/blocks/bkb_template_images/tripAgentLocationMarker.png", "Location Pin Icon")
textExample := NewTextBlockObject("plain_text", "Location: Central Business District", true, false)

actionBlock := NewContextBlock("test", locationPinImage, textExample)
contextElements := ContextElements{
ImageElements: []*ImageBlockElement{locationPinImage},
TextObjects: []*TextBlockObject{textExample},
}

actionBlock := NewContextBlock("test", contextElements)
assert.Equal(t, string(actionBlock.Type), "context")
assert.Equal(t, actionBlock.BlockID, "test")
assert.Equal(t, len(actionBlock.Elements), 2)
assert.Equal(t, len(actionBlock.Elements.ImageElements), 1)
assert.Equal(t, len(actionBlock.Elements.TextObjects), 1)

}
2 changes: 1 addition & 1 deletion block_element_test.go
Expand Up @@ -8,7 +8,7 @@ import (

func TestNewImageBlockElement(t *testing.T) {

imageElement := NewImageBlockObject("https://api.slack.com/img/blocks/bkb_template_images/tripAgentLocationMarker.png", "Location Pin Icon")
imageElement := NewImageBlockElement("https://api.slack.com/img/blocks/bkb_template_images/tripAgentLocationMarker.png", "Location Pin Icon")

assert.Equal(t, string(imageElement.Type), "image")
assert.Contains(t, imageElement.ImageURL, "tripAgentLocationMarker")
Expand Down
2 changes: 1 addition & 1 deletion block_object_test.go
Expand Up @@ -8,7 +8,7 @@ import (

func TestNewImageBlockObject(t *testing.T) {

imageObject := NewImageBlockObject("https://api.slack.com/img/blocks/bkb_template_images/beagle.png", "Beagle")
imageObject := NewImageBlockElement("https://api.slack.com/img/blocks/bkb_template_images/beagle.png", "Beagle")

assert.Equal(t, string(imageObject.Type), "image")
assert.Equal(t, imageObject.AltText, "Beagle")
Expand Down
2 changes: 1 addition & 1 deletion block_test.go
Expand Up @@ -11,6 +11,6 @@ func TestNewBlockMessage(t *testing.T) {
dividerBlock := NewDividerBlock()
blockMessage := NewBlockMessage(dividerBlock)

assert.Equal(t, len(blockMessage.Msg.Blocks), 1)
assert.Equal(t, len(blockMessage.Msg.Blocks.DividerBlocks), 1)

}

0 comments on commit 798dc26

Please sign in to comment.