| Total Complexity | 4 |
| Complexity/F | 1 |
| Lines of Code | 40 |
| Function Count | 4 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |