Skip to content

Commit

Permalink
Upgraded unexpected to get ansi colors instead of html when running i…
Browse files Browse the repository at this point in the history
…n mocha phantomjs
  • Loading branch information
Sune Simonsen committed Dec 16, 2014
1 parent 2a30f8d commit 5282b6c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -5,7 +5,7 @@
"main": "./lib/uninspected",
"dependencies": {
"magicpen-prism": "0.2.0",
"unexpected": "5.0.0-beta22"
"unexpected": "5.0.0-beta24"
},
"devDependencies": {
"browserify": "^5.9.1",
Expand Down
17 changes: 10 additions & 7 deletions test/uninspected.js
Expand Up @@ -6,35 +6,38 @@ var uninspected = require('../lib/uninspected'),

describe('uninspected', function () {
var expect = unexpected.clone().installPlugin(require('unexpected-sinon'));
var originalOutputFormat = uninspected.outputFormat;

afterEach(function () {
uninspected.outputFormat = originalOutputFormat;
});

describe('#inspect', function () {
it('should produce colored output', function () {
expect(uninspected.inspect({foo: 'abc'}), 'to equal', '{ foo: \x1B[36m\x1B[38;5;44m\'abc\'\x1B[39m }');
expect(uninspected.inspect({foo: 'abc'}), 'to equal', '{ \x1B[90m\x1B[38;5;242mfoo\x1B[39m: \x1B[36m\x1B[38;5;44m\'abc\'\x1B[39m }');
});

it('should have a default depth of 4', function () {
uninspected.outputFormat = 'text';
expect(uninspected.inspect({foo: {foo: {foo: {foo: {foo: {foo: 123}}}}}}), 'to equal', '{ foo: { foo: { foo: { foo: { foo: ... } } } } }');
});
});

it('should be a shorthand for uninspected.log', function () {
uninspected.outputFormat = 'text';
sinon.stub(console, 'log');
uninspected('abc', {foo: true});
expect(console.log, 'was called with', 'abc { foo: true }');
console.log.restore(); // Cannot do this in an afterEach as it'll suppress mocha's output
});

describe('#log', function () {
var originalOutputFormat = uninspected.outputFormat;
beforeEach(function () {
sinon.stub(console, 'log');
});

afterEach(function () {
uninspected.outputFormat = originalOutputFormat;
});

it('should log to the console', function () {
uninspected.outputFormat = 'text';
uninspected.log('abc', {foo: true});
expect(console.log, 'was called with', 'abc { foo: true }');
console.log.restore(); // Cannot do this in an afterEach as it'll suppress mocha's output
Expand All @@ -43,7 +46,7 @@ describe('uninspected', function () {
it('should log with colors if told to', function () {
uninspected.outputFormat = 'ansi';
uninspected.log('abc', {foo: 'abc'});
expect(console.log.args[0], 'to equal', ['abc { foo: \x1B[36m\x1B[38;5;44m\'abc\'\x1B[39m }']);
expect(console.log.args[0], 'to equal', ['abc { \x1B[90m\x1B[38;5;242mfoo\x1B[39m: \x1B[36m\x1B[38;5;44m\'abc\'\x1B[39m }']);
console.log.restore(); // Cannot do this in an afterEach as it'll suppress mocha's output
});

Expand Down

0 comments on commit 5282b6c

Please sign in to comment.