Sha256: 263a6b951b89a3873747f4fc5318d0056b96b86fd962af316498d3cbc1d8fbe6

Contents?: true

Size: 1.49 KB

Versions: 26

Compression:

Stored size: 1.49 KB

Contents

/**
 * Module dependencies.
 */

var http = require('http');

var server = http.createServer(function(req, res){
    if (req.method === 'GET') {
        var body = JSON.stringify({ name: 'tj' });
        res.writeHead(200, {
            'Content-Type': 'application/json; charset=utf8',
            'Content-Length': body.length
        });
        res.end(body);
    } else {
        var body = '';
        req.setEncoding('utf8');
        req.addListener('data', function(chunk){ body += chunk });
        req.addListener('end', function(){
            res.writeHead(200, {});
            res.end(req.url + ' ' + body);
        });
    }
});

module.exports = {
    'test assert.response()': function(assert, beforeExit){
        assert.response(server, {
            url: '/',
            method: 'GET'
        },{
            body: '{"name":"tj"}',
            status: 200,
            headers: {
                'Content-Type': 'application/json; charset=utf8'
            }
        });
        
        assert.response(server, {
            url: '/foo',
            method: 'POST',
            data: 'bar baz'
        },{
            body: '/foo bar baz',
            status: 200
        });
        
        var called;
        assert.response(server, {
            url: '/foo'
        }, function(res){
            called = true;
            assert.ok(res.body.indexOf('tj') >= 0, 'Test assert.response() callback');
        });
        
        beforeExit(function(){
            assert.ok(called);
        });
    }
};

Version data entries

26 entries across 26 versions & 1 rubygems

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