From c442bda7f50856f202b453c6423ce92a3e15cfb1 Mon Sep 17 00:00:00 2001 From: Terseus Date: Sat, 24 Apr 2021 14:10:18 +0200 Subject: [PATCH] Add a test to check if a warning is emitted --- test/cliff-test.js | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/test/cliff-test.js b/test/cliff-test.js index 83be1dc..97a0123 100644 --- a/test/cliff-test.js +++ b/test/cliff-test.js @@ -5,12 +5,34 @@ * */ +// When using cliff with winston 0.8.x in node 14.x a warning is emitted: +// +// Warning: Accessing non-existent property 'padLevels' of module exports +// inside circular dependency +// +// The warning is emitted when we require'd cliff, which happens before any +// test, so in order to test that a warning is *not* emitted we have to capture +// it before requiring cliff. +var warnings = []; +process.on('warning', function(warning) { + warnings.push(warning); +}); + var assert = require('assert'), vows = require('vows'), eyes = require('eyes'), cliff = require('../lib/cliff'); vows.describe('cliff').addBatch({ + "When require cliff module": { + "no warning should be raised": function () { + var rows = [ + ["a", "b"], + ]; + cliff.putRows('info', rows, ['red', 'green']); + assert.isEmpty(warnings); + }, + }, "When using cliff module": { "the columnMajor() method": { "should respond with rows in column major form": function () { @@ -76,4 +98,4 @@ vows.describe('cliff').addBatch({ } } } -}).export(module); \ No newline at end of file +}).export(module);