c893a85
'use strict';
c893a85
var assert = require('assert');
c893a85
98abd30
beforeEach(function () {
98abd30
	// clear the cache of the tested module
98abd30
	delete require.cache[require.resolve('./index')];
98abd30
	process.stdout.isTTY = true;
98abd30
	process.argv = [];
98abd30
	process.env = {};
98abd30
});
c893a85
98abd30
it('should return false if not TTY', function () {
98abd30
	process.stdout.isTTY = false;
98abd30
	assert.equal(require('./index'), false);
98abd30
});
c893a85
98abd30
it('should return false if --no-color flag is used', function () {
98abd30
	process.argv = ['--no-color'];
98abd30
	assert.equal(require('./index'), false);
98abd30
});
c893a85
98abd30
it('should return true if --color flag is used', function () {
98abd30
	process.argv = ['--color'];
98abd30
	assert.equal(require('./index'), true);
98abd30
});
c893a85
98abd30
it('should return true if `COLORTERM` is in env', function () {
98abd30
	process.env.COLORTERM = true;
98abd30
	assert.equal(require('./index'), true);
c893a85
});
98abd30