Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a test that printLogo printed to console
- Loading branch information
1 parent
2b5fa29
commit b0dc4ff
Showing
2 changed files
with
32 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
var stubHelper = require('./stubs/stubHelper'); | ||
var expect = require('chai').expect; | ||
|
||
describe('printLogo', function() { | ||
|
||
it('should print logo if called to console log', function() { | ||
stubHelper(function() { | ||
var didRun = false; | ||
console.log = function() { didRun = true; }; | ||
|
||
// run the file | ||
var printLogo = require('../printLogo'); | ||
printLogo(); | ||
|
||
expect(didRun).to.be.true; | ||
}); | ||
}); | ||
}); |
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,14 @@ | ||
module.exports = function helper(fn) { | ||
var originalConsoleLog = console.log; | ||
|
||
function restore() { | ||
console.log = originalConsoleLog; | ||
} | ||
|
||
if (fn.length) { | ||
fn(restore); | ||
} else { | ||
fn(); | ||
restore(); | ||
} | ||
}; |