-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathspec.js
41 lines (40 loc) · 824 Bytes
/
spec.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
39
40
41
const dd = require('.');
describe('double-digit', () => {
[
[ 0, '00' ],
[ 1, '01' ],
[ 9.9, '09.9' ],
[ 0.001, '00.001' ],
[ 1e3, '1000' ],
].forEach(([ n, r ]) => {
it(
`Should convert ${n} to ${r}`,
() => expect(dd(n)).to.equal(r),
);
it(
`${r} should represent ${n}`,
() => expect(Number(r)).to.equal(n),
);
});
[
[ '2', '02' ],
[ '2.0001', '02.0001' ],
[ '12', '12' ],
[ 'Hello', 'Hello' ],
[ undefined, undefined ],
[ false, false ],
[ null, null ],
[ Infinity, Infinity ],
[ -Infinity, -Infinity ],
].forEach(([ n, r ]) => {
it(
`Should convert ${n} to ${r}`,
() => expect(dd(n)).to.equal(r),
);
});
it('Should not convert NaN', () => {
const result = dd(NaN);
expect(result).to.be.a('number');
expect(Number.isNaN(result)).to.be.true;
});
});