Sha256: a5522a31e3099f5c9840d1a471e2e5c9427159d91a5ba2df1b08b0d45169ab77

Contents?: true

Size: 1.95 KB

Versions: 26

Compression:

Stored size: 1.95 KB

Contents

/**
 * Module dependencies.
 */

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

module.exports = {
    'test defaults': function(){
        var server = helpers.run(
            function(req, res, next){
                next(new Error('keyboard cat!'));
            },
            connect.errorHandler()
        );
        server.assertResponse('GET', '/', 500, 'Internal Server Error', 'Test error-handler defaults');
    },

    'test defaults with caught exception': function(){
        var server = helpers.run(
            function(req, res, next){
                throw new Error('keyboard cat!');
            },
            connect.errorHandler()
        );
        server.assertResponse('GET', '/', 500, 'Internal Server Error', 'Test error-handler defaults');
    },

    'test showMessage': function(){
        var server = helpers.run(
            function(req, res, next){
                next(new Error('keyboard cat!'));
            },
            connect.errorHandler({ showMessage: true })
        );
        server.assertResponse('GET', '/', 500, 'Error: keyboard cat!', 'Test error-handler showMessage');
    },

    'test showStack': function(){
        var server = helpers.run(
            function(req, res, next){
                next(new Error('keyboard cat!'));
            },
            connect.errorHandler({ showStack: true })
        );
        var req = server.request('GET', '/');
        req.buffer = true;
        req.addListener('response', function(res){
            res.addListener('end', function(){
                assert.equal(500, res.statusCode, 'Test error-handler 500 status code');
                assert.ok(res.body.indexOf('Error: keyboard cat!') !== -1, 'Test error-handler showStack message');
                assert.ok(res.body.indexOf('lib/connect/index.js') !== -1, 'Test error-handler showStack stack trace');
            })
        })
        req.end();
    }
}

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
vulcan-0.1.3 server/node_modules/connect-form/support/connect/test/errorHandler.test.js
vulcan-0.1.2 server/node_modules/connect-form/support/connect/test/errorHandler.test.js
vulcan-0.1.1 server/node_modules/connect-form/support/connect/test/errorHandler.test.js
vulcan-0.1.0 server/node_modules/connect-form/support/connect/test/errorHandler.test.js
vulcan-0.0.3 server/node_modules/connect-form/support/connect/test/errorHandler.test.js
vulcan-0.0.2 server/node_modules/connect-form/support/connect/test/errorHandler.test.js