-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
32 lines (29 loc) · 901 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
/**
* Module dependencies
*/
var assert = require('assert');
var regex = require('./');
/**
* Test
*/
describe('utc regex', function() {
it('should match iso input', function() {
assert.equal(regex().test('2011-10-05T14:48:00.000Z'), true);
});
it('should expose match groups', function() {
var match = regex().exec('2011-10-05T14:48:00.000Z');
assert.equal(match[0], '2011-10-05T14:48:00.000Z');
assert.equal(match[1], '2011');
assert.equal(match[2], '10');
assert.equal(match[3], '05');
assert.equal(match[4], '14:48:00');
assert.equal(match[5], '14');
assert.equal(match[6], '48');
assert.equal(match[7], '00');
assert.equal(match[8], '000');
});
it('should catch incorrect input', function() {
assert.equal(regex().test('201-10-05T14:48:00.000Z'), false);
assert.equal(regex().test('2011-10-05T14:48:00.00Z'), false);
});
});