Completed
Push — master ( d921eb...e48c5a )
by Mathias
01:34
created

test/Botlang.spec.js   A

Complexity

Total Complexity 7
Complexity/F 1

Size

Lines of Code 44
Function Count 7

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
nc 1
dl 0
loc 44
rs 10
noi 0
cc 0
wmc 7
mnd 0
bc 7
fnc 7
bpm 1
cpm 1

1 Function

Rating   Name   Duplication   Size   Complexity  
B Botlang.spec.js ➔ ??? 0 35 1
1
'use strict';
2
3
import * as fs from 'fs';
4
import * as path from 'path';
5
import { assert } from 'chai';
6
import Botlang from '../src/Botlang';
7
import pkg from '../package.json';
8
9
/** @test {Botlang} */
10
describe(`${pkg.name}/Botlang`, () => {
11
  /** @test {Botlang#constructor} */
12
  describe('#constructor', () => {
13
    it('Create a new instance of type Botlang', () => {
14
      const sourceCode = fs.readFileSync(path.join(__dirname, '..', 'example', 'hello_world.bot'), {
15
              encoding : 'utf8',
16
              flag     : 'r'
17
            }),
18
            botlang = new Botlang(sourceCode);
19
20
      assert.instanceOf(botlang, Botlang);
21
    });
22
  });
23
24
  /** @test {Botlang#reply} */
25
  describe('#reply', () => {
26
    const sourceCode = fs.readFileSync(path.join(__dirname, '..', 'example', 'hello_world.bot'), {
27
            encoding : 'utf8',
28
            flag     : 'r'
29
          }),
30
          botlang = new Botlang(sourceCode);
31
32
    it('Should return "Hi, how is it going?"', () => {
33
      assert.match(botlang.reply('Hey'), /Hi, how is it going?/);
34
    });
35
36
    it('Should return "Hi, how are you?" or "Hey, how are you?"', () => {
37
      assert.match(botlang.reply('Hello there'), /Hi, how are you?|Hey, how are you?/);
38
    });
39
40
    it('Should return "Sorry, I do not know the answer to that question."', () => {
41
      assert.match(botlang.reply('Yay ...'), /Sorry, I do not know the answer to that question./);
42
    });
43
  });
44
});
45