test-console
Advanced tools
Comparing version 0.7.1 to 1.0.0
@@ -10,3 +10,3 @@ // Copyright (c) 2014 Titanium I.T. LLC. All rights reserved. For license, see "README" or "LICENSE" file. | ||
task("default", ["lint", "test"], function() { | ||
console.log("\n\nOK"); | ||
console.log("\n\nBUILD OK"); | ||
}); | ||
@@ -16,2 +16,3 @@ | ||
task("lint", function() { | ||
process.stdout.write("Linting JavaScript: "); | ||
jshint.checkFiles({ | ||
@@ -26,3 +27,4 @@ files: [ "*.js", "src/**/*.js" ], | ||
task("test", function() { | ||
var mocha = new Mocha({ui: "bdd"}); | ||
console.log("Testing JavaScript: "); | ||
var mocha = new Mocha({ ui: "bdd", reporter: "dot" }); | ||
testFiles().forEach(mocha.addFile.bind(mocha)); | ||
@@ -29,0 +31,0 @@ |
{ | ||
"name": "test-console", | ||
"version": "0.7.1", | ||
"version": "1.0.0", | ||
"description": "A simple and pragmatic library for testing Node.js console output.", | ||
@@ -28,8 +28,8 @@ "main": "src/index.js", | ||
"devDependencies": { | ||
"jake": "^0.7.10", | ||
"jshint": "^2.4.4", | ||
"simplebuild-jshint": "^0.3.0", | ||
"mocha": "^1.18.2", | ||
"chai": "^1.9.1" | ||
"chai": "^3.0.0", | ||
"jake": "^8.0.12", | ||
"jshint": "^2.8.0", | ||
"mocha": "^2.2.5", | ||
"simplebuild-jshint": "^0.3.0" | ||
} | ||
} |
@@ -157,2 +157,4 @@ # test-console | ||
__1.0.0:__ API fails with nice error messages when called with wrong number of arguments. | ||
__0.7.1:__ Bug fix: Sync() versions restore old behavior even if exception occurs | ||
@@ -173,3 +175,3 @@ | ||
Copyright (c) 2014 James Shore | ||
Copyright (c) 2014-2015 James Shore | ||
@@ -176,0 +178,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy |
@@ -1,2 +0,2 @@ | ||
// Copyright (c) 2014 Titanium I.T. LLC. All rights reserved. For license, see "README" or "LICENSE" file. | ||
// Copyright (c) 2014-2015 Titanium I.T. LLC. All rights reserved. For license, see "README" or "LICENSE" file. | ||
"use strict"; | ||
@@ -8,3 +8,3 @@ | ||
describe("inspect", function() { | ||
describe("'synchronous' inspect", function() { | ||
@@ -22,2 +22,8 @@ it("calls passed-in function synchronously", function() { | ||
it("fails nicely when user forgets to pass in a function", function() { | ||
assert.throws(function() { | ||
stdout.inspectSync(); | ||
}, "inspectSync() requires a function parameter. Did you mean to call inspect()?"); | ||
}); | ||
it("provides writes to passed-in function", function() { | ||
@@ -93,2 +99,8 @@ stdout.inspectSync(function(output) { | ||
it("fails nicely when user confuses it for inspectSync and passes in a function", function() { | ||
assert.throws(function() { | ||
stdout.inspect(function() {}); | ||
}, "inspect() doesn't take a function parameter. Did you mean to call inspectSync()?"); | ||
}); | ||
it("is like synchronous version, except you have to restore it manually", function() { | ||
@@ -118,4 +130,10 @@ var inspect = stdout.inspect(); | ||
describe("ignore", function() { | ||
describe("'synchronous' ignore", function() { | ||
it("fails nicely when user forgets to pass in a function", function() { | ||
assert.throws(function() { | ||
stdout.ignoreSync(); | ||
}, "ignoreSync() requires a function parameter. Did you mean to call ignore()?"); | ||
}); | ||
it("simply disables output to console", function() { | ||
@@ -144,2 +162,8 @@ // We'll use inspect() to make sure ignore() works. Inception! (Okay, that joke's getting old. Too bad! Mwahaha!) | ||
it("fails nicely when user confuses it for ignoreSync and passes in a function", function() { | ||
assert.throws(function() { | ||
stdout.ignore(function() {}); | ||
}, "ignore() doesn't take a function parameter. Did you mean to call ignoreSync()?"); | ||
}); | ||
it("is like synchronous version, except you have to restore it manually", function() { | ||
@@ -146,0 +170,0 @@ // inception! |
@@ -1,2 +0,2 @@ | ||
// Copyright (c) 2014 Titanium I.T. LLC. All rights reserved. For license, see "README" or "LICENSE" file. | ||
// Copyright (c) 2014-2015 Titanium I.T. LLC. All rights reserved. For license, see "README" or "LICENSE" file. | ||
"use strict"; | ||
@@ -12,2 +12,4 @@ | ||
TestStream.prototype.inspect = function() { | ||
expectNoArguments(arguments, "inspect", "inspectSync"); | ||
// This code inspired by http://userinexperience.com/?p=714 | ||
@@ -31,2 +33,4 @@ var output = []; | ||
TestStream.prototype.inspectSync = function(fn) { | ||
expectOneFunction(arguments, "inspectSync", "inspect"); | ||
var inspect = this.inspect(); | ||
@@ -43,2 +47,4 @@ try { | ||
TestStream.prototype.ignore = function() { | ||
expectNoArguments(arguments, "ignore", "ignoreSync"); | ||
return this.inspect().restore; | ||
@@ -48,2 +54,4 @@ }; | ||
TestStream.prototype.ignoreSync = function(fn) { | ||
expectOneFunction(arguments, "ignoreSync", "ignore"); | ||
this.inspectSync(function() { | ||
@@ -53,1 +61,15 @@ fn(); | ||
}; | ||
function expectNoArguments(args, calledFunction, functionToCallInstead) { | ||
if (args.length !== 0) { | ||
throw new Error(calledFunction + "() doesn't take a function parameter. Did you mean to call " + | ||
functionToCallInstead + "()?"); | ||
} | ||
} | ||
function expectOneFunction(args, calledFunction, functionToCallInstead) { | ||
if (args.length !== 1) { | ||
throw new Error(calledFunction + "() requires a function parameter. Did you mean to call " + | ||
functionToCallInstead + "()?"); | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
15412
273
0
194