'use strict';

// MODULES //

var tape = require( 'tape' );
var hasOwnProp = require( './../lib' );


// TESTS //

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

tape( 'the function returns `false` if provided `null` or `undefined` for the first argument (native throws)', function test( t ) {
	var bool;

	bool = hasOwnProp( null, 'beep' );
	t.equal( bool, false, 'returns false when provided null' );

	bool = hasOwnProp( void 0, 'beep' );
	t.equal( bool, false, 'returns false when provided undefined' );

	t.end();
});

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

	bool = hasOwnProp( {'a':'b'}, 'a' );
	t.equal( bool, true, 'returns true' );

	bool = hasOwnProp( [1,2,3], '1' );
	t.equal( bool, true, 'returns true' );

	bool = hasOwnProp( [1,2,3], 1 );
	t.equal( bool, true, 'returns true' );

	t.end();
});

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

	bool = hasOwnProp( {'a':'b'}, 'c' );
	t.equal( bool, false, 'returns false' );

	bool = hasOwnProp( {'a':'b'}, null );
	t.equal( bool, false, 'returns false' );

	t.end();
});

tape( 'the function returns `false` if provided a prototype property', function test( t ) {
	var bool;

	bool = hasOwnProp( {}, 'hasOwnProperty' );
	t.equal( bool, false, 'returns false when provided a protyotype property' );

	t.end();
});

tape( 'values are coerced to objects', function test( t ) {
	var bool;

	bool = hasOwnProp( 'beep', 'length' );
	t.equal( bool, true, 'returns true' );

	t.end();
});

tape( 'property values are coerced to strings', function test( t ) {
	var bool;

	bool = hasOwnProp( {'null':false}, null );
	t.equal( bool, true, 'returns true' );

	bool = hasOwnProp( {'[object Object]':false}, {} );
	t.equal( bool, true, 'returns true' );

	t.end();
});

/* eslint-disable object-curly-newline */
'use strict';

// MODULES //

var tape = require( 'tape' );
var hasOwnProp = require( './../lib' );


// TESTS //

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

tape( 'the function returns `false` if provided `null` or `undefined` for the first argument (native throws)', function test( t ) {
	var bool;

	bool = hasOwnProp( null, 'beep' );
	t.strictEqual( bool, false, 'returns false when provided null' );

	bool = hasOwnProp( void 0, 'beep' );
	t.strictEqual( bool, false, 'returns false when provided undefined' );

	t.end();
});

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

	bool = hasOwnProp( { 'a': 'b' }, 'a' );
	t.strictEqual( bool, true, 'returns true' );

	bool = hasOwnProp( [ 1, 2, 3 ], '1' );
	t.strictEqual( bool, true, 'returns true' );

	bool = hasOwnProp( [ 1, 2, 3 ], 1 );
	t.strictEqual( bool, true, 'returns true' );

	t.end();
});

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

	bool = hasOwnProp( { 'a': 'b' }, 'c' );
	t.strictEqual( bool, false, 'returns false' );

	bool = hasOwnProp( { 'a': 'b' }, null );
	t.strictEqual( bool, false, 'returns false' );

	t.end();
});

tape( 'the function returns `false` if provided a prototype property', function test( t ) {
	var bool;

	bool = hasOwnProp( {}, 'hasOwnProperty' );
	t.strictEqual( bool, false, 'returns false when provided a prototype property' );

	t.end();
});

tape( 'values are coerced to objects', function test( t ) {
	var bool;

	bool = hasOwnProp( 'beep', 'length' );
	t.strictEqual( bool, true, 'returns true' );

	t.end();
});

tape( 'property values are coerced to strings', function test( t ) {
	var bool;

	bool = hasOwnProp( { 'null': false }, null );
	t.strictEqual( bool, true, 'returns true' );

	bool = hasOwnProp( { '[object Object]': false }, {} );
	t.strictEqual( bool, true, 'returns true' );

	t.end();
});

Fix spelling mistake