Skip to content

Commit

Permalink
update tests for new enter and leave events
Browse files Browse the repository at this point in the history
  • Loading branch information
aoberoi committed Jul 17, 2018
1 parent 8bba532 commit 7cf2eb2
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions test/bot.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ describe 'Disable Sync', ->
@slackbot.options.disableUserSync = true
@slackbot.run()
@slackbot.robot.brain.data.users.should.be.empty()

# Test moved to fetchUsers() in client.coffee because of change in code logic
#it 'Should still sync interacting users when disabled'

describe 'Send Messages', ->

it 'Should send a message', ->
Expand Down Expand Up @@ -207,13 +207,13 @@ describe 'Handling incoming messages', ->
@slackbot.eventHandler messageData
return

it 'Should handle channel_join events as envisioned', ->
@slackbot.eventHandler {type: 'message', subtype: 'channel_join', user: @stubs.user, channel: @stubs.channel.id}
it 'Should handle member_joined_channel events as envisioned', ->
@slackbot.eventHandler {type: 'member_joined_channel', user: @stubs.user, channel: @stubs.channel.id}
should.equal (@stubs._received instanceof EnterMessage), true
@stubs._received.user.id.should.equal @stubs.user.id

it 'Should handle channel_leave events as envisioned', ->
@slackbot.eventHandler {type: 'message', subtype: 'channel_leave', user: @stubs.user, channel: @stubs.channel.id}
it 'Should handle member_left_channel events as envisioned', ->
@slackbot.eventHandler {type: 'member_left_channel', user: @stubs.user, channel: @stubs.channel.id}
should.equal (@stubs._received instanceof LeaveMessage), true
@stubs._received.user.id.should.equal @stubs.user.id

Expand All @@ -222,16 +222,6 @@ describe 'Handling incoming messages', ->
should.equal (@stubs._received instanceof TopicMessage), true
@stubs._received.user.id.should.equal @stubs.user.id

it 'Should handle group_join events as envisioned', ->
@slackbot.eventHandler {type: 'message', subtype: 'group_join', user: @stubs.user, channel: @stubs.channel.id}
should.equal (@stubs._received instanceof EnterMessage), true
@stubs._received.user.id.should.equal @stubs.user.id

it 'Should handle group_leave events as envisioned', ->
@slackbot.eventHandler {type: 'message', subtype: 'group_leave', user: @stubs.user, channel: @stubs.channel.id}
should.equal (@stubs._received instanceof LeaveMessage), true
@stubs._received.user.id.should.equal @stubs.user.id

it 'Should handle group_topic events as envisioned', ->
@slackbot.eventHandler {type: 'message', subtype: 'group_topic', user: @stubs.user, channel: @stubs.channel.id}
should.equal (@stubs._received instanceof TopicMessage), true
Expand Down

0 comments on commit 7cf2eb2

Please sign in to comment.