Skip to content

Commit

Permalink
Test fixes after blocks refactoring
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 69ae9f5 commit da5d491
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 23 deletions.
2 changes: 1 addition & 1 deletion block_action_test.go
Original file line number Diff line number Diff line change
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.ButtonElements), 1)
assert.Equal(t, len(actionBlock.Elements.BlockElementSet), 1)

}
12 changes: 5 additions & 7 deletions block_context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@ func TestNewContextBlock(t *testing.T) {
textExample := NewTextBlockObject("plain_text", "Location: Central Business District", true, false)

contextElements := ContextElements{
ImageElements: []*ImageBlockElement{locationPinImage},
TextObjects: []*TextBlockObject{textExample},
ContextElementSet: []MixedElement{locationPinImage, textExample},
}

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

}
2 changes: 1 addition & 1 deletion block_element.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func NewAccessory(element BlockElement) *Accessory {
// BlockElements is a convenience struct defined to allow dynamic unmarshalling of
// the "elements" value in Slack's JSON response, which varies depending on BlockElement type
type BlockElements struct {
BlockElementSet []BlockElement `json:"element"`
BlockElementSet []BlockElement `json:"elements"`
}

// ImageBlockElement An element to insert an image - this element can be used
Expand Down
2 changes: 1 addition & 1 deletion block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ func TestNewBlockMessage(t *testing.T) {
dividerBlock := NewDividerBlock()
blockMessage := NewBlockMessage(dividerBlock)

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

}
20 changes: 7 additions & 13 deletions examples/blocks/blocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,7 @@ func exampleThree() {
conflictSection := slack.NewContextBlock(
"",
slack.NewContextElements(
[]*slack.ImageBlockElement{conflictImage},
[]*slack.TextBlockObject{conflictText},
[]slack.MixedElement{conflictImage, conflictText},
),
)

Expand Down Expand Up @@ -225,8 +224,7 @@ func exampleFour() {
// Option One Votes
optOneVoteText := slack.NewTextBlockObject("plain_text", "3 votes", true, false)
contextElements := slack.NewContextElements(
[]*slack.ImageBlockElement{profileOne, profileTwo, profileThree},
[]*slack.TextBlockObject{optOneVoteText},
[]slack.MixedElement{profileOne, profileTwo, profileThree, optOneVoteText},
)
optOneContext := slack.NewContextBlock("", contextElements)

Expand All @@ -237,8 +235,7 @@ func exampleFour() {
// Option Two Votes
optTwoVoteText := slack.NewTextBlockObject("plain_text", "2 votes", true, false)
contextElements = slack.NewContextElements(
[]*slack.ImageBlockElement{profileFour, profileTwo},
[]*slack.TextBlockObject{optTwoVoteText},
[]slack.MixedElement{profileFour, profileTwo, optTwoVoteText},
)
optTwoContext := slack.NewContextBlock("", contextElements)

Expand All @@ -248,7 +245,7 @@ func exampleFour() {

// Option Three Votes
optThreeVoteText := slack.NewTextBlockObject("plain_text", "No votes", true, false)
contextElements = slack.NewContextElements(nil, []*slack.TextBlockObject{optThreeVoteText})
contextElements = slack.NewContextElements([]slack.MixedElement{optThreeVoteText})
optThreeContext := slack.NewContextBlock("", contextElements)

// Suggestions Action
Expand Down Expand Up @@ -314,8 +311,7 @@ func exampleFive() {
hotelOneLoc := slack.NewTextBlockObject("plain_text", "Location: Central Business District", true, false)

contextElements := slack.NewContextElements(
[]*slack.ImageBlockElement{locationPinImage},
[]*slack.TextBlockObject{hotelOneLoc},
[]slack.MixedElement{locationPinImage, hotelOneLoc},
)

hotelOneSection := slack.NewSectionBlock(hotelOneInfo, nil, slack.NewAccessory(hotelOneImage))
Expand All @@ -327,8 +323,7 @@ func exampleFive() {
hotelTwoLoc := slack.NewTextBlockObject("plain_text", "Location: French Quarter", true, false)

contextElements = slack.NewContextElements(
[]*slack.ImageBlockElement{locationPinImage},
[]*slack.TextBlockObject{hotelTwoLoc},
[]slack.MixedElement{locationPinImage, hotelTwoLoc},
)

hotelTwoSection := slack.NewSectionBlock(hotelTwoInfo, nil, slack.NewAccessory(hotelTwoImage))
Expand All @@ -340,8 +335,7 @@ func exampleFive() {
hotelThreeLoc := slack.NewTextBlockObject("plain_text", "Location: French Quarter", true, false)

contextElements = slack.NewContextElements(
[]*slack.ImageBlockElement{locationPinImage},
[]*slack.TextBlockObject{hotelThreeLoc},
[]slack.MixedElement{locationPinImage, hotelThreeLoc},
)
hotelThreeSection := slack.NewSectionBlock(hotelThreeInfo, nil, slack.NewAccessory(hotelThreeImage))
hotelThreeContext := slack.NewContextBlock("", contextElements)
Expand Down

0 comments on commit da5d491

Please sign in to comment.