'use strict';

// MODULES //

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


// VARIABLES //

var hasSymbols = ( typeof Symbol !== 'undefined' );


// TESTS //

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

tape( 'feature detection result is a boolean', function test( t ) {
	t.equal( typeof detect(), 'boolean', 'detection result is a boolean' );
	t.end();
});

tape( 'if `Symbols` are supported, detection result is `true`', function test( t ) {
	if ( hasSymbols ) {
		t.equal( detect(), true, 'detection result is `true`' );
	} else {
		t.equal( detect(), false, 'detection result is `false`' );
	}
	t.end();
});

tape( 'the function guards against a `Symbol` global variable which does not produce `symbols`', function test( t ) {
	var tmp;
	if ( hasSymbols ) {
		tmp = Symbol;
		Symbol = {};
	} else {
		global.Symbol = {};
	}
	t.equal( detect(), false, 'detection result is `false`' );
	if ( hasSymbols ) {
		Symbol = tmp;
	}
	t.end();
});

'use strict';

// MODULES //

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


// VARIABLES //

var hasSymbols = ( typeof Symbol === 'function' );


// TESTS //

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

tape( 'feature detection result is a boolean', function test( t ) {
	t.equal( typeof detect(), 'boolean', 'detection result is a boolean' );
	t.end();
});

tape( 'if `Symbols` are supported, detection result is `true`', function test( t ) {
	if ( hasSymbols ) {
		t.equal( detect(), true, 'detection result is `true`' );
	} else {
		t.equal( detect(), false, 'detection result is `false`' );
	}
	t.end();
});

tape( 'the function guards against a `Symbol` global variable which does not produce `symbols`', function test( t ) {
	var tmp;
	if ( hasSymbols ) {
		tmp = Symbol;
		Symbol = {};
	} else {
		global.Symbol = {};
	}
	t.equal( detect(), false, 'detection result is `false`' );
	if ( hasSymbols ) {
		Symbol = tmp;
	}
	t.end();
});

Fix feature detection bug on Node v0.10
Fix feature detection bug on Node v0.10
