/* global require, describe, it */
'use strict';

// MODULES //

var tape = require( 'tape' );
var fs = require( 'fs' );
var proxyquire = require( 'proxyquire' );
var exists = require( './../lib/sync.js' );


// FIXME //

if ( typeof window !== 'undefined'  ) {
	// Don't run tests in the browser...for now...
	return;
}


// TESTS //

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

tape( 'function returns true if a path exists', function test( t ) {
	t.equal( exists( __filename ), true, 'returns true' );
	t.end();
});

tape( 'function returns false if a path does not exists', function test( t ) {
	t.equal( exists( 'beepboopbebop' ), false, 'returns false' );
	t.end();
});

tape( 'if `fs.access` is not supported, the function uses `fs.statSync`', function test( t ) {
	var exists = proxyquire( './../lib/sync.js', {
		'fs': {
			'statSync': fs.statSync,
			'accessSync': void 0
		}
	});
	t.equal( exists( __filename ), true, 'returns true' );
	t.end();
});

tape( 'should negatively test using `statSync`', function test( t ) {
	var exists = proxyquire( './../lib/sync.js', {
		'fs': {
			'statSync': fs.statSync,
			'accessSync': void 0
		}
	});
	t.equal( exists( 'beepboopbebop' ), false, 'returns false' );
	t.end();
});

'use strict';

// MODULES //

var tape = require( 'tape' );
var fs = require( 'fs' );
var proxyquire = require( 'proxyquire' );
var exists = require( './../lib/sync.js' );


// FIXME //

if ( typeof window !== 'undefined'  ) {
	// Don't run tests in the browser...for now...
	return;
}


// TESTS //

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

tape( 'function returns true if a path exists', function test( t ) {
	t.equal( exists( __filename ), true, 'returns true' );
	t.end();
});

tape( 'function returns false if a path does not exists', function test( t ) {
	t.equal( exists( 'beepboopbebop' ), false, 'returns false' );
	t.end();
});

tape( 'if `fs.access` is not supported, the function uses `fs.statSync`', function test( t ) {
	var exists = proxyquire( './../lib/sync.js', {
		'fs': {
			'statSync': fs.statSync,
			'accessSync': void 0
		}
	});
	t.equal( exists( __filename ), true, 'returns true' );
	t.end();
});

tape( 'should negatively test using `statSync`', function test( t ) {
	var exists = proxyquire( './../lib/sync.js', {
		'fs': {
			'statSync': fs.statSync,
			'accessSync': void 0
		}
	});
	t.equal( exists( 'beepboopbebop' ), false, 'returns false' );
	t.end();
});

Remove JSDOC annotation line from test file of fs.exists