-
-
Notifications
You must be signed in to change notification settings - Fork 804
/
Copy pathtest.js
45 lines (32 loc) · 1.03 KB
/
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
33
34
35
36
37
38
39
40
41
42
43
44
'use strict';
// MODULES //
var tape = require( 'tape' );
var isDateObjectArray = require( './../lib' );
// TESTS //
tape( 'main export is a function', function test( t ) {
t.ok( true, __filename );
t.strictEqual( typeof isDateObjectArray, 'function', 'main export is a function' );
t.end();
});
tape( 'the function tests for an array-like object containing only `Date` objects', function test( t ) {
var arr;
arr = [ new Date(), new Date(), new Date() ];
t.strictEqual( isDateObjectArray( arr ), true, 'returns true' );
arr = [
{ 'type': 'object' }, // eslint-disable-line object-curly-newline
/.*/,
{}
];
t.strictEqual( isDateObjectArray( arr ), false, 'returns false' );
arr = [ 5.0, {}, new Date() ];
t.strictEqual( isDateObjectArray( arr ), false, 'returns false' );
arr = {
'length': 2,
'0': new Date(),
'1': new Date()
};
t.strictEqual( isDateObjectArray( arr ), true, 'returns true' );
arr = [];
t.strictEqual( isDateObjectArray( arr ), false, 'returns false when provided an empty array' );
t.end();
});