From 1d5135bccaca46e64bf802c6aec5a716000787ce Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Mon, 2 Jan 2017 19:09:45 +1100 Subject: [PATCH] fix(test): moved abspath test to tap --- test/tap/log-abspath-test.js | 88 +++++++++++++++++++++++++++++++++++ test/vows/log-abspath-test.js | 88 ----------------------------------- 2 files changed, 88 insertions(+), 88 deletions(-) create mode 100644 test/tap/log-abspath-test.js delete mode 100644 test/vows/log-abspath-test.js diff --git a/test/tap/log-abspath-test.js b/test/tap/log-abspath-test.js new file mode 100644 index 0000000..aa274ac --- /dev/null +++ b/test/tap/log-abspath-test.js @@ -0,0 +1,88 @@ +'use strict'; + +const test = require('tap').test; +const path = require('path'); +const sandbox = require('sandboxed-module'); + +test('log4js-abspath', (batch) => { + batch.test('options', (t) => { + let appenderOptions; + + const log4js = sandbox.require( + '../../lib/log4js', + { + singleOnly: true, + requires: { + './appenders/fake': { + name: 'fake', + appender: function () { + }, + configure: function (configuration, options) { + appenderOptions = options; + return function () { + }; + } + } + } + } + ); + + const config = { + appenders: [ + { + type: 'fake', + filename: 'cheesy-wotsits.log' + } + ] + }; + + log4js.configure(config, { + cwd: '/absolute/path/to' + }); + t.test('should be passed to appenders during configuration', (assert) => { + assert.equal(appenderOptions.cwd, '/absolute/path/to'); + assert.end(); + }); + t.end(); + }); + + batch.test('file appender', (t) => { + let fileOpened; + + const fileAppender = sandbox.require( + '../../lib/appenders/file', + { + requires: { + streamroller: { + RollingFileStream: function (file) { + fileOpened = file; + return { + on: function () { + }, + end: function () { + } + }; + } + } + } + } + ); + + fileAppender.configure( + { + filename: 'whatever.log', + maxLogSize: 10 + }, + { cwd: '/absolute/path/to' } + ); + + t.test('should prepend options.cwd to config.filename', (assert) => { + const expected = path.sep + path.join('absolute', 'path', 'to', 'whatever.log'); + assert.equal(fileOpened, expected); + assert.end(); + }); + t.end(); + }); + + batch.end(); +}); diff --git a/test/vows/log-abspath-test.js b/test/vows/log-abspath-test.js deleted file mode 100644 index c761628..0000000 --- a/test/vows/log-abspath-test.js +++ /dev/null @@ -1,88 +0,0 @@ -'use strict'; - -const vows = require('vows'); -const assert = require('assert'); -const path = require('path'); -const sandbox = require('sandboxed-module'); - -vows.describe('log4js-abspath').addBatch({ - options: { - topic: function () { - let appenderOptions; - - const log4js = sandbox.require( - '../../lib/log4js', - { - singleOnly: true, - requires: { - './appenders/fake': { - name: 'fake', - appender: function () { - }, - configure: function (configuration, options) { - appenderOptions = options; - return function () { - }; - } - } - } - } - ); - - const config = { - appenders: [ - { - type: 'fake', - filename: 'cheesy-wotsits.log' - } - ] - }; - - log4js.configure(config, { - cwd: '/absolute/path/to' - }); - return appenderOptions; - }, - 'should be passed to appenders during configuration': function (options) { - assert.equal(options.cwd, '/absolute/path/to'); - } - }, - - 'file appender': { - topic: function () { - let fileOpened; - - const fileAppender = sandbox.require( - '../../lib/appenders/file', - { - requires: { - streamroller: { - RollingFileStream: function (file) { - fileOpened = file; - return { - on: function () { - }, - end: function () { - } - }; - } - } - } - } - ); - - fileAppender.configure( - { - filename: 'whatever.log', - maxLogSize: 10 - }, - { cwd: '/absolute/path/to' } - ); - return fileOpened; - }, - 'should prepend options.cwd to config.filename': function (fileOpened) { - const expected = path.sep + path.join('absolute', 'path', 'to', 'whatever.log'); - assert.equal(fileOpened, expected); - } - }, -}).export(module);