forked from hubotio/hubot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmessage_test.coffee
32 lines (27 loc) · 943 Bytes
/
message_test.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# Assertions and Stubbing
chai = require 'chai'
sinon = require 'sinon'
chai.use require 'sinon-chai'
{ expect } = chai
# Hubot classes
User = require '../src/user.coffee'
{ CatchAllMessage, EnterMessage, Message, TextMessage } = require '../src/message'
describe 'Message', ->
beforeEach ->
@user = new User
id: 1
name: 'hubottester'
room: '#mocha'
describe 'Unit Tests', ->
describe '#finish', ->
it 'marks the message as done', ->
testMessage = new Message(@user)
expect(testMessage.done).to.not.be.ok
testMessage.finish()
expect(testMessage.done).to.be.ok
describe 'TextMessage', ->
describe '#match', ->
it 'should perform standard regex matching', ->
testMessage = new TextMessage(@user, 'message123')
expect( testMessage.match(/^message123$/) ).to.be.ok
expect( testMessage.match(/^does-not-match$/) ).to.not.be.ok