forked from sindresorhus/round-to
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
29 lines (26 loc) · 668 Bytes
/
Copy pathtest.js
File metadata and controls
29 lines (26 loc) · 668 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
27
28
29
import test from 'ava';
import fn from './';
test('roundTo()', t => {
t.is(fn(0.129, 3), 0.129);
t.is(fn(0.129, 2), 0.13);
t.is(fn(0.129, 1), 0.1);
t.is(fn(1.005, 2), 1.01);
t.is(fn(1.005, 0), 1);
t.is(fn(111.1, -2), 100);
});
test('roundTo.up()', t => {
t.is(fn.up(0.111, 3), 0.111);
t.is(fn.up(0.111, 2), 0.12);
t.is(fn.up(0.111, 1), 0.2);
t.is(fn.up(1.004, 2), 1.01);
t.is(fn.up(1.111, 0), 2);
t.is(fn.up(111.1, -2), 200);
});
test('roundTo.down()', t => {
t.is(fn.down(0.666, 3), 0.666);
t.is(fn.down(0.666, 2), 0.66);
t.is(fn.down(0.666, 1), 0.6);
t.is(fn.down(1.006, 2), 1.00);
t.is(fn.down(1.006, 0), 1);
t.is(fn.down(111.6, -2), 100);
});