Skip to content

Commit

Permalink
Added test for hapijs#822
Browse files Browse the repository at this point in the history
  • Loading branch information
Eran Hammer committed May 6, 2013
1 parent 8fad5f1 commit 9703cbc
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/integration/response.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,36 @@ describe('Response', function () {
});
});

it('returns an JSONP response with path param', function (done) {

var handler = function () {

var parts = this.params.name.split('/');
this.reply({ first: parts[0], last: parts[1] });
};

var server = new Hapi.Server(0);
server.route({
method: 'GET',
path: '/user/{name*2}',
config: {
handler: handler,
jsonp: 'callback'
}
});

server.start(function () {

Request(server.info.uri + '/user/1/2?callback=docall', function (err, res, body) {

expect(err).to.not.exist;
expect(body).to.equal('docall({"first":"1","last":"2"});');
expect(res.headers['content-type']).to.equal('text/javascript; charset=utf-8');
done();
});
});
});

it('returns an JSONP response when response is a buffer', function (done) {

var handler = function (request) {
Expand Down

0 comments on commit 9703cbc

Please sign in to comment.