Sha256: e5414f75c84897367236484bdba5b383f7a2a7075406db9655862b295354f6fa

Contents?: true

Size: 1.71 KB

Versions: 26

Compression:

Stored size: 1.71 KB

Contents

/**
 * Module dependencies.
 */

var connect = require('connect'),
    helpers = require('./helpers'),
    assert = require('assert'),
    http = require('http');

module.exports = {
    test: function(){
        var logs = [];
        var fakeStream = { write: function(str){ logs.push(str); }};
        var orig = Date.prototype.toUTCString;
        Date.prototype.toUTCString = function(){
            return 'Thu, 27 May 2010 03:23:50 GMT';
        }
        var server = helpers.run(
            connect.logger({ stream: fakeStream }),
            require('./filters/uppercase')(),
            require('./providers/echo')()
        );

        var req = server.request('POST', '/', { 'User-Agent': 'ext-test', 'Referrer': 'http://google.com' });
        req.buffer = true
        req.addListener('response', function(res){
            res.addListener('end', function(){
                assert.equal('FOOBAR', res.body);
                assert.equal(
                    '127.0.0.1 - - [Thu, 27 May 2010 03:23:50 GMT] "POST / HTTP/1.1" 200 - "http://google.com" "ext-test"\n',
                    logs[0]);
                Date.prototype.toUTCString = orig;
            })
        })
        req.write('foobar');
        req.end();
    },
    
    'test custom format': function(){
        var logs = [];
        var fakeStream = { write: function(str){ logs.push(str); }};
        var server = helpers.run(
            connect.logger({ stream: fakeStream, format: ':method :url' }),
            require('./filters/uppercase')(),
            require('./providers/echo')()
        );
        server.assertResponse('GET', '/', 200, '', '', function(){
            assert.equal('GET /\n', logs[0], 'Test logger format option');
        });
    }
}

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
vulcan-0.8.2 server/node_modules/connect-form/support/connect/test/logger.test.js
vulcan-0.8.1 server/node_modules/connect-form/support/connect/test/logger.test.js
vulcan-0.8.0 server/node_modules/connect-form/support/connect/test/logger.test.js
vulcan-0.7.2 server/node_modules/connect-form/support/connect/test/logger.test.js
vulcan-0.7.1 server/node_modules/connect-form/support/connect/test/logger.test.js
vulcan-0.7.0 server/node_modules/connect-form/support/connect/test/logger.test.js
vulcan-0.6.1 server/node_modules/connect-form/support/connect/test/logger.test.js
vulcan-0.6.0 server/node_modules/connect-form/support/connect/test/logger.test.js
vulcan-0.5.0 server/node_modules/connect-form/support/connect/test/logger.test.js
vulcan-0.4.0 server/node_modules/connect-form/support/connect/test/logger.test.js
vulcan-0.3.0 server/node_modules/connect-form/support/connect/test/logger.test.js
vulcan-0.2.5 server/node_modules/connect-form/support/connect/test/logger.test.js
vulcan-0.2.4 server/node_modules/connect-form/support/connect/test/logger.test.js
vulcan-0.2.3 server/node_modules/connect-form/support/connect/test/logger.test.js
vulcan-0.2.2 server/node_modules/connect-form/support/connect/test/logger.test.js
vulcan-0.2.1 server/node_modules/connect-form/support/connect/test/logger.test.js
vulcan-0.2.0 server/node_modules/connect-form/support/connect/test/logger.test.js
vulcan-0.1.6 server/node_modules/connect-form/support/connect/test/logger.test.js
vulcan-0.1.5 server/node_modules/connect-form/support/connect/test/logger.test.js
vulcan-0.1.4 server/node_modules/connect-form/support/connect/test/logger.test.js