tests/rules/boolean.test.js   A
last analyzed

Complexity

Total Complexity 5
Complexity/F 1

Size

Lines of Code 31
Function Count 5

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 19
mnd 0
bc 0
fnc 5
dl 0
loc 31
bpm 0
cpm 1
noi 0
c 0
b 0
f 0
rs 10
1
import { RuleTester } from '../utils';
2
3
const tester = new RuleTester('boolean');
4
5
suite('Rules: boolean');
6
7
test('Positive: boolean', function () {
8
    tester.positive(true, true);
9
    tester.positive(false, false);
10
});
11
12
test('Positive: string', function () {
13
    tester.positive('true', true);
14
    tester.positive('false', false);
15
});
16
17
test('Positive: number', function () {
18
    tester.positive(1, true);
19
    tester.positive(0, false);
20
});
21
22
test('Positive: empty value', function () {
23
    tester.positive(null, null);
24
    tester.positive(undefined, undefined);
25
});
26
27
test('Negative: bad formats', function () {
28
    tester.negative({ object: 1 }, 'NOT_BOOLEAN', 'The value is not a boolean or could not be cast to a boolean');
29
    tester.negative('fkdsfdsfkds', 'NOT_BOOLEAN', 'The value is not a boolean or could not be cast to a boolean');
30
    tester.negative(2, 'NOT_BOOLEAN', 'The value is not a boolean or could not be cast to a boolean');
31
});
32