Permalink
Browse files

Fix space-before-blocks

  • Loading branch information...
1 parent 0d87e0e commit 2f205052edce82f89d34dda7c09454cdecd455f4 @bananaappletw bananaappletw committed Oct 20, 2016
View
@@ -2,7 +2,7 @@ var koa = require('koa');
var app = module.exports = koa();
-app.use(function *pageNotFound(next){
+app.use(function *pageNotFound(next) {
yield next;
if (404 != this.status) return;
View
@@ -2,9 +2,9 @@
var app = require('./app');
var request = require('supertest').agent(app.listen());
-describe('404', function(){
- describe('when GET /', function(){
- it('should return the 404 page', function(done){
+describe('404', function() {
+ describe('when GET /', function() {
+ it('should return the 404 page', function(done) {
request
.get('/')
.expect(404)
View
@@ -4,7 +4,7 @@ var app = module.exports = koa();
// custom 401 handling
-app.use(function* (next){
+app.use(function* (next) {
try {
yield next;
} catch (err) {
@@ -24,7 +24,7 @@ app.use(auth({ name: 'tj', pass: 'tobi' }));
// secret response
-app.use(function* (){
+app.use(function* () {
this.body = 'secret';
});
View
@@ -1,26 +1,26 @@
var app = require('./app');
var request = require('supertest').agent(app.listen());
-describe('Koa Basic Auth', function(){
- describe('with no credentials', function(){
- it('should `throw` 401', function(done){
+describe('Koa Basic Auth', function() {
+ describe('with no credentials', function() {
+ it('should `throw` 401', function(done) {
request
.get('/')
.expect(401, done);
})
})
- describe('with invalid credentials', function(){
- it('should `throw` 401', function(done){
+ describe('with invalid credentials', function() {
+ it('should `throw` 401', function(done) {
request
.get('/')
.auth('user', 'invalid password')
.expect(401, done);
})
})
- describe('with valid credentials', function(){
- it('should call the next middleware', function(done){
+ describe('with valid credentials', function() {
+ it('should call the next middleware', function(done) {
request
.get('/')
.auth('tj', 'tobi')
View
@@ -1,23 +1,23 @@
var app = require('./app');
var request = require('supertest').agent(app.listen());
-describe('Blog', function(){
- describe('GET /', function(){
- it('should see title "Posts"', function(done){
+describe('Blog', function() {
+ describe('GET /', function() {
+ it('should see title "Posts"', function(done) {
request
.get('/')
- .expect(200, function(err, res){
+ .expect(200, function(err, res) {
if (err) return done(err);
res.should.be.html;
res.text.should.include('<title>Posts</title>');
done();
});
});
- it('should see 0 post', function(done){
+ it('should see 0 post', function(done) {
request
.get('/')
- .expect(200, function(err, res){
+ .expect(200, function(err, res) {
if (err) return done(err);
res.should.be.html;
@@ -26,24 +26,24 @@ describe('Blog', function(){
});
});
});
- describe('POST /post/new', function(){
- it('should create post and redirect to /', function(done){
+ describe('POST /post/new', function() {
+ it('should create post and redirect to /', function(done) {
request
.post('/post')
.send({title: 'Title', body: 'Contents'})
- .end(function(err, res){
+ .end(function(err, res) {
if (err) return done(err);
res.header.location.should.be.equal('/')
done();
});
});
});
- describe('GET /post/0', function(){
- it('should see post', function(done){
+ describe('GET /post/0', function() {
+ it('should see post', function(done) {
request
.get('/post/0')
- .expect(200, function(err, res){
+ .expect(200, function(err, res) {
if (err) return done(err);
res.should.be.html;
View
@@ -8,7 +8,7 @@ var app = module.exports = koa();
// co-body accepts application/json
// and application/x-www-form-urlencoded
-app.use(function *(next){
+app.use(function *(next) {
if ('POST' != this.method) return yield next;
var body = yield parse(this, { limit: '1kb' });
if (!body.name) this.throw(400, '.name required');
View
@@ -1,10 +1,10 @@
var app = require('./app');
var request = require('supertest').agent(app.listen());
-describe('Body Parsing', function(){
- describe('POST /uppercase', function(){
- describe('with JSON', function(){
- it('should work', function(done){
+describe('Body Parsing', function() {
+ describe('POST /uppercase', function() {
+ describe('with JSON', function() {
+ it('should work', function(done) {
request
.post('/uppercase')
.send({ name: 'tobi' })
@@ -13,8 +13,8 @@ describe('Body Parsing', function(){
})
})
- describe('with urlencoded', function(){
- it('should work', function(done){
+ describe('with urlencoded', function() {
+ it('should work', function(done) {
request
.post('/uppercase')
.send('name=tj')
@@ -23,17 +23,17 @@ describe('Body Parsing', function(){
})
})
- describe('when length > limit', function(){
- it('should 413', function(done){
+ describe('when length > limit', function() {
+ it('should 413', function(done) {
request
.post('/json')
.send({ name: Array(5000).join('a') })
.expect(413, done);
})
})
- describe('when no name is sent', function(){
- it('should 400', function(done){
+ describe('when no name is sent', function() {
+ it('should 400', function(done) {
request
.post('/uppsercase')
.send('age=10')
View
@@ -18,7 +18,7 @@ var app = module.exports = koa();
// x-response-time
-function *responseTime(next){
+function *responseTime(next) {
var start = new Date();
yield next;
var ms = new Date() - start;
@@ -27,7 +27,7 @@ function *responseTime(next){
// logger
-function* logger(next){
+function* logger(next) {
var start = new Date();
yield next;
var ms = new Date() - start;
@@ -38,7 +38,7 @@ function* logger(next){
// response
-function* respond(next){
+function* respond(next) {
yield next;
if ('/' != this.url) return;
this.body = 'Hello World';
View
@@ -1,25 +1,25 @@
var app = require('./app');
var request = require('supertest').agent(app.listen());
-describe('Compose', function(){
- describe('when GET /', function(){
- it('should say "Hello World"', function(done){
+describe('Compose', function() {
+ describe('when GET /', function() {
+ it('should say "Hello World"', function(done) {
request
.get('/')
.expect(200)
.expect('Hello World', done);
})
- it('should set X-Response-Time', function(done){
+ it('should set X-Response-Time', function(done) {
request
.get('/')
.expect('X-Response-Time', /ms$/)
.expect(200, done);
})
})
- describe('when not GET /', function(){
- it('should 404', function(done){
+ describe('when not GET /', function() {
+ it('should 404', function(done) {
request
.get('/aklsjdf')
.expect(404, done);
@@ -8,7 +8,7 @@ var app = koa();
// middleware may "wrap" other middleware.
function ignoreAssets(mw) {
- return function *(next){
+ return function *(next) {
if (/(\.js|\.css|\.ico)$/.test(this.path)) {
yield next;
} else {
@@ -26,7 +26,7 @@ function ignoreAssets(mw) {
app.use(ignoreAssets(logger()));
-app.use(function *(){
+app.use(function *() {
this.body = 'Hello World';
});
View
@@ -6,7 +6,7 @@
var koa = require('koa');
var app = module.exports = koa();
-app.use(function *(){
+app.use(function *() {
var n = ~~this.cookies.get('view') + 1;
this.cookies.set('view', n);
this.body = n + ' views';
View
@@ -1,10 +1,10 @@
var app = require('./app');
var request = require('supertest').agent(app.listen());
-describe('Cookies Views', function(){
+describe('Cookies Views', function() {
[1, 2, 3].forEach(function(i) {
- describe('on iteration #' + i, function(){
- it('should set the views as a cookie and as the body', function(done){
+ describe('on iteration #' + i, function() {
+ it('should set the views as a cookie and as the body', function(done) {
request
.get('/')
.expect(200)
View
@@ -4,9 +4,9 @@ var request = require('supertest').agent(app.listen());
var token;
var cookie;
-describe('csrf', function(){
- describe('GET /token', function(){
- it('should get token', function(done){
+describe('csrf', function() {
+ describe('GET /token', function() {
+ it('should get token', function(done) {
request
.get('/token')
.expect(200)
View
@@ -4,7 +4,7 @@ var app = module.exports = koa();
// look ma, error propagation!
-app.use(function *(next){
+app.use(function *(next) {
try {
yield next;
} catch (err) {
@@ -24,13 +24,13 @@ app.use(function *(next){
// response
-app.use(function *(){
+app.use(function *() {
throw new Error('boom boom');
});
// error handler
-app.on('error', function(err){
+app.on('error', function(err) {
if (process.env.NODE_ENV != 'test') {
console.log('sent error %s to the cloud', err.message);
console.log(err);
View
@@ -2,14 +2,14 @@ var app = require('./app');
var request = require('supertest').agent(app.listen());
describe('Errors', function() {
- it('should catch the error', function(done){
+ it('should catch the error', function(done) {
request
.get('/')
.expect(500)
.expect('Content-Type', /text\/html/, done);
})
- it('should emit the error on app', function(done){
+ it('should emit the error on app', function(done) {
app.once('error', function(err, ctx) {
err.message.should.equal('boom boom');
ctx.should.be.ok;
@@ -18,6 +18,6 @@ describe('Errors', function() {
request
.get('/')
- .end(function(){});
+ .end(function() {});
})
})
@@ -13,7 +13,7 @@ var app = module.exports = koa();
app.keys = ['key1', 'key2'];
app.use(session(app));
-app.use(function *(next){
+app.use(function *(next) {
if (this.method !== 'GET' || this.path !== '/messages') return yield next;
// get any messages saved in the session
@@ -24,7 +24,7 @@ app.use(function *(next){
delete this.session.messages;
})
-app.use(function *(next){
+app.use(function *(next) {
if (this.method !== 'POST' || this.path !== '/messages') return yield next;
// the request string is the flash message
Oops, something went wrong.

0 comments on commit 2f20505

Please sign in to comment.