Sha256: 8ef615565e795c27b193c67ffb91b651cd319e8b4e5bdc44308bc428d89b425c

Contents?: true

Size: 1.21 KB

Versions: 11

Compression:

Stored size: 1.21 KB

Contents

/**
 * Module dependencies.
 */

var assert = require('assert')
  , http = require('http');

var server = http.createServer(function(req, res){
    if (req.method === 'GET') {
        if (req.url === '/delay') {
            setTimeout(function(){
                res.writeHead(200, {});
                res.end('delayed');
            }, 200);
        } else {
            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(done){
        assert.response(server, {
            url: '/',
            method: 'GET'
        },{
            body: '{"name":"tj"}',
            status: 200,
            headers: {
                'Content-Type': 'application/json; charset=utf8'
            }
        }, done);
    }
};

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
traceur-rb-0.0.1 vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/serial/http.test.js
vulcan-0.3.0 server/node_modules/express/node_modules/qs/support/expresso/test/serial/http.test.js
vulcan-0.1.6 server/node_modules/express/node_modules/qs/support/expresso/test/serial/http.test.js
vulcan-0.1.5 server/node_modules/express/node_modules/qs/support/expresso/test/serial/http.test.js
vulcan-0.1.4 server/node_modules/express/node_modules/qs/support/expresso/test/serial/http.test.js
vulcan-0.1.3 server/node_modules/express/node_modules/qs/support/expresso/test/serial/http.test.js
vulcan-0.1.2 server/node_modules/express/node_modules/qs/support/expresso/test/serial/http.test.js
vulcan-0.1.1 server/node_modules/express/node_modules/qs/support/expresso/test/serial/http.test.js
vulcan-0.1.0 server/node_modules/express/node_modules/qs/support/expresso/test/serial/http.test.js
vulcan-0.0.3 server/node_modules/express/node_modules/qs/support/expresso/test/serial/http.test.js
vulcan-0.0.2 server/node_modules/express/node_modules/qs/support/expresso/test/serial/http.test.js