-
-
Notifications
You must be signed in to change notification settings - Fork 804
/
Copy pathtest.js
34 lines (22 loc) · 811 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
33
'use strict';
// MODULES //
var tape = require( 'tape' );
var isObjectArray = require( './../lib' );
// TESTS //
tape( 'main export is a function', function test( t ) {
t.ok( true, __filename );
t.equal( typeof isObjectArray, 'function', 'main export is a function' );
t.end();
});
tape( 'the function tests for an array-like object containing only objects', function test( t ) {
var arr;
arr = [ { 'type': 'object' }, /.*/, {} ];
t.equal( isObjectArray( arr ), true, 'returns true' );
arr = [ 5.0, {}, new Date() ];
t.equal( isObjectArray( arr ), false, 'returns false' );
arr = {'length': 2, '0': {}, '1': new Date() };
t.equal( isObjectArray( arr ), true, 'returns true' );
arr = [];
t.equal( isObjectArray( arr ), false, 'returns false when provided an empty array' );
t.end();
});