'use strict';

// MODULES //

var tape = require( 'tape' );
var has = require( './../lib/has.js' );


// TESTS //

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

tape( 'the function returns `true` if an object has a specified path', function test( t ) {
	var bool;
	var path;
	var obj;

	obj = {
		'a': {
			'b': {
				'c': 'd'
			}
		}
	};
	path = [ 'a', 'b', 'c' ];

	bool = has( obj, path );
	t.strictEqual( bool, true, 'returns true' );

	obj = {
		'a': [
			{
				'b': [
					{
						'c': 'd'
					},
					{
						'e': 'f'
					}
				]
			}
		]
	};
	path = [ 'a', '0', 'b', '0', 'c' ];

	bool = has( obj, path );
	t.strictEqual( bool, true, 'returns true' );

	t.end();
});

tape( 'the function returns `false` if an object does not have a specified path', function test( t ) {
	var bool;
	var path;
	var obj;

	obj = {
		'a': {
			'b': {
				'c': 'd'
			}
		}
	};
	path = [ 'a', 'b', 'c', 'd', 'e' ];

	bool = has( obj, path );
	t.strictEqual( bool, false, 'returns false' );

	obj = {
		'a': [
			{
				'b': [
					{
						'c': 'd'
					},
					{
						'e': 'f'
					}
				]
			}
		]
	};
	path = [ '0', 'a', '0', 'b', '0', 'e' ];

	bool = has( obj, path );
	t.strictEqual( bool, false, 'returns false' );

	t.end();
});

'use strict';

// MODULES //

var tape = require( 'tape' );
var has = require( './../lib/has.js' );


// TESTS //

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

tape( 'the function returns `true` if an object has a specified path', function test( t ) {
	var bool;
	var path;
	var obj;

	obj = {
		'a': {
			'b': {
				'c': 'd'
			}
		}
	};
	path = [ 'a', 'b', 'c' ];

	bool = has( obj, path );
	t.strictEqual( bool, true, 'returns true' );

	obj = {
		'a': [
			{
				'b': [
					{
						'c': 'd'
					},
					{
						'e': 'f'
					}
				]
			}
		]
	};
	path = [ 'a', '0', 'b', '0', 'c' ];

	bool = has( obj, path );
	t.strictEqual( bool, true, 'returns true' );

	t.end();
});

tape( 'the function returns `false` if an object does not have a specified path', function test( t ) {
	var bool;
	var path;
	var obj;

	obj = {
		'a': {
			'b': {
				'c': 'd'
			}
		}
	};
	path = [ 'a', 'b', 'c', 'd', 'e' ];

	bool = has( obj, path );
	t.strictEqual( bool, false, 'returns false' );

	obj = {
		'a': [
			{
				'b': [
					{
						'c': 'd'
					},
					{
						'e': 'f'
					}
				]
			}
		]
	};
	path = [ '0', 'a', '0', 'b', '0', 'e' ];

	bool = has( obj, path );
	t.strictEqual( bool, false, 'returns false' );

	t.end();
});

tape( 'the function returns `false` if provided an empty object', function test( t ) {
	var bool;
	var path;
	var obj;

	path = [ 'a', 'b', 'c' ];
	obj = {};

	bool = has( obj, path );
	t.strictEqual( bool, false, 'returns false' );

	path = [];
	obj = {};

	bool = has( obj, path );
	t.strictEqual( bool, false, 'returns false' );

	t.end();
});

tape( 'the function returns `false` if provided an empty key path', function test( t ) {
	var bool;
	var path;
	var obj;

	path = [];
	obj = {
		'a': 'b'
	};

	bool = has( obj, path );
	t.strictEqual( bool, false, 'returns false' );

	path = [];
	obj = {};

	bool = has( obj, path );
	t.strictEqual( bool, false, 'returns false' );

	t.end();
});

Add test cases