<commit_before>var assert = require('assert')
var sinon = require('sinon')
var ControllerFactory = require('./fixtures/controller')
var Stream = require('stream')
var Logging = require('../plugins/logging')

var Controller
var instance

var config = { name:'test', stream: new Stream }
config.stream.write = function(){}

describe('Logging', function() {

  beforeEach(function(done) {

    Controller = ControllerFactory.create()
    Controller.addPlugin(Logging, config)
    instance = ControllerFactory.init(Controller)

    done()
  })

  describe('Exists', function() {

    it('should add log method to controller', function(done) {
      assert(instance.log)
      done()
    })

    it('should add log method to request', function(done) {
      assert(instance.req.log)
      done()
    })

    it('should add log method to response', function(done) {
      assert(instance.res.log)
      done()
    })

    it('should log response on request finished', function(done) {
      instance.req.log.info = sinon.spy()
      instance.req.emit('finish')
      assert(instance.req.log.info.called)<commit_msg>updated logging test<commit_after>var assert = require('assert')
var sinon = require('sinon')
var ControllerFactory = require('./fixtures/controller')
var Stream = require('stream')
var Logging = require('../plugins/logging')

var Controller
var instance

var config = { name:'test', stream: new Stream }
config.stream.write = function(){}

describe('Logging', function() {

  beforeEach(function(done) {

    Controller = ControllerFactory.create()
    Controller.addPlugin(Logging, config)
    instance = ControllerFactory.init(Controller)

    done()
  })

  describe('Exists', function() {

    it('should add log method to controller', function(done) {
      assert(instance.log)
      done()
    })

    it('should add log method to request', function(done) {
      assert(instance.req.log)
      done()
    })

    it('should add log method to response', function(done) {
      assert(instance.res.log)
      done()
    })

    it('should log response on request finished', function(done) {
      instance.req.log.info = sinon.spy()
      assert(!instance.req.log.info.called)
      instance.req.emit('finish')
      assert(instance.req.log.info.called)
{'fraction_non_alphanumeric': 0.1388276773909211, 'fraction_numerical': 0.0, 'mean_word_length': 3.5766129032258065, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6471357', 'n_tokens_mistral': 655, 'n_tokens_neox': 635, 'n_words': 156}