forked from mochajs/mocha
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Respect err.showDiff, add Base reporter test (close mochajs#810)
- Loading branch information
Michael Olson
committed
Nov 8, 2013
1 parent
b43cb7f
commit a5d7240
Showing
3 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
var rewire = require('rewire'), | ||
util = require('util'); | ||
|
||
describe('Base reporter', function () { | ||
var Base, output; | ||
|
||
beforeEach(function() { | ||
Base = rewire('../../lib/reporters/base'); | ||
output = { log: [], error: [] }; | ||
Base.__set__('console', { | ||
error: function() { | ||
output.error.push(arguments); | ||
}, | ||
log: function() { | ||
output.log.push(arguments); | ||
}, | ||
// allow info to be passed to original 'console' for debugging purposes | ||
info: console.info | ||
}); | ||
}); | ||
|
||
it('does not show diffs when showDiff property set', function () { | ||
var err = new Error('test'); | ||
err.actual = "a1"; | ||
err.expected = "e1"; | ||
err.showDiff = false; | ||
var test = { | ||
err: err, | ||
fullTitle: function() { return 'title'; } | ||
}; | ||
|
||
Base.list([test]); | ||
|
||
var errOut = output.error.map(function(lineArgs) { | ||
return util.format.apply(null, lineArgs); | ||
}).join('\n'); | ||
|
||
errOut.should.include('test'); | ||
errOut.should.not.include('actual'); | ||
errOut.should.not.include('expected'); | ||
}); | ||
}); |