Permalink
Browse files

Tests for enabling & disabling warnings.

  • Loading branch information...
1 parent 575e9b3 commit 90f16180e913fea1d700844014e1b2a4e30d9f94 @mfncooper committed Dec 27, 2011
Showing with 40 additions and 2 deletions.
  1. +40 −2 test/mockery.functional.js
View
@@ -23,7 +23,7 @@ module.exports = testCase({
callback();
},
- "when a mock is not registered": testCase({
+ "when nothing is registered": testCase({
"and mockery is enabled": testCase({
setUp: function (callback) {
mockery.enable();
@@ -40,7 +40,45 @@ module.exports = testCase({
mock_console.verify();
mock_console.restore();
test.done();
- }
+ },
+
+ "and warnings are disabled": testCase({
+ setUp: function (callback) {
+ mockery.warnOnUnregistered(false);
+ callback();
+ },
+
+ "requiring a module causes no warning to be logged": function (test) {
+ var mock_console = sinon.mock(console);
+ mock_console.expects('warn').never();
+
+ var fake_module = require('./fixtures/fake_module');
+ test.equal(fake_module.foo(), 'real foo');
+
+ mock_console.verify();
+ mock_console.restore();
+ test.done();
+ }
+ }),
+
+ "and warnings are reenabled": testCase({
+ setUp: function (callback) {
+ mockery.warnOnUnregistered(true);
+ callback();
+ },
+
+ "requiring a module causes a warning to be logged": function (test) {
+ var mock_console = sinon.mock(console);
+ mock_console.expects('warn').once();
+
+ var fake_module = require('./fixtures/fake_module');
+ test.equal(fake_module.foo(), 'real foo');
+
+ mock_console.verify();
+ mock_console.restore();
+ test.done();
+ }
+ })
})
}),

0 comments on commit 90f1618

Please sign in to comment.