Skip to content

Commit

Permalink
Fix space-before-blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
bananaappletw committed Oct 20, 2016
1 parent 0d87e0e commit 2f20505
Show file tree
Hide file tree
Showing 30 changed files with 112 additions and 112 deletions.
2 changes: 1 addition & 1 deletion 404/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions 404/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions base-auth/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -24,7 +24,7 @@ app.use(auth({ name: 'tj', pass: 'tobi' }));

// secret response

app.use(function* (){
app.use(function* () {
this.body = 'secret';
});

Expand Down
14 changes: 7 additions & 7 deletions base-auth/test.js
Original file line number Diff line number Diff line change
@@ -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')
Expand Down
24 changes: 12 additions & 12 deletions blog/test.js
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion body-parsing/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
20 changes: 10 additions & 10 deletions body-parsing/test.js
Original file line number Diff line number Diff line change
@@ -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' })
Expand All @@ -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')
Expand All @@ -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')
Expand Down
6 changes: 3 additions & 3 deletions compose/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -38,7 +38,7 @@ function* logger(next){

// response

function* respond(next){
function* respond(next) {
yield next;
if ('/' != this.url) return;
this.body = 'Hello World';
Expand Down
12 changes: 6 additions & 6 deletions compose/test.js
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
4 changes: 2 additions & 2 deletions conditional-middleware/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -26,7 +26,7 @@ function ignoreAssets(mw) {

app.use(ignoreAssets(logger()));

app.use(function *(){
app.use(function *() {
this.body = 'Hello World';
});

Expand Down
2 changes: 1 addition & 1 deletion cookies/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
6 changes: 3 additions & 3 deletions cookies/test.js
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
6 changes: 3 additions & 3 deletions csrf/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions errors/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions errors/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -18,6 +18,6 @@ describe('Errors', function() {

request
.get('/')
.end(function(){});
.end(function() {});
})
})
4 changes: 2 additions & 2 deletions flash-messages/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Loading

0 comments on commit 2f20505

Please sign in to comment.