arnaucube
arnaucube/thoughtsPublic Self-hosted repository
thoughts/node_modules/mongoose/node_modules/ms/test/test.js
node_modules/mongoose/node_modules/ms/test/test.jsRaw
 1
 2/**
 3 * Dependencies.
 4 */
 5
 6if ('undefined' != typeof require) {
 7  expect = require('expect.js');
 8  ms = require('../ms');
 9}
10
11/**
12 * Test.
13 */
14
15describe('ms.js', function () {
16
17  it('should preserve ms', function () {
18    expect(100).to.be(100);
19  });
20
21  it('should convert number strings to number', function () {
22    expect(ms('1e+5')).to.be(1e+5);
23  });
24 
25  it('should convert from m to ms', function () {
26    expect(ms('1m')).to.be(60000);
27  });
28
29  it('should convert from h to ms', function () {
30    expect(ms('1h')).to.be(3600000);
31  });
32
33  it('should convert d to ms', function () {
34    expect(ms('2d')).to.be(172800000);
35  });
36
37  it('should convert s to ms', function () {
38    expect(ms('1s')).to.be(1000);
39  });
40
41  it('should convert ms to ms', function () {
42    expect(ms('100ms')).to.be(100);
43  });
44
45  it('should work with decimals', function () {
46    expect(ms('1.5h')).to.be(5400000);
47  });
48
49  it('should return NaN if invalid', function () {
50    expect(isNaN(ms('☃'))).to.be(true);
51  });
52
53  it('should be case-insensitive', function () {
54    expect(ms('1.5H')).to.be(5400000);
55  });
56
57  it('should work with numbers starting with .', function () {
58    expect(ms('.5ms')).to.be(.5);
59  });
60
61});