Passed
Branch master (1b85f8)
by Pieter Epeüs
19:20 queued 15:41
created

tests/unit/error.spec.js   A

Complexity

Total Complexity 3
Complexity/F 1

Size

Lines of Code 29
Function Count 3

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 19
mnd 0
bc 0
fnc 3
dl 0
loc 29
rs 10
bpm 0
cpm 1
noi 2
c 0
b 0
f 0
1
import TruthTable from '../../src/TruthTable.mjs';
2
import InvalidInputError from '../../src/InvalidInputError';
3
4
const ErrorTestCases = [
5
    {
6
        description: 'test propositions with a null value',
7
        propositions: null,
8
        expectedError: 'propositions isnt a number',
9
    },
10
    {
11
        description: 'test propositions with a string',
12
        propositions: 'not ok',
13
        expectedError: 'propositions isnt a number',
14
    },
15
];
16
17
describe.each(ErrorTestCases)(
18
    'Test totalTrueInputs helper exception test',
19
    ({ description, propositions, expectedError }) => {
20
        it(description, () => {
21
            function testWrongInput() {
22
                TruthTable.create(propositions);
23
            }
24
25
            expect(testWrongInput).toThrowError(new Error(expectedError));
26
            expect(testWrongInput).toThrowError(InvalidInputError);
27
        });
28
    }
29
);
30