1 | 'use strict'
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | const chai = require('chai')
|
8 | chai.use(require('sinon-chai'))
|
9 |
|
10 | const expect = chai.expect
|
11 |
|
12 |
|
13 | const User = require('../src/user')
|
14 | const Message = require('../src/message').Message
|
15 | const TextMessage = require('../src/message').TextMessage
|
16 |
|
17 | describe('Message', function () {
|
18 | beforeEach(function () {
|
19 | this.user = new User({
|
20 | id: 1,
|
21 | name: 'hubottester',
|
22 | room: '#mocha'
|
23 | })
|
24 | })
|
25 |
|
26 | describe('Unit Tests', function () {
|
27 | describe('#finish', () =>
|
28 | it('marks the message as done', function () {
|
29 | const testMessage = new Message(this.user)
|
30 | expect(testMessage.done).to.not.be.ok
|
31 | testMessage.finish()
|
32 | expect(testMessage.done).to.be.ok
|
33 | })
|
34 | )
|
35 |
|
36 | describe('TextMessage', () =>
|
37 | describe('#match', () =>
|
38 | it('should perform standard regex matching', function () {
|
39 | const testMessage = new TextMessage(this.user, 'message123')
|
40 | expect(testMessage.match(/^message123$/)).to.be.ok
|
41 | expect(testMessage.match(/^does-not-match$/)).to.not.be.ok
|
42 | })
|
43 | )
|
44 | )
|
45 | })
|
46 | })
|