-
-
Notifications
You must be signed in to change notification settings - Fork 804
/
Copy pathtest.js
73 lines (53 loc) · 1.75 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/* eslint-disable no-new-wrappers */
'use strict';
// MODULES //
var tape = require( 'tape' );
var isNumberArray = require( './../lib' );
// TESTS //
tape( 'main export is a function', function test( t ) {
t.ok( true, __filename );
t.strictEqual( typeof isNumberArray, 'function', 'main export is a function' );
t.end();
});
tape( 'the function tests for an array-like object containing only numbers', function test( t ) {
var arr;
arr = [ 1, new Number( 2 ), 3, new Number( 4 ) ];
t.strictEqual( isNumberArray( arr ), true, 'returns true' );
arr = {
'length': 2,
'0': 1,
'1': 2
};
t.strictEqual( isNumberArray( arr ), true, 'returns true' );
arr = [ 1, '2', 3 ];
t.strictEqual( isNumberArray( arr ), false, 'returns false' );
t.end();
});
tape( 'the function provides a method to test for an array-like object containing only number primitives', function test( t ) {
var arr;
arr = [ 1, 2, 3, 4 ];
t.strictEqual( isNumberArray.primitives( arr ), true, 'returns true' );
arr = {
'length': 2,
'0': 1,
'1': 2
};
t.strictEqual( isNumberArray.primitives( arr ), true, 'returns true' );
arr = [ new Number( 1 ), 2, 3 ];
t.strictEqual( isNumberArray.primitives( arr ), false, 'returns false' );
t.end();
});
tape( 'the function provides a method to test for an array-like object containing only `Number` objects', function test( t ) {
var arr;
arr = [ new Number( 1 ), new Number( 2 ), new Number( 3 ) ];
t.strictEqual( isNumberArray.objects( arr ), true, 'returns true' );
arr = {
'length': 2,
'0': new Number( 1 ),
'1': new Number( 2 )
};
t.strictEqual( isNumberArray.objects( arr ), true, 'returns true' );
arr = [ new Number( 1 ), 2, 3 ];
t.strictEqual( isNumberArray.objects( arr ), false, 'returns false' );
t.end();
});