2 * file-test.js: Tests for instances of the File transport
4 * (C) 2010 Charlie Robbins
9 var path = require('path'),
10 vows = require('vows'),
12 assert = require('assert'),
13 winston = require('../../lib/winston'),
14 helpers = require('../helpers');
16 var stream = fs.createWriteStream(path.join(__dirname, '..', 'fixtures', 'logs', 'testfile.log')),
17 fileTransport = new (winston.transports.File)({ filename: path.join(__dirname, '..', 'fixtures', 'logs', 'testfilename.log') }),
18 streamTransport = new (winston.transports.File)({ stream: stream });
20 vows.describe('winston/transports/file').addBatch({
21 "An instance of the File Transport": {
22 "when passed a valid filename": {
23 "should have the proper methods defined": function () {
24 helpers.assertFile(fileTransport);
26 "the log() method": helpers.testNpmLevels(fileTransport, "should respond with true", function (ign, err, logged) {
28 assert.isTrue(logged);
31 "when passed a valid file stream": {
32 "should have the proper methods defined": function () {
33 helpers.assertFile(streamTransport);
35 "the log() method": helpers.testNpmLevels(streamTransport, "should respond with true", function (ign, err, logged) {
37 assert.isTrue(logged);
42 "These tests have a non-deterministic end": {
44 setTimeout(this.callback, 200);
46 "and this should be fixed before releasing": function () {