'use strict';

// MODULES //

var tape = require( 'tape' );
var proxyquire = require( 'proxyquire' );
var isArray = require( './../lib' );


// TESTS //

tape( 'main export is a function', function test( t ) {
	t.ok( true, __filename );
	t.equal( typeof isArray, 'function', 'main export is a function' );
	t.end();
});

tape( 'function returns `true` if provided an array', function test( t ) {
	t.ok( isArray( [] ), 'returns true' );
	t.ok( isArray( new Array( 10 ) ), 'returns true' );
	t.end();
});

tape( 'function returns `false` if not provided an array', function test( t ) {
	var values = [
		5,
		{},
		true,
		'5',
		null,
		NaN,
		function(){},
		undefined
	];

	for ( var i = 0; i < values.length; i++ ) {
		t.equal( !isArray( values[i] ), false, 'returns false for value: ' + values[i] );
	}
	t.end();
});

tape( 'function includes a polyfill for Array.isArray', function test( t ) {
	var fcn = Array.isArray;
	var isArray;
	var values;

	Array.isArray = undefined;
	isArray = proxyquire( './../lib', {} );

	values = [
		5,
		{},
		true,
		'5',
		null,
		NaN,
		function(){},
		undefined
	];

	for ( var i = 0; i < values.length; i++ ) {
		t.ok( !isArray( values[i] ) );
	}
	t.ok( isArray( [] ) );

	Array.isArray = fcn;
	t.end();
});

@@ -313,32 +313,36 @@
 ();%0A%7D);%0A%0Atape( '
+the 
 function returns
@@ -392,26 +392,29 @@
 t( t ) %7B%0A%09t.
-ok
+equal
 ( isArray( %5B
@@ -417,16 +417,22 @@
 y( %5B%5D ),
+ true,
  'return
@@ -441,26 +441,29 @@
 true' );%0A%09t.
-ok
+equal
 ( isArray( n
@@ -479,16 +479,22 @@
  10 ) ),
+ true,
  'return
@@ -518,32 +518,36 @@
 ();%0A%7D);%0A%0Atape( '
+the 
 function returns
@@ -604,24 +604,42 @@
  t ) %7B%0A%09var 
+values;%0A%09var i;%0A%0A%09
 values = %5B%0A%09
@@ -709,36 +709,32 @@
 ined%0A%09%5D;%0A%0A%09for (
- var
  i = 0; i %3C valu
@@ -763,17 +763,16 @@
 .equal( 
-!
 isArray(
@@ -815,14 +815,21 @@
 for 
-value:
+when provided
  ' +
@@ -867,16 +867,20 @@
 %0Atape( '
+the 
 function
@@ -993,16 +993,24 @@
  values;
+%0A%09var i;
 %0A%0A%09Array
@@ -1169,12 +1169,8 @@
 or (
- var
  i =
@@ -1208,13 +1208,15 @@
 %09%09t.
-ok
+equal
 ( 
-!
 isAr
@@ -1231,16 +1231,65 @@
 ues%5Bi%5D )
+, false, 'returns false when provided '+values%5Bi%5D
  );%0A%09%7D%0A%09
@@ -1290,18 +1290,21 @@
 ;%0A%09%7D%0A%09t.
-ok
+equal
 ( isArra
@@ -1310,16 +1310,61 @@
 ay( %5B%5D )
+, true, 'returns true when provided an array'
  );%0A%0A%09Ar

Update is-array tests