-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathreply-spec.js
51 lines (43 loc) · 1.45 KB
/
reply-spec.js
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/* global describe, it, expect */
'use strict'
const underTest = require('../lib/reply')
describe('Reply', () => {
it('should be a function', () => {
expect(typeof underTest).toBe('function')
})
it('should not return anything if message is not a string or an object', () => {
expect(underTest()).not.toBeDefined()
expect(underTest(123)).not.toBeDefined()
expect(underTest(1.2)).not.toBeDefined()
expect(underTest([])).not.toBeDefined()
expect(underTest([1, 2])).not.toBeDefined()
})
it('should return an object if message is a string', () => {
expect(underTest('hello')).toEqual({
version: '1.0',
response: {
shouldEndSession: true,
outputSpeech: {
type: 'PlainText',
text: 'hello'
}
}
})
})
it('should not return anything if message is an empty string', () => {
expect(underTest('')).not.toBeDefined()
})
it('should not return anything if message contains just spaces and tabs', () => {
expect(underTest(' ')).not.toBeDefined()
expect(underTest(' ')).not.toBeDefined()
expect(underTest('\t')).not.toBeDefined()
expect(underTest('\n')).not.toBeDefined()
expect(underTest(' \t\n')).not.toBeDefined()
})
it('should return the object if message is an object and not null', () => {
expect(underTest({})).toEqual({})
})
it('should not return anything if message is null', () => {
expect(underTest(null)).not.toBeDefined()
})
})