'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();
});

'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( 'the function returns `true` if provided an array', function test( t ) {
	t.equal( isArray( [] ), true, 'returns true' );
	t.equal( isArray( new Array( 10 ) ), true, 'returns true' );
	t.end();
});

tape( 'the function returns `false` if not provided an array', function test( t ) {
	var values;
	var i;

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

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

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

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

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

	for ( i = 0; i < values.length; i++ ) {
		t.equal( isArray( values[i] ), false, 'returns false when provided '+values[i] );
	}
	t.equal( isArray( [] ), true, 'returns true when provided an array' );

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

Update is-array tests