1
0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-11-08 23:25:51 +01:00
verdaccio/test/unit/parse_interval.js
Alex Kocharin 6b9001ef6c change interval formatting in config
All intervals are now in milliseconds. But you can add
multiples ("ms", "s", "m", "h", "d", "M", "y") to set
value using different units.

For example, value "1.5h" would mean 1.5 hours.
2014-03-08 03:49:59 +00:00

22 lines
525 B
JavaScript

var assert = require('assert')
, parse_interval = require('../../lib/config').parse_interval
describe('Parse interval', function() {
function add_test(str, res) {
it('parse ' + str, function() {
assert.strictEqual(parse_interval(str), res)
})
}
add_test(12345, 12345)
add_test('1000', 1000)
add_test('1.5s', 1500)
add_test('25ms', 25)
add_test('2m', 2*1000*60)
add_test('3h', 3*1000*60*60)
add_test('0.5d', 0.5*1000*60*60*24)
add_test('1M', 1000*60*60*24*30)
add_test('1y', 1000*60*60*24*30*365.25)
})