Skip to content

Commit

Permalink
Add real tests
Browse files Browse the repository at this point in the history
Fixes #18
  • Loading branch information
strugee committed May 27, 2019
1 parent 1f94663 commit 41ac8ea
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
"grunt": "^1.0.1",
"grunt-cli": "^1.2.0",
"grunt-contrib-watch": "^1.0.0",
"grunt-mocha-test": "~0.7.0",
"grunt-mocha-test": "^0.13.3",
"grunt-release": "^0.14.0",
"hubot-test-helper": "^1.9.0",
"matchdep": "~0.1.2",
"mocha": "^1.21.5",
"sinon": "^1.17.7",
Expand Down
Binary file added test/.seen-test.coffee.swp
Binary file not shown.
30 changes: 20 additions & 10 deletions test/seen-test.coffee
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
# TODO test more, like the non-timeago functionality

Helper = require('hubot-test-helper')
chai = require 'chai'
sinon = require 'sinon'
chai.use require 'sinon-chai'

expect = chai.expect

helper = new Helper('../src/seen.coffee')

describe 'seen', ->
beforeEach ->
@robot =
respond: sinon.spy()
hear: sinon.spy()
@room = helper.createRoom()

require('../src/seen')(@robot)
afterEach ->
@room.destroy()

it 'registers a respond listener', ->
expect(@robot.respond).to.have.been.calledWith(/hello/)
it 'responds to \'seen alice\'', ->
@room.user.say('alice', '@hubot seen alice').then =>
expect(@room.messages).to.eql [
['alice', '@hubot seen alice']
['hubot', 'alice was last seen less than a minute ago, saying \'@hubot seen alice\' in room1']
]

it 'registers a hear listener', ->
expect(@robot.hear).to.have.been.calledWith(/orly/)
it 'responds to a question about someone who hasn\'t spoken', ->
@room.user.say('alice', '@hubot seen bob').then =>
expect(@room.messages).to.eql [
['alice', '@hubot seen bob']
['hubot', 'I haven\'t seen bob around lately']
]

0 comments on commit 41ac8ea

Please sign in to comment.