Total Complexity | 3 |
Complexity/F | 1 |
Lines of Code | 49 |
Function Count | 3 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import Gate from '../../src/LogicGates.mjs'; |
||
2 | import InvalidInputError from '../../src/InvalidInputError'; |
||
3 | |||
4 | const ErrorTestCases = [ |
||
5 | { |
||
6 | description: 'test inputs with a null value', |
||
7 | inputs: null, |
||
8 | expectedError: 'inputs isnt a array of booleans', |
||
9 | }, |
||
10 | { |
||
11 | description: 'test inputs with a string', |
||
12 | inputs: 'not ok', |
||
13 | expectedError: 'inputs isnt a array of booleans', |
||
14 | }, |
||
15 | { |
||
16 | description: 'test inputs with a string', |
||
17 | inputs: [true, 42], |
||
18 | expectedError: 'inputs isnt a array of booleans', |
||
19 | }, |
||
20 | { |
||
21 | description: 'test inputs with a string', |
||
22 | inputs: [1], |
||
23 | expectedError: 'inputs isnt a array of booleans', |
||
24 | }, |
||
25 | { |
||
26 | description: 'test inputs with a string', |
||
27 | inputs: [0], |
||
28 | expectedError: 'inputs isnt a array of booleans', |
||
29 | }, |
||
30 | { |
||
31 | description: 'test inputs with a string', |
||
32 | inputs: [null], |
||
33 | expectedError: 'inputs isnt a array of booleans', |
||
34 | }, |
||
35 | ]; |
||
36 | |||
37 | describe.each(ErrorTestCases)( |
||
38 | 'Test totalTrueInputs helper exception test', |
||
39 | ({ description, inputs, expectedError }) => { |
||
40 | it(description, () => { |
||
41 | function testWrongInput() { |
||
42 | Gate.create(inputs); |
||
43 | } |
||
44 | |||
45 | expect(testWrongInput).toThrowError(new Error(expectedError)); |
||
46 | expect(testWrongInput).toThrowError(InvalidInputError); |
||
47 | }); |
||
48 | } |
||
49 | ); |
||
50 |