Skip to content

Commit

Permalink
added some coveralls tests and ignores
Browse files Browse the repository at this point in the history
  • Loading branch information
John Agan committed Jun 17, 2016
1 parent c244c3d commit cd61c60
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 5 deletions.
1 change: 1 addition & 0 deletions Gruntfile.coffee
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
### istanbul ignore next ###
module.exports = (grunt) ->
grunt.loadNpmTasks 'grunt-release'
grunt.loadNpmTasks 'grunt-contrib-watch'
Expand Down
2 changes: 1 addition & 1 deletion src/slack.coffee
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{Robot, Adapter, EnterMessage, LeaveMessage, TopicMessage} = require 'hubot'
{SlackTextMessage, SlackRawMessage, SlackBotMessage} = require './message'
{SlackRawListener, SlackBotListener} = require './listener'
# {SlackRawListener, SlackBotListener} = require './listener'
{RtmClient, MemoryDataStore} = require '@slack/client'

class SlackBot extends Adapter
Expand Down
29 changes: 29 additions & 0 deletions test/listener.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{SlackRawMessage, SlackBotMessage, SlackTextMessage} = require '../src/message'
{SlackBotListener, SlackRawListener} = require '../src/listener'
should = require 'should'


describe 'Listeners', ->

it 'Should fail on incorrect message type', ->
callback = (response) ->
matcher = (message) -> message.text.match /Hello/

listener = new SlackRawListener(@stubs.robot, matcher, callback)
listener.call().should.be.false


it 'Should call a SlackRawListener', ->
callback = (response) ->
matcher = (message) -> message.text.match /Hello/

message = new SlackRawMessage(@stubs.user.id, 'Hello world', 'Hello world', {ts: 1234})
listener = new SlackRawListener(@stubs.robot, matcher, callback)
listener.call(message).should.be.true


it 'Should call a SlackBotListener', ->
callback = (response) ->
message = new SlackBotMessage(@stubs.user.id, 'Hello world', 'Hello world', {ts: 1234})
listener = new SlackBotListener(@stubs.robot, /Hello/, callback)
listener.call(message).should.be.true
1 change: 1 addition & 0 deletions test/slack.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

should = require 'should'


describe 'Adapter', ->
it 'Should initialize with a robot', ->
@slackbot.robot.should.eql @stubs.robot
Expand Down
5 changes: 1 addition & 4 deletions test/stubs.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,11 @@ beforeEach ->
@stubs.client.dataStore.dms.push
name: user.name
id: 'D1234'
sendMessage: (msg) =>
@stubs._msg = if @stubs._msg then @stubs._msg + msg else msg
callback?()
users: [@stubs.user, @stubs.self]
dms: [
name: 'user2'
id: 'D5432'
sendMessage: (msg) =>
@stubs._dmmsg = if @stubs._dmmsg then @stubs._dmmsg + msg else msg
]
# Hubot.Robot instance
@stubs.robot = do ->
Expand All @@ -77,6 +73,7 @@ beforeEach ->
@received.push msg
# attach a real Brain to the robot
robot.brain = new Brain robot
robot.Response = (robot, message, match) ->
robot

# Generate a new slack instance for each test.
Expand Down

0 comments on commit cd61c60

Please sign in to comment.