diff --git a/test/application/context.js b/test/application/context.js
index c5fadf1..6446d77 100644
--- a/test/application/context.js
+++ b/test/application/context.js
@@ -12,23 +12,23 @@ describe('app.context', function(){
it('should merge properties', function(done){
app1.use(function *(next){
- assert.equal(this.msg, 'hello')
- this.status = 204
+ assert.equal(this.msg, 'hello');
+ this.status = 204;
});
request(app1.listen())
.get('/')
.expect(204, done);
- })
+ });
it('should not affect the original prototype', function(done){
app2.use(function *(next){
- assert.equal(this.msg, undefined)
+ assert.equal(this.msg, undefined);
this.status = 204;
});
request(app2.listen())
.get('/')
.expect(204, done);
- })
-})
+ });
+});
diff --git a/test/application/index.js b/test/application/index.js
index 32d4aea..f961b95 100644
--- a/test/application/index.js
+++ b/test/application/index.js
@@ -22,7 +22,7 @@ describe('app', function(){
request(app.listen())
.get('/')
.end(function(){});
- })
+ });
it('should not .writeHead when !socket.writable', function(done){
const app = new Koa();
@@ -36,7 +36,7 @@ describe('app', function(){
this.res.end = function(){
throw new Error('response sent');
};
- })
+ });
// hackish, but the response should occur in a single tick
setImmediate(done);
@@ -44,7 +44,7 @@ describe('app', function(){
request(app.listen())
.get('/')
.end(function(){});
- })
+ });
it('should set development env when NODE_ENV missing', function(){
const NODE_ENV = process.env.NODE_ENV;
@@ -52,5 +52,5 @@ describe('app', function(){
const app = new Koa();
process.env.NODE_ENV = NODE_ENV;
assert.equal(app.env, 'development');
- })
-})
+ });
+});
diff --git a/test/application/inspect.js b/test/application/inspect.js
index 68a156c..223eac7 100644
--- a/test/application/inspect.js
+++ b/test/application/inspect.js
@@ -7,6 +7,6 @@ describe('app.inspect()', function(){
it('should work', function(){
const app = new Koa();
const util = require('util');
- const str = util.inspect(app);
- })
-})
+ util.inspect(app);
+ });
+});
diff --git a/test/application/onerror.js b/test/application/onerror.js
index 5ba438d..bb47026 100644
--- a/test/application/onerror.js
+++ b/test/application/onerror.js
@@ -9,17 +9,12 @@ describe('app.onerror(err)', function(){
it('should throw an error if a non-error is given', function(done){
const app = new Koa();
- try {
+ (function(){
app.onerror('foo');
-
- should.fail();
- } catch (err) {
- err.should.be.instanceOf(AssertionError);
- err.message.should.equal('non-error thrown: foo');
- }
+ }).should.throw(AssertionError, {message: 'non-error thrown: foo'});
done();
- })
+ });
it('should do nothing if status is 404', function(done){
const app = new Koa();
@@ -27,28 +22,28 @@ describe('app.onerror(err)', function(){
err.status = 404;
- const output = stderr.inspectSync(function() {
+ const output = stderr.inspectSync(function(){
app.onerror(err);
});
output.should.eql([]);
done();
- })
+ });
it('should do nothing if .silent', function(done){
const app = new Koa();
app.silent = true;
const err = new Error();
- const output = stderr.inspectSync(function() {
+ const output = stderr.inspectSync(function(){
app.onerror(err);
});
output.should.eql([]);
done();
- })
+ });
it('should log the error to stderr', function(done){
const app = new Koa();
@@ -57,14 +52,14 @@ describe('app.onerror(err)', function(){
const err = new Error();
err.stack = 'Foo';
- const output = stderr.inspectSync(function() {
+ const output = stderr.inspectSync(function(){
app.onerror(err);
});
- output.should.eql(["\n", " Foo\n", "\n"]);
+ output.should.eql(['\n', ' Foo\n', '\n']);
done();
- })
+ });
it('should use err.toString() instad of err.stack', function(done){
const app = new Koa();
@@ -73,12 +68,12 @@ describe('app.onerror(err)', function(){
const err = new Error('mock stack null');
err.stack = null;
- const output = stderr.inspectSync(function() {
+ const output = stderr.inspectSync(function(){
app.onerror(err);
});
- output.should.eql(["\n", " Error: mock stack null\n", "\n"]);
+ output.should.eql(['\n', ' Error: mock stack null\n', '\n']);
done();
- })
-})
+ });
+});
diff --git a/test/application/request.js b/test/application/request.js
index 4ad1c05..0dd8599 100644
--- a/test/application/request.js
+++ b/test/application/request.js
@@ -12,23 +12,23 @@ describe('app.request', function(){
it('should merge properties', function(done){
app1.use(function *(next){
- assert.equal(this.request.message, 'hello')
- this.status = 204
+ assert.equal(this.request.message, 'hello');
+ this.status = 204;
});
request(app1.listen())
.get('/')
.expect(204, done);
- })
+ });
it('should not affect the original prototype', function(done){
app2.use(function *(next){
- assert.equal(this.request.message, undefined)
+ assert.equal(this.request.message, undefined);
this.status = 204;
});
request(app2.listen())
.get('/')
.expect(204, done);
- })
-})
+ });
+});
diff --git a/test/application/respond.js b/test/application/respond.js
index bb9a35b..4ae26c0 100644
--- a/test/application/respond.js
+++ b/test/application/respond.js
@@ -21,8 +21,8 @@ describe('app.respond', function(){
setImmediate(function(){
res.setHeader('Content-Type', 'text/plain');
res.end('lol');
- })
- })
+ });
+ });
const server = app.listen();
@@ -31,8 +31,8 @@ describe('app.respond', function(){
.expect(200)
.expect('lol')
.end(done);
- })
- })
+ });
+ });
describe('when HEAD is used', function(){
it('should not respond with the body', function(done){
@@ -54,7 +54,7 @@ describe('app.respond', function(){
assert(0 == res.text.length);
done();
});
- })
+ });
it('should keep json headers', function(done){
const app = new Koa();
@@ -75,7 +75,7 @@ describe('app.respond', function(){
assert(0 == res.text.length);
done();
});
- })
+ });
it('should keep string headers', function(done){
const app = new Koa();
@@ -96,7 +96,7 @@ describe('app.respond', function(){
assert(0 == res.text.length);
done();
});
- })
+ });
it('should keep buffer headers', function(done){
const app = new Koa();
@@ -117,35 +117,35 @@ describe('app.respond', function(){
assert(0 == res.text.length);
done();
});
- })
+ });
it('should respond with a 404 if no body was set', function(done){
const app = new Koa();
app.use(function *(){
- })
+ });
const server = app.listen();
request(server)
.head('/')
.expect(404, done);
- })
+ });
it('should respond with a 200 if body = ""', function(done){
const app = new Koa();
app.use(function *(){
this.body = '';
- })
+ });
const server = app.listen();
request(server)
.head('/')
.expect(200, done);
- })
+ });
it('should not overwrite the content-type', function(done){
const app = new Koa();
@@ -153,7 +153,7 @@ describe('app.respond', function(){
app.use(function *(){
this.status = 200;
this.type = 'application/javascript';
- })
+ });
const server = app.listen();
@@ -161,8 +161,8 @@ describe('app.respond', function(){
.head('/')
.expect('content-type', /application\/javascript/)
.expect(200, done);
- })
- })
+ });
+ });
describe('when no middleware are present', function(){
it('should 404', function(done){
@@ -173,8 +173,8 @@ describe('app.respond', function(){
request(server)
.get('/')
.expect(404, done);
- })
- })
+ });
+ });
describe('when res has already been written to', function(){
it('should not cause an app error', function(done){
@@ -183,14 +183,14 @@ describe('app.respond', function(){
app.use(function *(next){
const res = this.res;
this.status = 200;
- res.setHeader("Content-Type", "text/html")
+ res.setHeader('Content-Type', 'text/html');
res.write('Hello');
setTimeout(function(){
- res.end("Goodbye")
+ res.end('Goodbye');
}, 0);
});
- const errorCaught = false;
+ let errorCaught = false;
app.on('error', function(err){
errorCaught = err;
@@ -206,7 +206,7 @@ describe('app.respond', function(){
if (errorCaught) return done(errorCaught);
done();
});
- })
+ });
it('should send the right body', function(done){
const app = new Koa();
@@ -214,10 +214,10 @@ describe('app.respond', function(){
app.use(function *(next){
const res = this.res;
this.status = 200;
- res.setHeader("Content-Type", "text/html")
+ res.setHeader('Content-Type', 'text/html');
res.write('Hello');
setTimeout(function(){
- res.end("Goodbye");
+ res.end('Goodbye');
}, 0);
});
@@ -227,8 +227,8 @@ describe('app.respond', function(){
.get('/')
.expect(200)
.expect('HelloGoodbye', done);
- })
- })
+ });
+ });
describe('when .body is missing', function(){
describe('with status=400', function(){
@@ -246,8 +246,8 @@ describe('app.respond', function(){
.expect(400)
.expect('Content-Length', 11)
.expect('Bad Request', done);
- })
- })
+ });
+ });
describe('with status=204', function(){
it('should respond without a body', function(done){
@@ -255,7 +255,7 @@ describe('app.respond', function(){
app.use(function *(){
this.status = 204;
- })
+ });
const server = app.listen();
@@ -268,9 +268,9 @@ describe('app.respond', function(){
res.header.should.not.have.property('content-type');
done();
- })
- })
- })
+ });
+ });
+ });
describe('with status=205', function(){
it('should respond without a body', function(done){
@@ -278,7 +278,7 @@ describe('app.respond', function(){
app.use(function *(){
this.status = 205;
- })
+ });
const server = app.listen();
@@ -291,9 +291,9 @@ describe('app.respond', function(){
res.header.should.not.have.property('content-type');
done();
- })
- })
- })
+ });
+ });
+ });
describe('with status=304', function(){
it('should respond without a body', function(done){
@@ -301,7 +301,7 @@ describe('app.respond', function(){
app.use(function *(){
this.status = 304;
- })
+ });
const server = app.listen();
@@ -314,18 +314,18 @@ describe('app.respond', function(){
res.header.should.not.have.property('content-type');
done();
- })
- })
- })
+ });
+ });
+ });
describe('with custom status=700', function(){
- it('should respond with the associated status message', function (done){
+ it('should respond with the associated status message', function(done){
const app = new Koa();
statuses['700'] = 'custom status';
app.use(function *(){
this.status = 700;
- })
+ });
const server = app.listen();
@@ -337,18 +337,18 @@ describe('app.respond', function(){
if (err) return done(err);
res.res.statusMessage.should.equal('custom status');
done();
- })
- })
- })
+ });
+ });
+ });
describe('with custom statusMessage=ok', function(){
- it('should respond with the custom status message', function (done){
+ it('should respond with the custom status message', function(done){
const app = new Koa();
app.use(function *(){
this.status = 200;
this.message = 'ok';
- })
+ });
const server = app.listen();
@@ -360,17 +360,17 @@ describe('app.respond', function(){
if (err) return done(err);
res.res.statusMessage.should.equal('ok');
done();
- })
- })
- })
+ });
+ });
+ });
- describe('with custom status without message', function (){
- it('should respond with the status code number', function (done){
+ describe('with custom status without message', function(){
+ it('should respond with the status code number', function(done){
const app = new Koa();
app.use(function *(){
this.res.statusCode = 701;
- })
+ });
const server = app.listen();
@@ -378,9 +378,9 @@ describe('app.respond', function(){
.get('/')
.expect(701)
.expect('701', done);
- })
- })
- })
+ });
+ });
+ });
describe('when .body is a null', function(){
it('should respond 204 by default', function(done){
@@ -388,7 +388,7 @@ describe('app.respond', function(){
app.use(function *(){
this.body = null;
- })
+ });
const server = app.listen();
@@ -401,8 +401,8 @@ describe('app.respond', function(){
res.header.should.not.have.property('content-type');
done();
- })
- })
+ });
+ });
it('should respond 204 with status=200', function(done){
const app = new Koa();
@@ -410,7 +410,7 @@ describe('app.respond', function(){
app.use(function *(){
this.status = 200;
this.body = null;
- })
+ });
const server = app.listen();
@@ -423,8 +423,8 @@ describe('app.respond', function(){
res.header.should.not.have.property('content-type');
done();
- })
- })
+ });
+ });
it('should respond 205 with status=205', function(done){
const app = new Koa();
@@ -432,7 +432,7 @@ describe('app.respond', function(){
app.use(function *(){
this.status = 205;
this.body = null;
- })
+ });
const server = app.listen();
@@ -445,8 +445,8 @@ describe('app.respond', function(){
res.header.should.not.have.property('content-type');
done();
- })
- })
+ });
+ });
it('should respond 304 with status=304', function(done){
const app = new Koa();
@@ -454,7 +454,7 @@ describe('app.respond', function(){
app.use(function *(){
this.status = 304;
this.body = null;
- })
+ });
const server = app.listen();
@@ -467,9 +467,9 @@ describe('app.respond', function(){
res.header.should.not.have.property('content-type');
done();
- })
- })
- })
+ });
+ });
+ });
describe('when .body is a string', function(){
it('should respond', function(done){
@@ -484,8 +484,8 @@ describe('app.respond', function(){
request(server)
.get('/')
.expect('Hello', done);
- })
- })
+ });
+ });
describe('when .body is a Buffer', function(){
it('should respond', function(done){
@@ -500,8 +500,8 @@ describe('app.respond', function(){
request(server)
.get('/')
.expect('Hello', done);
- })
- })
+ });
+ });
describe('when .body is a Stream', function(){
it('should respond', function(done){
@@ -524,7 +524,7 @@ describe('app.respond', function(){
res.body.should.eql(pkg);
done();
});
- })
+ });
it('should strip content-length when overwriting', function(done){
const app = new Koa();
@@ -546,8 +546,8 @@ describe('app.respond', function(){
res.should.not.have.header('Content-Length');
res.body.should.eql(pkg);
done();
- })
- })
+ });
+ });
it('should keep content-length if not overwritten', function(done){
const app = new Koa();
@@ -569,8 +569,8 @@ describe('app.respond', function(){
res.should.have.header('Content-Length');
res.body.should.eql(pkg);
done();
- })
- })
+ });
+ });
it('should keep content-length if overwritten with the same stream', function(done){
const app = new Koa();
@@ -594,8 +594,8 @@ describe('app.respond', function(){
res.should.have.header('Content-Length');
res.body.should.eql(pkg);
done();
- })
- })
+ });
+ });
it('should handle errors', function(done){
const app = new Koa();
@@ -612,7 +612,7 @@ describe('app.respond', function(){
.expect('Content-Type', 'text/plain; charset=utf-8')
.expect(404)
.end(done);
- })
+ });
it('should handle errors when no content status', function(done){
const app = new Koa();
@@ -627,8 +627,7 @@ describe('app.respond', function(){
request(server)
.get('/')
.expect(204, done);
- })
-
+ });
it('should handle all intermediate stream body errors', function(done){
const app = new Koa();
@@ -644,8 +643,8 @@ describe('app.respond', function(){
request(server)
.get('/')
.expect(404, done);
- })
- })
+ });
+ });
describe('when .body is an Object', function(){
it('should respond with json', function(done){
@@ -661,8 +660,8 @@ describe('app.respond', function(){
.get('/')
.expect('Content-Type', 'application/json; charset=utf-8')
.expect('{"hello":"world"}', done);
- })
- })
+ });
+ });
describe('when an error occurs', function(){
it('should emit "error" on the app', function(done){
@@ -680,7 +679,7 @@ describe('app.respond', function(){
request(app.listen())
.get('/')
.end(function(){});
- })
+ });
describe('with an .expose property', function(){
it('should expose the message', function(done){
@@ -697,8 +696,8 @@ describe('app.respond', function(){
.get('/')
.expect(403, 'sorry!')
.end(done);
- })
- })
+ });
+ });
describe('with a .status property', function(){
it('should respond with .status', function(done){
@@ -714,8 +713,8 @@ describe('app.respond', function(){
.get('/')
.expect(403, 'Forbidden')
.end(done);
- })
- })
+ });
+ });
it('should respond with 500', function(done){
const app = new Koa();
@@ -730,7 +729,7 @@ describe('app.respond', function(){
.get('/')
.expect(500, 'Internal Server Error')
.end(done);
- })
+ });
it('should be catchable', function(done){
const app = new Koa();
@@ -746,7 +745,6 @@ describe('app.respond', function(){
app.use(function *(next){
throw new Error('boom!');
- this.body = 'Oh no';
});
const server = app.listen();
@@ -755,8 +753,8 @@ describe('app.respond', function(){
.get('/')
.expect(200, 'Got error')
.end(done);
- })
- })
+ });
+ });
describe('when status and body property', function(){
it('should 200', function(done){
@@ -774,9 +772,9 @@ describe('app.respond', function(){
.get('/')
.expect(200)
.expect('hello', done);
- })
+ });
- it('should 204', function(done) {
+ it('should 204', function(done){
const app = new Koa();
app.use(function *(){
@@ -791,10 +789,10 @@ describe('app.respond', function(){
request(server)
.get('/')
.expect(204)
- .end(function (err, res) {
+ .end(function(err, res){
res.should.not.have.header('content-type');
done(err);
});
});
- })
-})
+ });
+});
diff --git a/test/application/response.js b/test/application/response.js
index 9675be0..f4840fb 100644
--- a/test/application/response.js
+++ b/test/application/response.js
@@ -12,23 +12,23 @@ describe('app.response', function(){
it('should merge properties', function(done){
app1.use(function *(next){
- assert.equal(this.response.msg, 'hello')
- this.status = 204
+ assert.equal(this.response.msg, 'hello');
+ this.status = 204;
});
request(app1.listen())
.get('/')
.expect(204, done);
- })
+ });
it('should not affect the original prototype', function(done){
app2.use(function *(next){
- assert.equal(this.response.msg, undefined)
+ assert.equal(this.response.msg, undefined);
this.status = 204;
});
request(app2.listen())
.get('/')
.expect(204, done);
- })
-})
+ });
+});
diff --git a/test/application/toJSON.js b/test/application/toJSON.js
index d76f948..44f4201 100644
--- a/test/application/toJSON.js
+++ b/test/application/toJSON.js
@@ -12,5 +12,5 @@ describe('app.toJSON()', function(){
subdomainOffset: 2,
env: 'test'
});
- })
-})
+ });
+});
diff --git a/test/application/use.js b/test/application/use.js
index 68f4123..ebf1eed 100644
--- a/test/application/use.js
+++ b/test/application/use.js
@@ -34,10 +34,10 @@ describe('app.use(fn)', function(){
.expect(404)
.end(function(err){
if (err) return done(err);
- calls.should.eql([1,2,3,4,5,6]);
+ calls.should.eql([1, 2, 3, 4, 5, 6]);
done();
});
- })
+ });
it('should error when a non-generator function is passed', function(){
const app = new Koa();
@@ -47,11 +47,11 @@ describe('app.use(fn)', function(){
} catch (err) {
err.message.should.equal('app.use() requires a generator function');
}
- })
+ });
it('should not error when a non-generator function is passed when .experimental=true', function(){
const app = new Koa();
app.experimental = true;
app.use(function(){});
- })
-})
+ });
+});
diff --git a/test/context/assert.js b/test/context/assert.js
index f7c86ae..d28812c 100644
--- a/test/context/assert.js
+++ b/test/context/assert.js
@@ -15,5 +15,5 @@ describe('ctx.assert(value, status)', function(){
assert(404 == err.status);
assert(err.expose);
}
- })
-})
+ });
+});
diff --git a/test/context/cookies.js b/test/context/cookies.js
index 77ecca5..0114e97 100644
--- a/test/context/cookies.js
+++ b/test/context/cookies.js
@@ -11,7 +11,7 @@ describe('ctx.cookies.set()', function(){
app.use(function *(next){
this.cookies.set('name', 'jon');
this.status = 204;
- })
+ });
const server = app.listen();
@@ -26,8 +26,8 @@ describe('ctx.cookies.set()', function(){
}).should.be.ok;
done();
- })
- })
+ });
+ });
describe('with .signed', function(){
describe('when no .keys are set', function(){
@@ -45,8 +45,8 @@ describe('ctx.cookies.set()', function(){
request(app.listen())
.get('/')
.expect('.keys required for signed cookies', done);
- })
- })
+ });
+ });
it('should send a signed cookie', function(done){
const app = new Koa();
@@ -56,7 +56,7 @@ describe('ctx.cookies.set()', function(){
app.use(function *(next){
this.cookies.set('name', 'jon', { signed: true });
this.status = 204;
- })
+ });
const server = app.listen();
@@ -77,7 +77,7 @@ describe('ctx.cookies.set()', function(){
}).should.be.ok;
done();
- })
- })
- })
-})
+ });
+ });
+ });
+});
diff --git a/test/context/inspect.js b/test/context/inspect.js
index dd0cf44..709d18f 100644
--- a/test/context/inspect.js
+++ b/test/context/inspect.js
@@ -9,5 +9,5 @@ describe('ctx.inspect()', function(){
const toJSON = ctx.toJSON(ctx);
toJSON.should.eql(ctx.inspect());
- })
-})
+ });
+});
diff --git a/test/context/onerror.js b/test/context/onerror.js
index 0ba5882..6f176dd 100644
--- a/test/context/onerror.js
+++ b/test/context/onerror.js
@@ -12,7 +12,7 @@ describe('ctx.onerror(err)', function(){
this.body = 'something else';
this.throw(418, 'boom');
- })
+ });
const server = app.listen();
@@ -22,7 +22,7 @@ describe('ctx.onerror(err)', function(){
.expect('Content-Type', 'text/plain; charset=utf-8')
.expect('Content-Length', '4')
.end(done);
- })
+ });
it('should unset all headers', function(done){
const app = new Koa();
@@ -33,7 +33,7 @@ describe('ctx.onerror(err)', function(){
this.body = 'response';
this.throw(418, 'boom');
- })
+ });
const server = app.listen();
@@ -49,8 +49,8 @@ describe('ctx.onerror(err)', function(){
res.headers.should.not.have.property('x-csrf-token');
done();
- })
- })
+ });
+ });
describe('when invalid err.status', function(){
describe('not number', function(){
@@ -62,7 +62,7 @@ describe('ctx.onerror(err)', function(){
const err = new Error('some error');
err.status = 'notnumber';
throw err;
- })
+ });
const server = app.listen();
@@ -71,8 +71,8 @@ describe('ctx.onerror(err)', function(){
.expect(500)
.expect('Content-Type', 'text/plain; charset=utf-8')
.expect('Internal Server Error', done);
- })
- })
+ });
+ });
describe('not http status code', function(){
it('should respond 500', function(done){
@@ -83,7 +83,7 @@ describe('ctx.onerror(err)', function(){
const err = new Error('some error');
err.status = 9999;
throw err;
- })
+ });
const server = app.listen();
@@ -92,17 +92,17 @@ describe('ctx.onerror(err)', function(){
.expect(500)
.expect('Content-Type', 'text/plain; charset=utf-8')
.expect('Internal Server Error', done);
- })
- })
- })
+ });
+ });
+ });
describe('when non-error thrown', function(){
it('should response non-error thrown message', function(done){
const app = new Koa();
app.use(function *(next){
- throw 'string error';
- })
+ throw 'string error'; // eslint-disable-line no-throw-literal
+ });
const server = app.listen();
@@ -111,6 +111,6 @@ describe('ctx.onerror(err)', function(){
.expect(500)
.expect('Content-Type', 'text/plain; charset=utf-8')
.expect('Internal Server Error', done);
- })
- })
-})
+ });
+ });
+});
diff --git a/test/context/state.js b/test/context/state.js
index 750ab4e..1c80d63 100644
--- a/test/context/state.js
+++ b/test/context/state.js
@@ -5,11 +5,11 @@ const request = require('supertest');
const assert = require('assert');
const Koa = require('../..');
-describe('ctx.state', function() {
- it('should provide a ctx.state namespace', function(done) {
+describe('ctx.state', function(){
+ it('should provide a ctx.state namespace', function(done){
const app = new Koa();
- app.use(function *() {
+ app.use(function *(){
assert.deepEqual(this.state, {});
});
@@ -19,5 +19,5 @@ describe('ctx.state', function() {
.get('/')
.expect(404)
.end(done);
- })
-})
+ });
+});
diff --git a/test/context/throw.js b/test/context/throw.js
index 1543d4a..224faa3 100644
--- a/test/context/throw.js
+++ b/test/context/throw.js
@@ -15,8 +15,8 @@ describe('ctx.throw(msg)', function(){
assert(!err.expose);
done();
}
- })
-})
+ });
+});
describe('ctx.throw(err)', function(){
it('should set .status to 500', function(done){
@@ -31,8 +31,8 @@ describe('ctx.throw(err)', function(){
assert(!err.expose);
done();
}
- })
-})
+ });
+});
describe('ctx.throw(err, status)', function(){
it('should throw the error and set .status', function(done){
@@ -47,8 +47,8 @@ describe('ctx.throw(err, status)', function(){
assert(true === err.expose);
done();
}
- })
-})
+ });
+});
describe('ctx.throw(status, err)', function(){
it('should throw the error and set .status', function(done){
@@ -63,8 +63,8 @@ describe('ctx.throw(status, err)', function(){
assert(true === err.expose);
done();
}
- })
-})
+ });
+});
describe('ctx.throw(msg, status)', function(){
it('should throw an error', function(done){
@@ -78,8 +78,8 @@ describe('ctx.throw(msg, status)', function(){
assert(true === err.expose);
done();
}
- })
-})
+ });
+});
describe('ctx.throw(status, msg)', function(){
it('should throw an error', function(done){
@@ -93,8 +93,8 @@ describe('ctx.throw(status, msg)', function(){
assert(true === err.expose);
done();
}
- })
-})
+ });
+});
describe('ctx.throw(status)', function(){
it('should throw an error', function(done){
@@ -108,7 +108,7 @@ describe('ctx.throw(status)', function(){
assert(true === err.expose);
done();
}
- })
+ });
describe('when not valid status', function(){
it('should not expose', function(done){
@@ -118,14 +118,14 @@ describe('ctx.throw(status)', function(){
const err = new Error('some error');
err.status = -1;
ctx.throw(err);
- } catch(err) {
+ } catch (err) {
assert('some error' == err.message);
assert(!err.expose);
done();
}
- })
- })
-})
+ });
+ });
+});
describe('ctx.throw(status, msg, props)', function(){
it('should mixin props', function(done){
@@ -140,7 +140,7 @@ describe('ctx.throw(status, msg, props)', function(){
assert(true === err.prop);
done();
}
- })
+ });
describe('when props include status', function(){
it('should be ignored', function(done){
@@ -158,9 +158,9 @@ describe('ctx.throw(status, msg, props)', function(){
assert(true === err.prop);
done();
}
- })
- })
-})
+ });
+ });
+});
describe('ctx.throw(msg, props)', function(){
it('should mixin props', function(done){
@@ -175,8 +175,8 @@ describe('ctx.throw(msg, props)', function(){
assert(true === err.prop);
done();
}
- })
-})
+ });
+});
describe('ctx.throw(status, props)', function(){
it('should mixin props', function(done){
@@ -191,8 +191,8 @@ describe('ctx.throw(status, props)', function(){
assert(true === err.prop);
done();
}
- })
-})
+ });
+});
describe('ctx.throw(err, props)', function(){
it('should mixin props', function(done){
@@ -207,5 +207,5 @@ describe('ctx.throw(err, props)', function(){
assert(true === err.prop);
done();
}
- })
-})
+ });
+});
diff --git a/test/context/toJSON.js b/test/context/toJSON.js
index e8441af..2acdeaf 100644
--- a/test/context/toJSON.js
+++ b/test/context/toJSON.js
@@ -33,5 +33,5 @@ describe('ctx.toJSON()', function(){
'content-length': '10'
}
});
- })
-})
+ });
+});
diff --git a/test/experimental/async.js b/test/experimental/async.js
index 631942e..4eacdc5 100644
--- a/test/experimental/async.js
+++ b/test/experimental/async.js
@@ -8,11 +8,11 @@
const request = require('supertest');
const Koa = require('../..');
-describe('.experimental=true', function () {
- it('should support async functions', function (done) {
+describe('.experimental=true', function(){
+ it('should support async functions', function(done){
const app = new Koa();
app.experimental = true;
- app.use(async function (next) {
+ app.use(async function (next){
const string = await Promise.resolve('asdf');
this.body = string;
});
@@ -21,5 +21,5 @@ describe('.experimental=true', function () {
.get('/')
.expect('asdf')
.expect(200, done);
- })
-})
+ });
+});
diff --git a/test/helpers/context.js b/test/helpers/context.js
index ede99c1..5b1e10f 100644
--- a/test/helpers/context.js
+++ b/test/helpers/context.js
@@ -8,16 +8,16 @@ module.exports = function(req, res){
const socket = new Stream.Duplex();
req = req || { headers: {}, socket: socket, __proto__: Stream.Readable.prototype };
res = res || { _headers: {}, socket: socket, __proto__: Stream.Writable.prototype };
- res.getHeader = function(k){ return res._headers[k.toLowerCase()] };
- res.setHeader = function(k, v){ res._headers[k.toLowerCase()] = v };
- res.removeHeader = function(k, v){ delete res._headers[k.toLowerCase()] };
+ res.getHeader = function(k){ return res._headers[k.toLowerCase()]; };
+ res.setHeader = function(k, v){ res._headers[k.toLowerCase()] = v; };
+ res.removeHeader = function(k, v){ delete res._headers[k.toLowerCase()]; };
return (new Koa()).createContext(req, res);
-}
+};
module.exports.request = function(req, res){
return module.exports(req, res).request;
-}
+};
module.exports.response = function(req, res){
return module.exports(req, res).response;
-}
+};
diff --git a/test/request/accepts.js b/test/request/accepts.js
index bcef845..bb19069 100644
--- a/test/request/accepts.js
+++ b/test/request/accepts.js
@@ -10,9 +10,9 @@ describe('ctx.accepts(types)', function(){
const ctx = context();
ctx.req.headers.accept = 'application/*;q=0.2, image/jpeg;q=0.8, text/html, text/plain';
ctx.accepts().should.eql(['text/html', 'text/plain', 'image/jpeg', 'application/*']);
- })
- })
- })
+ });
+ });
+ });
describe('with no valid types', function(){
describe('when Accept is populated', function(){
@@ -20,16 +20,16 @@ describe('ctx.accepts(types)', function(){
const ctx = context();
ctx.req.headers.accept = 'application/*;q=0.2, image/jpeg;q=0.8, text/html, text/plain';
ctx.accepts('image/png', 'image/tiff').should.be.false;
- })
- })
+ });
+ });
describe('when Accept is not populated', function(){
it('should return the first type', function(){
const ctx = context();
ctx.accepts('text/html', 'text/plain', 'image/jpeg', 'application/*').should.equal('text/html');
- })
- })
- })
+ });
+ });
+ });
describe('when extensions are given', function(){
it('should convert to mime types', function(){
@@ -40,8 +40,8 @@ describe('ctx.accepts(types)', function(){
ctx.accepts('txt').should.equal('txt');
ctx.accepts('.txt').should.equal('.txt');
ctx.accepts('png').should.be.false;
- })
- })
+ });
+ });
describe('when an array is given', function(){
it('should return the first match', function(){
@@ -49,8 +49,8 @@ describe('ctx.accepts(types)', function(){
ctx.req.headers.accept = 'text/plain, text/html';
ctx.accepts(['png', 'text', 'html']).should.equal('text');
ctx.accepts(['png', 'html']).should.equal('html');
- })
- })
+ });
+ });
describe('when multiple arguments are given', function(){
it('should return the first match', function(){
@@ -58,8 +58,8 @@ describe('ctx.accepts(types)', function(){
ctx.req.headers.accept = 'text/plain, text/html';
ctx.accepts('png', 'text', 'html').should.equal('text');
ctx.accepts('png', 'html').should.equal('html');
- })
- })
+ });
+ });
describe('when present in Accept as an exact match', function(){
it('should return the type', function(){
@@ -67,8 +67,8 @@ describe('ctx.accepts(types)', function(){
ctx.req.headers.accept = 'text/plain, text/html';
ctx.accepts('text/html').should.equal('text/html');
ctx.accepts('text/plain').should.equal('text/plain');
- })
- })
+ });
+ });
describe('when present in Accept as a type match', function(){
it('should return the type', function(){
@@ -77,8 +77,8 @@ describe('ctx.accepts(types)', function(){
ctx.accepts('text/html').should.equal('text/html');
ctx.accepts('text/plain').should.equal('text/plain');
ctx.accepts('image/png').should.equal('image/png');
- })
- })
+ });
+ });
describe('when present in Accept as a subtype match', function(){
it('should return the type', function(){
@@ -87,6 +87,6 @@ describe('ctx.accepts(types)', function(){
ctx.accepts('text/html').should.equal('text/html');
ctx.accepts('text/plain').should.equal('text/plain');
ctx.accepts('image/png').should.be.false;
- })
- })
-})
+ });
+ });
+});
diff --git a/test/request/acceptsCharsets.js b/test/request/acceptsCharsets.js
index 884157f..59fc1a4 100644
--- a/test/request/acceptsCharsets.js
+++ b/test/request/acceptsCharsets.js
@@ -10,9 +10,9 @@ describe('ctx.acceptsCharsets()', function(){
const ctx = context();
ctx.req.headers['accept-charset'] = 'utf-8, iso-8859-1;q=0.2, utf-7;q=0.5';
ctx.acceptsCharsets().should.eql(['utf-8', 'utf-7', 'iso-8859-1']);
- })
- })
- })
+ });
+ });
+ });
describe('with multiple arguments', function(){
describe('when Accept-Charset is populated', function(){
@@ -21,31 +21,31 @@ describe('ctx.acceptsCharsets()', function(){
const ctx = context();
ctx.req.headers['accept-charset'] = 'utf-8, iso-8859-1;q=0.2, utf-7;q=0.5';
ctx.acceptsCharsets('utf-7', 'utf-8').should.equal('utf-8');
- })
- })
+ });
+ });
describe('if no types match', function(){
it('should return false', function(){
const ctx = context();
ctx.req.headers['accept-charset'] = 'utf-8, iso-8859-1;q=0.2, utf-7;q=0.5';
ctx.acceptsCharsets('utf-16').should.be.false;
- })
- })
- })
+ });
+ });
+ });
describe('when Accept-Charset is not populated', function(){
it('should return the first type', function(){
const ctx = context();
ctx.acceptsCharsets('utf-7', 'utf-8').should.equal('utf-7');
- })
- })
- })
+ });
+ });
+ });
describe('with an array', function(){
it('should return the best fit', function(){
const ctx = context();
ctx.req.headers['accept-charset'] = 'utf-8, iso-8859-1;q=0.2, utf-7;q=0.5';
ctx.acceptsCharsets(['utf-7', 'utf-8']).should.equal('utf-8');
- })
- })
-})
+ });
+ });
+});
diff --git a/test/request/acceptsEncodings.js b/test/request/acceptsEncodings.js
index 4deceeb..95d187d 100644
--- a/test/request/acceptsEncodings.js
+++ b/test/request/acceptsEncodings.js
@@ -11,17 +11,17 @@ describe('ctx.acceptsEncodings()', function(){
ctx.req.headers['accept-encoding'] = 'gzip, compress;q=0.2';
ctx.acceptsEncodings().should.eql(['gzip', 'compress', 'identity']);
ctx.acceptsEncodings('gzip', 'compress').should.equal('gzip');
- })
- })
+ });
+ });
describe('when Accept-Encoding is not populated', function(){
it('should return identity', function(){
const ctx = context();
ctx.acceptsEncodings().should.eql(['identity']);
ctx.acceptsEncodings('gzip', 'deflate', 'identity').should.equal('identity');
- })
- })
- })
+ });
+ });
+ });
describe('with multiple arguments', function(){
it('should return the best fit', function(){
@@ -29,14 +29,14 @@ describe('ctx.acceptsEncodings()', function(){
ctx.req.headers['accept-encoding'] = 'gzip, compress;q=0.2';
ctx.acceptsEncodings('compress', 'gzip').should.eql('gzip');
ctx.acceptsEncodings('gzip', 'compress').should.eql('gzip');
- })
- })
+ });
+ });
describe('with an array', function(){
it('should return the best fit', function(){
const ctx = context();
ctx.req.headers['accept-encoding'] = 'gzip, compress;q=0.2';
ctx.acceptsEncodings(['compress', 'gzip']).should.eql('gzip');
- })
- })
-})
+ });
+ });
+});
diff --git a/test/request/acceptsLanguages.js b/test/request/acceptsLanguages.js
index 3488dba..d7f0826 100644
--- a/test/request/acceptsLanguages.js
+++ b/test/request/acceptsLanguages.js
@@ -10,9 +10,9 @@ describe('ctx.acceptsLanguages(langs)', function(){
const ctx = context();
ctx.req.headers['accept-language'] = 'en;q=0.8, es, pt';
ctx.acceptsLanguages().should.eql(['es', 'pt', 'en']);
- })
- })
- })
+ });
+ });
+ });
describe('with multiple arguments', function(){
describe('when Accept-Language is populated', function(){
@@ -21,31 +21,31 @@ describe('ctx.acceptsLanguages(langs)', function(){
const ctx = context();
ctx.req.headers['accept-language'] = 'en;q=0.8, es, pt';
ctx.acceptsLanguages('es', 'en').should.equal('es');
- })
- })
+ });
+ });
describe('if no types match', function(){
it('should return false', function(){
const ctx = context();
ctx.req.headers['accept-language'] = 'en;q=0.8, es, pt';
ctx.acceptsLanguages('fr', 'au').should.be.false;
- })
- })
- })
+ });
+ });
+ });
describe('when Accept-Language is not populated', function(){
it('should return the first type', function(){
const ctx = context();
ctx.acceptsLanguages('es', 'en').should.equal('es');
- })
- })
- })
+ });
+ });
+ });
describe('with an array', function(){
it('should return the best fit', function(){
const ctx = context();
ctx.req.headers['accept-language'] = 'en;q=0.8, es, pt';
ctx.acceptsLanguages(['es', 'en']).should.equal('es');
- })
- })
-})
+ });
+ });
+});
diff --git a/test/request/charset.js b/test/request/charset.js
index c4bd78b..a089b0c 100644
--- a/test/request/charset.js
+++ b/test/request/charset.js
@@ -9,22 +9,22 @@ describe('req.charset', function(){
it('should return ""', function(){
const req = request();
assert('' === req.charset);
- })
- })
+ });
+ });
describe('with charset present', function(){
it('should return ""', function(){
const req = request();
req.header['content-type'] = 'text/plain';
assert('' === req.charset);
- })
- })
+ });
+ });
describe('with a charset', function(){
it('should return the charset', function(){
const req = request();
req.header['content-type'] = 'text/plain; charset=utf-8';
req.charset.should.equal('utf-8');
- })
- })
-})
+ });
+ });
+});
diff --git a/test/request/fresh.js b/test/request/fresh.js
index 65a99b3..a1e8655 100644
--- a/test/request/fresh.js
+++ b/test/request/fresh.js
@@ -4,13 +4,13 @@
const context = require('../helpers/context');
describe('ctx.fresh', function(){
- describe('the request method is not GET and HEAD', function (){
- it('should return false', function (){
+ describe('the request method is not GET and HEAD', function(){
+ it('should return false', function(){
const ctx = context();
ctx.req.method = 'POST';
ctx.fresh.should.be.false;
- })
- })
+ });
+ });
describe('the response is non-2xx', function(){
it('should return false', function(){
@@ -20,7 +20,7 @@ describe('ctx.fresh', function(){
ctx.req.headers['if-none-match'] = '123';
ctx.set('ETag', '123');
ctx.fresh.should.be.false;
- })
+ });
});
describe('the response is 2xx', function(){
@@ -32,8 +32,8 @@ describe('ctx.fresh', function(){
ctx.req.headers['if-none-match'] = '123';
ctx.set('ETag', '123');
ctx.fresh.should.be.true;
- })
- })
+ });
+ });
describe('and etag do not match', function(){
it('should return false', function(){
@@ -43,7 +43,7 @@ describe('ctx.fresh', function(){
ctx.req.headers['if-none-match'] = '123';
ctx.set('ETag', 'hey');
ctx.fresh.should.be.false;
- })
- })
- })
-})
+ });
+ });
+ });
+});
diff --git a/test/request/get.js b/test/request/get.js
index fd52d0e..b9f611e 100644
--- a/test/request/get.js
+++ b/test/request/get.js
@@ -13,5 +13,5 @@ describe('ctx.get(name)', function(){
ctx.get('host').should.equal('http://google.com');
ctx.get('referer').should.equal('http://google.com');
ctx.get('referrer').should.equal('http://google.com');
- })
-})
+ });
+});
diff --git a/test/request/header.js b/test/request/header.js
index 94d3581..96e68fc 100644
--- a/test/request/header.js
+++ b/test/request/header.js
@@ -7,5 +7,5 @@ describe('req.header', function(){
it('should return the request header object', function(){
const req = request();
req.header.should.equal(req.req.headers);
- })
-})
+ });
+});
diff --git a/test/request/headers.js b/test/request/headers.js
index 9820d80..d3c5d04 100644
--- a/test/request/headers.js
+++ b/test/request/headers.js
@@ -7,5 +7,5 @@ describe('req.headers', function(){
it('should return the request header object', function(){
const req = request();
req.headers.should.equal(req.req.headers);
- })
-})
+ });
+});
diff --git a/test/request/host.js b/test/request/host.js
index 1fe7319..fea18ac 100644
--- a/test/request/host.js
+++ b/test/request/host.js
@@ -9,33 +9,33 @@ describe('req.host', function(){
const req = request();
req.header.host = 'foo.com:3000';
req.host.should.equal('foo.com:3000');
- })
+ });
describe('with no host present', function(){
it('should return ""', function(){
const req = request();
assert.equal(req.host, '');
- })
- })
+ });
+ });
describe('when X-Forwarded-Host is present', function(){
describe('and proxy is not trusted', function(){
it('should be ignored', function(){
const req = request();
req.header['x-forwarded-host'] = 'bar.com';
- req.header['host'] = 'foo.com';
+ req.header.host = 'foo.com';
req.host.should.equal('foo.com');
- })
- })
+ });
+ });
describe('and proxy is trusted', function(){
it('should be used', function(){
const req = request();
req.app.proxy = true;
req.header['x-forwarded-host'] = 'bar.com, baz.com';
- req.header['host'] = 'foo.com';
+ req.header.host = 'foo.com';
req.host.should.equal('bar.com');
- })
- })
- })
-})
+ });
+ });
+ });
+});
diff --git a/test/request/hostname.js b/test/request/hostname.js
index 9e93aaa..0b01681 100644
--- a/test/request/hostname.js
+++ b/test/request/hostname.js
@@ -9,33 +9,33 @@ describe('req.hostname', function(){
const req = request();
req.header.host = 'foo.com:3000';
req.hostname.should.equal('foo.com');
- })
+ });
describe('with no host present', function(){
it('should return ""', function(){
const req = request();
assert.equal(req.hostname, '');
- })
- })
+ });
+ });
describe('when X-Forwarded-Host is present', function(){
describe('and proxy is not trusted', function(){
it('should be ignored', function(){
const req = request();
req.header['x-forwarded-host'] = 'bar.com';
- req.header['host'] = 'foo.com';
- req.hostname.should.equal('foo.com')
- })
- })
+ req.header.host = 'foo.com';
+ req.hostname.should.equal('foo.com');
+ });
+ });
describe('and proxy is trusted', function(){
it('should be used', function(){
const req = request();
req.app.proxy = true;
req.header['x-forwarded-host'] = 'bar.com, baz.com';
- req.header['host'] = 'foo.com';
- req.hostname.should.equal('bar.com')
- })
- })
- })
-})
+ req.header.host = 'foo.com';
+ req.hostname.should.equal('bar.com');
+ });
+ });
+ });
+});
diff --git a/test/request/href.js b/test/request/href.js
index 27b916f..84c8498 100644
--- a/test/request/href.js
+++ b/test/request/href.js
@@ -22,29 +22,29 @@ describe('ctx.href', function(){
// change it also work
ctx.url = '/foo/users/1?next=/dashboard';
ctx.href.should.equal('http://localhost/users/1?next=/dashboard');
- })
+ });
it('should work with `GET http://example.com/foo`', function(done){
- const app = new Koa()
- app.use(function* (){
- this.body = this.href
- })
+ const app = new Koa();
+ app.use(function *(){
+ this.body = this.href;
+ });
app.listen(function(){
- const address = this.address()
+ const address = this.address();
http.get({
host: 'localhost',
path: 'http://example.com/foo',
port: address.port
}, function(res){
- res.statusCode.should.equal(200)
- var buf = ''
- res.setEncoding('utf8')
- res.on('data', function(s){ buf += s })
+ res.statusCode.should.equal(200);
+ var buf = '';
+ res.setEncoding('utf8');
+ res.on('data', function(s){ buf += s; });
res.on('end', function(){
- buf.should.equal('http://example.com/foo')
- done()
- })
- })
- })
- })
-})
+ buf.should.equal('http://example.com/foo');
+ done();
+ });
+ });
+ });
+ });
+});
diff --git a/test/request/idempotent.js b/test/request/idempotent.js
index 036755f..626d8cd 100644
--- a/test/request/idempotent.js
+++ b/test/request/idempotent.js
@@ -4,22 +4,22 @@
const request = require('../helpers/context').request;
describe('ctx.idempotent', function(){
- describe('when the request method is idempotent', function (){
- it('should return true', function (){
+ describe('when the request method is idempotent', function(){
+ it('should return true', function(){
['GET', 'HEAD', 'PUT', 'DELETE', 'OPTIONS', 'TRACE'].forEach(check);
- function check(method) {
+ function check(method){
const req = request();
req.method = method;
req.idempotent.should.equal(true);
}
- })
- })
+ });
+ });
describe('when the request method is not idempotent', function(){
- it('should return false', function (){
+ it('should return false', function(){
const req = request();
req.method = 'POST';
req.idempotent.should.equal(false);
- })
- })
-})
+ });
+ });
+});
diff --git a/test/request/inspect.js b/test/request/inspect.js
index 2d5dd8c..77c9348 100644
--- a/test/request/inspect.js
+++ b/test/request/inspect.js
@@ -11,8 +11,8 @@ describe('req.inspect()', function(){
req.method = 'GET';
delete req.req;
assert(null == req.inspect());
- })
- })
+ });
+ });
it('should return a json representation', function(){
const req = request();
@@ -27,5 +27,5 @@ describe('req.inspect()', function(){
host: 'example.com'
}
});
- })
-})
+ });
+});
diff --git a/test/request/ip.js b/test/request/ip.js
index 0169167..c1f33f7 100644
--- a/test/request/ip.js
+++ b/test/request/ip.js
@@ -11,22 +11,22 @@ describe('req.ip', function(){
req.header['x-forwarded-for'] = '127.0.0.1';
req.socket.remoteAddress = '127.0.0.2';
req.ip.should.equal('127.0.0.1');
- })
- })
+ });
+ });
describe('with no req.ips present', function(){
it('should return req.socket.remoteAddress', function(){
const req = request();
req.socket.remoteAddress = '127.0.0.2';
req.ip.should.equal('127.0.0.2');
- })
+ });
describe('with req.socket.remoteAddress not present', function(){
it('should return an empty string', function(){
const req = request();
req.socket.remoteAddress = null;
req.ip.should.equal('');
- })
- })
- })
-})
+ });
+ });
+ });
+});
diff --git a/test/request/ips.js b/test/request/ips.js
index 4f41cc0..dd2ea70 100644
--- a/test/request/ips.js
+++ b/test/request/ips.js
@@ -11,8 +11,8 @@ describe('req.ips', function(){
req.app.proxy = false;
req.header['x-forwarded-for'] = '127.0.0.1,127.0.0.2';
req.ips.should.eql([]);
- })
- })
+ });
+ });
describe('and proxy is trusted', function(){
it('should be used', function(){
@@ -20,7 +20,7 @@ describe('req.ips', function(){
req.app.proxy = true;
req.header['x-forwarded-for'] = '127.0.0.1,127.0.0.2';
req.ips.should.eql(['127.0.0.1', '127.0.0.2']);
- })
- })
- })
-})
+ });
+ });
+ });
+});
diff --git a/test/request/is.js b/test/request/is.js
index 9592ac4..67d69fb 100644
--- a/test/request/is.js
+++ b/test/request/is.js
@@ -2,7 +2,6 @@
'use strict';
const context = require('../helpers/context');
-const should = require('should');
const assert = require('assert');
describe('ctx.is(type)', function(){
@@ -12,7 +11,7 @@ describe('ctx.is(type)', function(){
ctx.header['transfer-encoding'] = 'chunked';
ctx.is('text/*').should.equal('text/html');
- })
+ });
describe('when no body is given', function(){
it('should return null', function(){
@@ -21,8 +20,8 @@ describe('ctx.is(type)', function(){
assert(null == ctx.is());
assert(null == ctx.is('image/*'));
assert(null == ctx.is('image/*', 'text/*'));
- })
- })
+ });
+ });
describe('when no content type is given', function(){
it('should return false', function(){
@@ -32,8 +31,8 @@ describe('ctx.is(type)', function(){
ctx.is().should.be.false;
ctx.is('image/*').should.be.false;
ctx.is('text/*', 'image/*').should.be.false;
- })
- })
+ });
+ });
describe('give no types', function(){
it('should return the mime type', function(){
@@ -42,8 +41,8 @@ describe('ctx.is(type)', function(){
ctx.header['transfer-encoding'] = 'chunked';
ctx.is().should.equal('image/png');
- })
- })
+ });
+ });
describe('given one type', function(){
it('should return the type or false', function(){
@@ -62,8 +61,8 @@ describe('ctx.is(type)', function(){
ctx.is('image/jpeg').should.be.false;
ctx.is('text/*').should.be.false;
ctx.is('*/jpeg').should.be.false;
- })
- })
+ });
+ });
describe('given multiple types', function(){
it('should return the first match or false', function(){
@@ -87,8 +86,8 @@ describe('ctx.is(type)', function(){
ctx.is('.jpeg').should.be.false;
ctx.is('text/*', 'application/*').should.be.false;
ctx.is('text/html', 'text/plain', 'application/json; charset=utf-8').should.be.false;
- })
- })
+ });
+ });
describe('when Content-Type: application/x-www-form-urlencoded', function(){
it('should match "urlencoded"', function(){
@@ -99,6 +98,6 @@ describe('ctx.is(type)', function(){
ctx.is('urlencoded').should.equal('urlencoded');
ctx.is('json', 'urlencoded').should.equal('urlencoded');
ctx.is('urlencoded', 'json').should.equal('urlencoded');
- })
- })
-})
+ });
+ });
+});
diff --git a/test/request/length.js b/test/request/length.js
index 2df2118..270e028 100644
--- a/test/request/length.js
+++ b/test/request/length.js
@@ -9,10 +9,10 @@ describe('ctx.length', function(){
const req = request();
req.header['content-length'] = '10';
req.length.should.equal(10);
- })
+ });
describe('with no content-length present', function(){
const req = request();
assert(null == req.length);
- })
-})
+ });
+});
diff --git a/test/request/origin.js b/test/request/origin.js
index bfc0d1f..cdb319d 100644
--- a/test/request/origin.js
+++ b/test/request/origin.js
@@ -2,8 +2,6 @@
'use strict';
const Stream = require('stream');
-const http = require('http');
-const Koa = require('../../');
const context = require('../helpers/context');
describe('ctx.origin', function(){
@@ -22,5 +20,5 @@ describe('ctx.origin', function(){
// change it also work
ctx.url = '/foo/users/1?next=/dashboard';
ctx.origin.should.equal('http://localhost');
- })
-})
+ });
+});
diff --git a/test/request/path.js b/test/request/path.js
index cac7fe8..7935242 100644
--- a/test/request/path.js
+++ b/test/request/path.js
@@ -8,8 +8,8 @@ describe('ctx.path', function(){
const ctx = context();
ctx.url = '/login?next=/dashboard';
ctx.path.should.equal('/login');
- })
-})
+ });
+});
describe('ctx.path=', function(){
it('should set the pathname', function(){
@@ -19,7 +19,7 @@ describe('ctx.path=', function(){
ctx.path = '/logout';
ctx.path.should.equal('/logout');
ctx.url.should.equal('/logout?next=/dashboard');
- })
+ });
it('should change .url but not .originalUrl', function(){
const ctx = context({ url: '/login' });
@@ -27,5 +27,5 @@ describe('ctx.path=', function(){
ctx.url.should.equal('/logout');
ctx.originalUrl.should.equal('/login');
ctx.request.originalUrl.should.equal('/login');
- })
-})
+ });
+});
diff --git a/test/request/protocol.js b/test/request/protocol.js
index f35a2ab..329013a 100644
--- a/test/request/protocol.js
+++ b/test/request/protocol.js
@@ -9,16 +9,16 @@ describe('req.protocol', function(){
const req = request();
req.req.socket = { encrypted: true };
req.protocol.should.equal('https');
- })
- })
+ });
+ });
describe('when unencrypted', function(){
it('should return "http"', function(){
const req = request();
req.req.socket = {};
req.protocol.should.equal('http');
- })
- })
+ });
+ });
describe('when X-Forwarded-Proto is set', function(){
describe('and proxy is trusted', function(){
@@ -28,7 +28,7 @@ describe('req.protocol', function(){
req.req.socket = {};
req.header['x-forwarded-proto'] = 'https, http';
req.protocol.should.equal('https');
- })
+ });
describe('and X-Forwarded-Proto is empty', function(){
it('should return "http"', function(){
@@ -37,9 +37,9 @@ describe('req.protocol', function(){
req.req.socket = {};
req.header['x-forwarded-proto'] = '';
req.protocol.should.equal('http');
- })
- })
- })
+ });
+ });
+ });
describe('and proxy is not trusted', function(){
it('should not be used', function(){
@@ -47,7 +47,7 @@ describe('req.protocol', function(){
req.req.socket = {};
req.header['x-forwarded-proto'] = 'https, http';
req.protocol.should.equal('http');
- })
- })
- })
-})
+ });
+ });
+ });
+});
diff --git a/test/request/query.js b/test/request/query.js
index 3840dda..d2c02ca 100644
--- a/test/request/query.js
+++ b/test/request/query.js
@@ -8,21 +8,21 @@ describe('ctx.query', function(){
it('should return an empty object', function(){
const ctx = context({ url: '/' });
ctx.query.should.eql({});
- })
+ });
- it('should return the same object each time it\'s accessed', function(done) {
+ it('should return the same object each time it\'s accessed', function(done){
const ctx = context({ url: '/' });
ctx.query.a = '2';
ctx.query.a.should.equal('2');
done();
});
- })
+ });
it('should return a parsed query-string', function(){
const ctx = context({ url: '/?page=2' });
ctx.query.page.should.equal('2');
- })
-})
+ });
+});
describe('ctx.query=', function(){
it('should stringify and replace the querystring and search', function(){
@@ -30,8 +30,8 @@ describe('ctx.query=', function(){
ctx.query = { page: 2, color: 'blue' };
ctx.url.should.equal('/store/shoes?page=2&color=blue');
ctx.querystring.should.equal('page=2&color=blue');
- ctx.search.should.equal('?page=2&color=blue')
- })
+ ctx.search.should.equal('?page=2&color=blue');
+ });
it('should change .url but not .originalUrl', function(){
const ctx = context({ url: '/store/shoes' });
@@ -39,5 +39,5 @@ describe('ctx.query=', function(){
ctx.url.should.equal('/store/shoes?page=2');
ctx.originalUrl.should.equal('/store/shoes');
ctx.request.originalUrl.should.equal('/store/shoes');
- })
-})
+ });
+});
diff --git a/test/request/querystring.js b/test/request/querystring.js
index d1bfc3c..1bbeb71 100644
--- a/test/request/querystring.js
+++ b/test/request/querystring.js
@@ -7,16 +7,16 @@ describe('ctx.querystring', function(){
it('should return the querystring', function(){
const ctx = context({ url: '/store/shoes?page=2&color=blue' });
ctx.querystring.should.equal('page=2&color=blue');
- })
+ });
describe('when ctx.req not present', function(){
it('should return an empty string', function(){
const ctx = context();
ctx.request.req = null;
ctx.querystring.should.equal('');
- })
- })
-})
+ });
+ });
+});
describe('ctx.querystring=', function(){
it('should replace the querystring', function(){
@@ -24,7 +24,7 @@ describe('ctx.querystring=', function(){
ctx.querystring = 'page=2&color=blue';
ctx.url.should.equal('/store/shoes?page=2&color=blue');
ctx.querystring.should.equal('page=2&color=blue');
- })
+ });
it('should update ctx.search and ctx.query', function(){
const ctx = context({ url: '/store/shoes' });
@@ -35,7 +35,7 @@ describe('ctx.querystring=', function(){
page: '2',
color: 'blue'
});
- })
+ });
it('should change .url but not .originalUrl', function(){
const ctx = context({ url: '/store/shoes' });
@@ -43,5 +43,5 @@ describe('ctx.querystring=', function(){
ctx.url.should.equal('/store/shoes?page=2&color=blue');
ctx.originalUrl.should.equal('/store/shoes');
ctx.request.originalUrl.should.equal('/store/shoes');
- })
-})
+ });
+});
diff --git a/test/request/search.js b/test/request/search.js
index 2a744e7..35ee034 100644
--- a/test/request/search.js
+++ b/test/request/search.js
@@ -9,7 +9,7 @@ describe('ctx.search=', function(){
ctx.search = '?page=2&color=blue';
ctx.url.should.equal('/store/shoes?page=2&color=blue');
ctx.search.should.equal('?page=2&color=blue');
- })
+ });
it('should update ctx.querystring and ctx.query', function(){
const ctx = context({ url: '/store/shoes' });
@@ -20,7 +20,7 @@ describe('ctx.search=', function(){
page: '2',
color: 'blue'
});
- })
+ });
it('should change .url but not .originalUrl', function(){
const ctx = context({ url: '/store/shoes' });
@@ -28,12 +28,12 @@ describe('ctx.search=', function(){
ctx.url.should.equal('/store/shoes?page=2&color=blue');
ctx.originalUrl.should.equal('/store/shoes');
ctx.request.originalUrl.should.equal('/store/shoes');
- })
+ });
describe('when missing', function(){
it('should return ""', function(){
const ctx = context({ url: '/store/shoes' });
ctx.search.should.equal('');
- })
- })
-})
+ });
+ });
+});
diff --git a/test/request/secure.js b/test/request/secure.js
index d3bc7b2..9a186fe 100644
--- a/test/request/secure.js
+++ b/test/request/secure.js
@@ -8,5 +8,5 @@ describe('req.secure', function(){
const req = request();
req.req.socket = { encrypted: true };
req.secure.should.be.true;
- })
-})
+ });
+});
diff --git a/test/request/stale.js b/test/request/stale.js
index d729193..512827a 100644
--- a/test/request/stale.js
+++ b/test/request/stale.js
@@ -12,5 +12,5 @@ describe('req.stale', function(){
ctx.set('ETag', '"123"');
ctx.fresh.should.be.true;
ctx.stale.should.be.false;
- })
-})
+ });
+});
diff --git a/test/request/subdomains.js b/test/request/subdomains.js
index 9d2ccaa..38f4d0b 100644
--- a/test/request/subdomains.js
+++ b/test/request/subdomains.js
@@ -12,10 +12,10 @@ describe('req.subdomains', function(){
req.app.subdomainOffset = 3;
req.subdomains.should.eql(['tobi']);
- })
+ });
describe('with no host present', function(){
const req = request();
req.subdomains.should.eql([]);
- })
-})
+ });
+});
diff --git a/test/request/type.js b/test/request/type.js
index 9447b50..08dfa79 100644
--- a/test/request/type.js
+++ b/test/request/type.js
@@ -9,10 +9,10 @@ describe('req.type', function(){
const req = request();
req.header['content-type'] = 'text/html; charset=utf-8';
req.type.should.equal('text/html');
- })
+ });
describe('with no host present', function(){
const req = request();
assert('' === req.type);
- })
-})
+ });
+});
diff --git a/test/response/append.js b/test/response/append.js
index 3dc2246..f623733 100644
--- a/test/response/append.js
+++ b/test/response/append.js
@@ -9,17 +9,17 @@ describe('ctx.append(name, val)', function(){
ctx.append('x-foo', 'bar1');
ctx.append('x-foo', 'bar2');
ctx.response.header['x-foo'].should.eql(['bar1', 'bar2']);
- })
+ });
- it('should accept array of values', function (){
+ it('should accept array of values', function(){
const ctx = context();
ctx.append('Set-Cookie', ['foo=bar', 'fizz=buzz']);
ctx.append('Set-Cookie', 'hi=again');
ctx.response.header['set-cookie'].should.eql(['foo=bar', 'fizz=buzz', 'hi=again']);
- })
+ });
- it('should get reset by res.set(field, val)', function (){
+ it('should get reset by res.set(field, val)', function(){
const ctx = context();
ctx.append('Link', '