Passed
Push — master ( 0597be...a2c147 )
by Muhammad Dyas
02:30
created

tests/config-form.test.js   A

Complexity

Total Complexity 4
Complexity/F 1

Size

Lines of Code 40
Function Count 4

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 27
mnd 0
bc 0
fnc 4
dl 0
loc 40
rs 10
bpm 0
cpm 1
noi 0
c 0
b 0
f 0
1
import {buildConfigurationForm, buildOptionsFromMessage} from '../src/config-form.js';
2
import {default as json} from './json/configuration_form.json';
3
4
test('build configuration form', () => {
5
  const dialog = buildConfigurationForm({
6
    topic: 'Who is the most handsome AI?',
7
    choices: [],
8
  });
9
  expect(dialog).toEqual(json);
10
});
11
12
test('build options  from message', () => {
13
  const message = '"How much your average sleep time?" "5 hours" "6 hours" "7 hours" "8 hours" "9 hours"';
14
  const options = buildOptionsFromMessage(message);
15
  const expected = {
16
    topic: 'How much your average sleep time?',
17
    choices: ['5 hours', '6 hours', '7 hours', '8 hours', '9 hours'],
18
  };
19
  expect(options).toEqual(expected);
20
});
21
22
23
test('build options from empty message', () => {
24
  const message = '';
25
  const options = buildOptionsFromMessage(message);
26
  const expected = {
27
    topic: '',
28
    choices: [],
29
  };
30
  expect(options).toStrictEqual(expected);
31
});
32
33
test('build options from undefined message', () => {
34
  const options = buildOptionsFromMessage(undefined);
35
  const expected = {
36
    topic: '',
37
    choices: [],
38
  };
39
  expect(options).toStrictEqual(expected);
40
});
41