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

Complexity

Total Complexity 5
Complexity/F 1

Size

Lines of Code 34
Function Count 5

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 22
mnd 0
bc 0
fnc 5
dl 0
loc 34
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('number');
4
5
suite('Rules: number');
6
7
test('Positive: numbers', function () {
8
    tester.positive(1, 1);
9
    tester.positive(-3874, -3874);
10
    tester.positive(0, 0);
11
    tester.positive(1e+7, 1e+7);
12
});
13
14
test('Positive: string', function () {
15
    tester.positive('5', 5);
16
    tester.positive('6.0', 6);
17
    tester.positive('-34', -34);
18
});
19
20
test('Positive: empty value', function () {
21
    tester.positive(null, null);
22
    tester.positive(undefined, undefined);
23
});
24
25
test('Negative: numbers', function () {
26
    tester.negative(Number.NaN, 'NOT_NUMBER', 'The value is not a number or could not be cast to a number');
27
});
28
29
test('Negative: bad formats', function () {
30
    tester.negative({ object: 1 }, 'NOT_NUMBER', 'The value is not a number or could not be cast to a number');
31
    tester.negative(false, 'NOT_NUMBER', 'The value is not a number or could not be cast to a number');
32
    tester.negative(true, 'NOT_NUMBER', 'The value is not a number or could not be cast to a number');
33
    tester.negative('fkdsfdsfkds', 'NOT_NUMBER', 'The value is not a number or could not be cast to a number');
34
});
35