Skip to content

Commit

Permalink
Additional => conversions. For #2877
Browse files Browse the repository at this point in the history
  • Loading branch information
hueniverse committed Oct 25, 2015
1 parent a7b3ad7 commit ca3ee7e
Show file tree
Hide file tree
Showing 17 changed files with 1,498 additions and 1,325 deletions.
150 changes: 75 additions & 75 deletions test/auth.js

Large diffs are not rendered by default.

285 changes: 158 additions & 127 deletions test/connection.js

Large diffs are not rendered by default.

66 changes: 33 additions & 33 deletions test/cors.js

Large diffs are not rendered by default.

176 changes: 103 additions & 73 deletions test/handler.js

Large diffs are not rendered by default.

201 changes: 103 additions & 98 deletions test/methods.js

Large diffs are not rendered by default.

96 changes: 48 additions & 48 deletions test/payload.js

Large diffs are not rendered by default.

738 changes: 404 additions & 334 deletions test/plugin.js

Large diffs are not rendered by default.

38 changes: 20 additions & 18 deletions test/protect.js
Expand Up @@ -32,23 +32,23 @@ describe('Protect', () => {

const handler = function (request, reply) {

process.nextTick(function () {
process.nextTick(() => {

throw new Error('no domain');
});
};

server.route({ method: 'GET', path: '/', handler: handler });
const domain = Domain.createDomain();
domain.once('error', function (err) {
domain.once('error', (err) => {

expect(err.message).to.equal('no domain');
done();
});

domain.run(function () {
domain.run(() => {

server.inject('/', function (res) { });
server.inject('/', (res) => { });
});
});

Expand All @@ -60,14 +60,14 @@ describe('Protect', () => {
const handler = function (request, reply) {

reply('ok');
process.nextTick(function () {
process.nextTick(() => {

throw new Error('should not leave domain');
});
};

server.route({ method: 'GET', path: '/', handler: handler });
server.inject('/', function (res) {
server.inject('/', (res) => {

expect(res.statusCode).to.equal(200);
done();
Expand All @@ -83,19 +83,19 @@ describe('Protect', () => {

reply('ok');

process.nextTick(function () {
process.nextTick(() => {

throw new Error('should not leave domain 1');
});

process.nextTick(function () {
process.nextTick(() => {

throw new Error('should not leave domain 2');
});
};

server.route({ method: 'GET', path: '/', handler: handler });
server.inject('/', function (res) {
server.inject('/', (res) => {

expect(res.statusCode).to.equal(200);
done();
Expand All @@ -113,19 +113,21 @@ describe('Protect', () => {

const test = function (srv, options, next) {

srv.ext('onPreStart', function (plugin, afterNext) {
const preStart = function (plugin, afterNext) {

const client = new Client(); // Created in the global domain
plugin.bind({ client: client });
afterNext();
});
};

srv.ext('onPreStart', preStart);

srv.route({
method: 'GET',
path: '/',
handler: function (request, reply) {

this.client.on('event', request.domain.bind(function () {
this.client.on('event', request.domain.bind(() => {

throw new Error('boom'); // Caught by the global domain by default, not request domain
}));
Expand All @@ -143,14 +145,14 @@ describe('Protect', () => {

const server = new Hapi.Server({ debug: false });
server.connection();
server.register(test, function (err) {
server.register(test, (err) => {

expect(err).to.not.exist();

server.initialize(function (err) {
server.initialize((err) => {

expect(err).to.not.exist();
server.inject('/', function (res) {
server.inject('/', (res) => {

done();
});
Expand All @@ -163,7 +165,7 @@ describe('Protect', () => {
const handler = function (request, reply) {

reply('ok');
setTimeout(function () {
setTimeout(() => {

throw new Error('After done');
}, 10);
Expand All @@ -172,14 +174,14 @@ describe('Protect', () => {
const server = new Hapi.Server({ debug: false });
server.connection();

server.on('log', function (event, tags) {
server.on('log', (event, tags) => {

expect(tags.implementation).to.exist();
done();
});

server.route({ method: 'GET', path: '/', handler: handler });
server.inject('/', function (res) {
server.inject('/', (res) => {

expect(res.statusCode).to.equal(200);
});
Expand Down
58 changes: 29 additions & 29 deletions test/reply.js
Expand Up @@ -37,7 +37,7 @@ describe('Reply', () => {
const server = new Hapi.Server({ debug: false });
server.connection();
server.route({ method: 'GET', path: '/', handler: handler });
server.inject('/', function (res) {
server.inject('/', (res) => {

expect(res.statusCode).to.equal(500);
done();
Expand All @@ -54,7 +54,7 @@ describe('Reply', () => {
const server = new Hapi.Server();
server.connection();
server.route({ method: 'GET', path: '/', handler: handler });
server.inject('/', function (res) {
server.inject('/', (res) => {

expect(res.statusCode).to.equal(302);
expect(res.headers.location).to.equal('/elsewhere');
Expand All @@ -74,7 +74,7 @@ describe('Reply', () => {
const server = new Hapi.Server();
server.connection();
server.route({ method: 'GET', path: '/', handler: handler });
server.inject('/', function (res) {
server.inject('/', (res) => {

expect(res.statusCode).to.equal(200);
expect(res.result).to.equal('steve');
Expand All @@ -92,7 +92,7 @@ describe('Reply', () => {
const server = new Hapi.Server();
server.connection();
server.route({ method: 'GET', path: '/', handler: handler });
server.inject('/', function (res) {
server.inject('/', (res) => {

expect(res.statusCode).to.equal(400);
done();
Expand All @@ -109,7 +109,7 @@ describe('Reply', () => {
const server = new Hapi.Server();
server.connection();
server.route({ method: 'GET', path: '/', handler: handler });
server.inject('/', function (res) {
server.inject('/', (res) => {

expect(res.statusCode).to.equal(400);
done();
Expand All @@ -129,7 +129,7 @@ describe('Reply', () => {
const server = new Hapi.Server();
server.connection();
server.route({ method: 'GET', path: '/', handler: handler });
server.inject('/', function (res) {
server.inject('/', (res) => {

expect(res.statusCode).to.equal(200);
expect(res.result).to.equal(null);
Expand All @@ -150,7 +150,7 @@ describe('Reply', () => {
server.connection();
server.route({ method: 'GET', path: '/', config: { handler: handler } });

server.inject('/', function (res) {
server.inject('/', (res) => {

expect(res.statusCode).to.equal(299);
expect(res.result).to.equal('Tada1');
Expand All @@ -170,7 +170,7 @@ describe('Reply', () => {
server.connection();
server.route({ method: 'GET', path: '/', handler: handler });

server.inject('/', function (res) {
server.inject('/', (res) => {

expect(res.payload).to.equal('{\"a\":1,\"b\":2}');
expect(res.headers['content-length']).to.equal(13);
Expand All @@ -189,7 +189,7 @@ describe('Reply', () => {
server.connection();
server.route({ method: 'GET', path: '/', handler: handler });

server.inject('/', function (res) {
server.inject('/', (res) => {

expect(res.payload).to.equal('false');
done();
Expand All @@ -207,7 +207,7 @@ describe('Reply', () => {
server.connection();
server.route({ method: 'GET', path: '/', handler: handler });

server.inject('/', function (res) {
server.inject('/', (res) => {

expect(res.statusCode).to.equal(500);
expect(res.result).to.exist();
Expand All @@ -226,7 +226,7 @@ describe('Reply', () => {
server.connection();
server.route({ method: 'GET', path: '/', handler: handler });

server.inject('/', function (res) {
server.inject('/', (res) => {

expect(res.statusCode).to.equal(299);
expect(res.headers['content-length']).to.equal(0);
Expand Down Expand Up @@ -265,13 +265,13 @@ describe('Reply', () => {
server.connection();
server.route({ method: 'GET', path: '/stream', config: { handler: handler, cache: { expiresIn: 9999 } } });

server.inject('/stream', function (res1) {
server.inject('/stream', (res1) => {

expect(res1.result).to.equal('xy');
expect(res1.statusCode).to.equal(200);
expect(res1.headers['cache-control']).to.equal('max-age=2, must-revalidate');

server.inject({ method: 'HEAD', url: '/stream' }, function (res2) {
server.inject({ method: 'HEAD', url: '/stream' }, (res2) => {

expect(res2.result).to.equal('');
expect(res2.statusCode).to.equal(200);
Expand Down Expand Up @@ -305,23 +305,23 @@ describe('Reply', () => {
server.route({ method: 'GET', path: '/writable', handler: writableHandler });

let requestError;
server.on('request-error', function (request, err) {
server.on('request-error', (request, err) => {

requestError = err;
});

server.initialize(function (err) {
server.initialize((err) => {

expect(err).to.not.exist();

server.inject('/stream', function (res1) {
server.inject('/stream', (res1) => {

expect(res1.statusCode).to.equal(500);
expect(requestError).to.exist();
expect(requestError.message).to.equal('Stream must have a streams2 readable interface');

requestError = undefined;
server.inject('/writable', function (res2) {
server.inject('/writable', (res2) => {

expect(res2.statusCode).to.equal(500);
expect(requestError).to.exist();
Expand Down Expand Up @@ -349,11 +349,11 @@ describe('Reply', () => {
server.route({ method: 'GET', path: '/', handler: handler });
server.route({ method: 'GET', path: '/stream', handler: streamHandler });

server.initialize(function (err) {
server.initialize((err) => {

expect(err).to.not.exist();

server.inject('/stream', function (res) {
server.inject('/stream', (res) => {

expect(res.statusCode).to.equal(500);
done();
Expand Down Expand Up @@ -391,7 +391,7 @@ describe('Reply', () => {
server.connection();
server.route({ method: 'GET', path: '/', handler: handler });

server.inject('/', function (res) {
server.inject('/', (res) => {

expect(res.statusCode).to.equal(500);
done();
Expand Down Expand Up @@ -432,7 +432,7 @@ describe('Reply', () => {
server.connection();
server.route({ method: 'GET', path: '/stream', config: { handler: handler, cache: { expiresIn: 9999 } } });

server.inject('/stream', function (res) {
server.inject('/stream', (res) => {

expect(res.result).to.equal('xy');
expect(res.statusCode).to.equal(299);
Expand All @@ -451,7 +451,7 @@ describe('Reply', () => {
server.connection();
server.route({ method: 'GET', path: '/', handler: handler });

server.inject('/', function (res) {
server.inject('/', (res) => {

expect(res.statusCode).to.equal(299);
expect(res.result.toString()).to.equal('buffer content');
Expand All @@ -476,7 +476,7 @@ describe('Reply', () => {

server.route({ method: 'GET', path: '/domain', handler: handler });

server.inject('/domain', function (res) {
server.inject('/domain', (res) => {

expect(res.result).to.equal('123');
done();
Expand All @@ -491,15 +491,15 @@ describe('Reply', () => {
const handler = function (request, reply) {

const response = reply('123').hold();
setTimeout(function () {
setTimeout(() => {

response.send();
}, 10);
};

server.route({ method: 'GET', path: '/domain', handler: handler });

server.inject('/domain', function (res) {
server.inject('/domain', (res) => {

expect(res.result).to.equal('123');
done();
Expand All @@ -521,7 +521,7 @@ describe('Reply', () => {
server.connection();
server.route({ method: 'GET', path: '/', config: { handler: handler } });

server.inject('/', function (res) {
server.inject('/', (res) => {

expect(res.result).to.equal('');
done();
Expand All @@ -539,7 +539,7 @@ describe('Reply', () => {
server.connection();
server.route({ method: 'GET', path: '/', config: { handler: handler } });

server.inject('/', function (res) {
server.inject('/', (res) => {

expect(res.result).to.equal('');
done();
Expand All @@ -560,7 +560,7 @@ describe('Reply', () => {
server.connection();
server.route({ method: 'GET', path: '/', config: { handler: handler } });

server.inject('/', function (res) {
server.inject('/', (res) => {

expect(res.statusCode).to.equal(200);
expect(res.result).to.equal(null);
Expand Down Expand Up @@ -609,7 +609,7 @@ describe('Reply', () => {
}
});

server.inject('/', function (res) {
server.inject('/', (res) => {

expect(res.statusCode).to.equal(200);
expect(res.result).to.deep.equal({
Expand Down

0 comments on commit ca3ee7e

Please sign in to comment.