Skip to content

Commit 11b3645

Browse files
author
Eran Hammer
committed
Test for hapijs#2467
1 parent 5063415 commit 11b3645

File tree

1 file changed

+34
-9
lines changed

1 file changed

+34
-9
lines changed

test/connection.js

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ describe('Connection', function () {
507507
});
508508
});
509509

510-
it('refuses to handle new incoming requests', function (done) {
510+
it('refuses to handle new incoming requests', function (done) {
511511

512512
var server = new Hapi.Server();
513513
server.connection();
@@ -519,7 +519,7 @@ describe('Connection', function () {
519519

520520
Wreck.get('http://localhost:' + server.info.port + '/', { agent: agent }, function (err1, res, body) {
521521

522-
server.stop(function() {
522+
server.stop(function () {
523523

524524
expect(err1).to.not.exist();
525525
expect(body.toString()).to.equal('ok');
@@ -675,16 +675,16 @@ describe('Connection', function () {
675675

676676
it('returns the labels for the connections', function (done) {
677677

678-
var server = new Hapi.Server();
679-
server.connection({ labels: ['test'] });
678+
var server = new Hapi.Server();
679+
server.connection({ labels: ['test'] });
680680

681-
server.route({ path: '/test/', method: 'get', handler: function () { } });
682-
server.route({ path: '/test/{p}/end', method: 'get', handler: function () { } });
681+
server.route({ path: '/test/', method: 'get', handler: function () { } });
682+
server.route({ path: '/test/{p}/end', method: 'get', handler: function () { } });
683683

684-
var connection = server.table()[0];
684+
var connection = server.table()[0];
685685

686-
expect(connection.labels).to.only.include(['test']);
687-
done();
686+
expect(connection.labels).to.only.include(['test']);
687+
done();
688688
});
689689

690690
it('returns an array of the current routes (connection)', function (done) {
@@ -1076,6 +1076,31 @@ describe('Connection', function () {
10761076
cmd.stdin.end();
10771077
});
10781078
});
1079+
1080+
it('executes multiple extensions', function (done) {
1081+
1082+
var server = new Hapi.Server();
1083+
server.connection();
1084+
server.ext('onPreResponse', function (request, reply) {
1085+
1086+
request.response.source = request.response.source + '1';
1087+
return reply.continue();
1088+
});
1089+
1090+
server.ext('onPreResponse', function (request, reply) {
1091+
1092+
request.response.source = request.response.source + '2';
1093+
return reply.continue();
1094+
});
1095+
1096+
server.route({ method: 'GET', path: '/', handler: function (request, reply) { return reply('0'); } });
1097+
1098+
server.inject({ method: 'GET', url: '/' }, function (res) {
1099+
1100+
expect(res.result).to.equal('012');
1101+
done();
1102+
});
1103+
});
10791104
});
10801105
});
10811106

0 commit comments

Comments
 (0)