-
-
Notifications
You must be signed in to change notification settings - Fork 805
/
Copy pathtest.js
46 lines (37 loc) · 972 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
34
35
36
37
38
39
40
41
42
43
44
45
46
/* eslint-disable no-array-constructor */
'use strict';
// MODULES //
var tape = require( 'tape' );
var isEmptyArray = require( './../lib' );
// TESTS //
tape( 'main export is a function', function test( t ) {
t.ok( true, __filename );
t.strictEqual( typeof isEmptyArray, 'function', 'main export is a function' );
t.end();
});
tape( 'the function returns `true` if provided an empty array', function test( t ) {
t.strictEqual( isEmptyArray( [] ), true, 'returns true' );
t.strictEqual( isEmptyArray( new Array() ), true, 'returns true' );
t.end();
});
tape( 'the function returns `false` if not provided an empty array', function test( t ) {
var values;
var i;
values = [
'5',
5,
NaN,
true,
false,
null,
undefined,
[ 1, 2, 3 ],
new Array( 10 ),
{},
function noop() {}
];
for ( i = 0; i < values.length; i++ ) {
t.strictEqual( isEmptyArray( values[i] ), false, 'returns false for when provided ' + values[i] );
}
t.end();
});