+27
test/messages.test.js
+27
test/messages.test.js
···
1
+
/* global suite, test */
2
+
// The module 'assert' provides assertion methods from node
3
+
const assert = require('assert')
4
+
const alex = require('alex')
5
+
const { getMessage, messages } = require('../messages')
6
+
7
+
// Defines a Mocha test suite to group tests of similar kind together
8
+
suite('Message text', function() {
9
+
// Defines a Mocha unit test
10
+
test('Test against Alex', function() {
11
+
const text = messages.join(' ')
12
+
const { messages: results } = alex(text)
13
+
assert(results.length === 0, results.reduce((a, m) => a + m + '\n', '\n\n'))
14
+
})
15
+
})
16
+
17
+
suite('getMessage', function() {
18
+
test('Returns with an emoji', function() {
19
+
const message = getMessage(true)
20
+
assert(message.startsWith('🎉'))
21
+
})
22
+
23
+
test('Returns without an emoji', function() {
24
+
const message = getMessage(false)
25
+
assert(!message.startsWith('🎉'))
26
+
})
27
+
})