-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Expand file tree
/
Copy pathisDuration.test.js
More file actions
44 lines (42 loc) · 852 Bytes
/
isDuration.test.js
File metadata and controls
44 lines (42 loc) · 852 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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { describe } from 'mocha';
import test from '../testFunctions';
describe('isDuration', () => {
it('should validate duration strings', () => {
test({
validator: 'isDuration',
valid: [
'1 week',
'2 days',
'1h',
'30m',
'15 s',
'100ms',
'1.5h',
'2.5 weeks',
'-1d',
'-200',
],
invalid: [
'',
'abc',
'1 invalid',
'week 1',
'1.2.3h',
'+1h', // plus sign is not allowed as in `ms` package
'+200', // plus sign is not allowed as in `ms` package
],
});
});
it('should accept various unit formats', () => {
test({
validator: 'isDuration',
valid: [
'1 Year',
'2 WEEKS',
'3 days',
'4H',
'5m',
],
});
});
});