-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
26 lines (20 loc) · 750 Bytes
/
test.js
File metadata and controls
26 lines (20 loc) · 750 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import test from 'ava';
import integer from './index.js';
test('integer return type to be number', t => {
t.is(typeof integer(), 'number');
});
test('integer with number min 0 return type to be number', t => {
t.is(typeof integer({min: 0}), 'number');
});
test('integer with number min 0 and max 10 return type to be number', t => {
t.is(typeof integer({min: 0, max: 10}), 'number');
});
test('integer with number min 0 and max 10 less than 11', t => {
t.true(integer({min: 0, max: 10}) < 11);
});
test('integer with string to thow error on min > max', t => {
const error = t.throws(() => {
integer({min: 10, max: 0});
}, {instanceOf: TypeError});
t.is(error.message, 'Min cannot be greater than Max.');
});