From e4ea3fb05f1fa0e962dc62582ae29d898d16cbc7 Mon Sep 17 00:00:00 2001 From: Ryan Graham Date: Fri, 8 Aug 2014 18:17:14 -0700 Subject: [PATCH] test: ensure parent type guard is working --- test/ctor.test.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/ctor.test.js b/test/ctor.test.js index ce6f36d..2435497 100644 --- a/test/ctor.test.js +++ b/test/ctor.test.js @@ -132,3 +132,17 @@ test('ensure Logger child() options', function (t) { t.end(); }); + + +test('ensure Logger() rejects non-Logger parents', function (t) { + var dad = new Logger({name: 'dad', streams: []}); + + t.throws(function () { new Logger({}, {}); }, + /invalid Logger creation: do not pass a second arg/, + 'Logger arguments must be valid'); + + t.doesNotThrow(function () { new Logger(dad, {}); }, + 'Logger allows Logger instance as parent'); + + t.end(); +});