'use strict';

// MODULES //

var tape = require( 'tape' );
var proxyquire = require( 'proxyquire' );


// VARIABLES //

var mpath = './../lib/';


// TESTS //

tape( 'main export is a function', function test( t ) {
	var homedir;
	t.ok( true, __filename );
	homedir = require( mpath );
	t.strictEqual( typeof homedir, 'function', 'main export is a function' );
	t.end();
});

tape( 'the function aliases `os.homedir` if available', function test( t ) {
	var homedir;
	var opts;

	opts = {
		'os': {
			'homedir': mock
		}
	};
	homedir = proxyquire( mpath, opts );

	t.strictEqual( homedir, mock, 'equals `os.homedir`' );
	t.end();

	function mock(){}
});

tape( 'the function supports older Node versions', function test( t ) {
	var homedir;
	var opts;
	var env;

	opts = {
		'os': {
			'homedir': undefined
		}
	};
	homedir = proxyquire( mpath, opts );
	env = process.env;
	process.env = {
		'HOME': '/Users/beep'
	};

	t.strictEqual( homedir(), '/Users/beep', 'returns home directory' );
	process.env = env;
	t.end();
});

'use strict';

// MODULES //

var tape = require( 'tape' );
var proxyquire = require( 'proxyquire' );


// VARIABLES //

var mpath = './../lib/';


// TESTS //

tape( 'main export is a function', function test( t ) {
	var homedir;
	t.ok( true, __filename );
	homedir = require( mpath );
	t.strictEqual( typeof homedir, 'function', 'main export is a function' );
	t.end();
});

tape( 'the function aliases `os.homedir` if available', function test( t ) {
	var homedir;
	var opts;

	opts = {
		'os': {
			'homedir': mock
		}
	};
	homedir = proxyquire( mpath, opts );

	t.strictEqual( homedir, mock, 'equals `os.homedir`' );
	t.end();

	function mock(){}
});

tape( 'the function supports older Node versions', function test( t ) {
	var homedir;
	var opts;
	var env;

	opts = {
		'os': {
			'homedir': void 0
		}
	};
	homedir = proxyquire( mpath, opts );
	env = process.env;
	process.env = {
		'HOME': '/Users/beep'
	};

	t.strictEqual( homedir(), '/Users/beep', 'returns home directory' );
	process.env = env;
	t.end();
});

Use void 0 instead of undefined
Use void 0 instead of undefined
