cocalc/src / smc-project / node_modules / broadway / node_modules / winston / test / winston-test.js
50659 views/*1* logger-test.js: Tests for instances of the winston Logger2*3* (C) 2010 Charlie Robbins4* MIT LICENSE5*6*/78var fs = require('fs'),9path = require('path'),10vows = require('vows'),11http = require('http'),12assert = require('assert'),13winston = require('../lib/winston'),14helpers = require('./helpers');1516vows.describe('winston').addBatch({17"The winston module": {18topic: function () {19winston.default.transports.console.level = 'silly';20return null;21},22"should have the correct methods defined": function () {23assert.isObject(winston.transports);24assert.isFunction(winston.Transport);25assert.isTrue(!winston.transports.Transport);26assert.isFunction(winston.transports.Console);27assert.isFunction(winston.transports.File);28assert.isFunction(winston.transports.Webhook);29assert.isObject(winston.default.transports.console);30assert.isFalse(winston.emitErrs);31assert.isObject(winston.config);32['Logger', 'add', 'remove', 'extend']33.concat(Object.keys(winston.config.npm.levels))34.forEach(function (key) {35assert.isFunction(winston[key]);36});37},38"it should": {39topic: function () {40fs.readFile(path.join(__dirname, '..', 'package.json'), this.callback);41},42"have the correct version set": function (err, data) {43assert.isNull(err);44data = JSON.parse(data.toString());45assert.equal(winston.version, data.version);46}47},48"the log() method": helpers.testNpmLevels(winston, "should respond without an error", function (err) {49assert.isNull(err);50}),51"the extend() method called on an empty object": {52topic: function (logger) {53var empty = {};54winston.extend(empty);55return empty;56},57"should define the appropriate methods": function (extended) {58['log', 'profile', 'startTimer'].concat(Object.keys(winston.config.npm.levels)).forEach(function (method) {59assert.isFunction(extended[method]);60});61}62}63}64}).addBatch({65"The winston module": {66"the setLevels() method": {67topic: function () {68winston.setLevels(winston.config.syslog.levels);69return null;70},71"should have the proper methods defined": function () {72assert.isObject(winston.transports);73assert.isFunction(winston.transports.Console);74assert.isFunction(winston.transports.Webhook);75assert.isObject(winston.default.transports.console);76assert.isFalse(winston.emitErrs);77assert.isObject(winston.config);7879var newLevels = Object.keys(winston.config.syslog.levels);80['Logger', 'add', 'remove', 'extend']81.concat(newLevels)82.forEach(function (key) {83assert.isFunction(winston[key]);84});858687Object.keys(winston.config.npm.levels)88.filter(function (key) {89return newLevels.indexOf(key) === -1;90})91.forEach(function (key) {92assert.isTrue(typeof winston[key] === 'undefined');93});94}95}96}97}).export(module);9899100