UNPKG

1.21 kBJavaScriptView Raw
1'use strict'
2
3/* global describe, beforeEach, it */
4/* eslint-disable no-unused-expressions */
5
6// Assertions and Stubbing
7const chai = require('chai')
8chai.use(require('sinon-chai'))
9
10const expect = chai.expect
11
12// Hubot classes
13const User = require('../src/user')
14const Message = require('../src/message').Message
15const TextMessage = require('../src/message').TextMessage
16
17describe('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})