-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
38 lines (26 loc) · 796 Bytes
/
test.js
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
30
31
32
33
34
35
36
37
38
var tape = require('tape');
var zeroise = require('./');
tape('add leading zeros when number digits are more than the threshold', function(t) {
var result = zeroise(12, 4);
var expected = '0012';
t.same( result, expected );
t.end();
});
tape('leave the number untouched when number digits are the same as the threshold', function(t) {
var result = zeroise(1234, 4);
var expected = '1234';
t.same( result, expected );
t.end();
});
tape('leave the number untouched when number digits are more than the threshold', function(t) {
var result = zeroise(12345, 4);
var expected = '12345';
t.same( result, expected );
t.end();
});
tape('use a custom padding string', function(t) {
var result = zeroise(12, 4, 5);
var expected = '5512';
t.same( result, expected );
t.end();
});