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
|
|
|
|