Skip to content

Commit

Permalink
add a test that printLogo printed to console
Browse files Browse the repository at this point in the history
  • Loading branch information
thatkookooguy committed Feb 14, 2017
1 parent 2b5fa29 commit b0dc4ff
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test/printLogo.specs.js
@@ -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;
});
});
});
14 changes: 14 additions & 0 deletions test/stubs/stubHelper.js
@@ -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();
}
};

0 comments on commit b0dc4ff

Please sign in to comment.