forked from koajs/examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request koajs#93 from bananaappletw/master
Add eslint
- Loading branch information
Showing
46 changed files
with
285 additions
and
259 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
env: | ||
mocha: true | ||
extends: standard | ||
plugins: | ||
- standard | ||
- promise | ||
rules: | ||
arrow-parens: 0 | ||
eqeqeq: 0 | ||
no-return-assign: 0 # fails for arrow functions | ||
semi: [2, always] | ||
space-before-function-paren: [2, never] | ||
yoda: 0 | ||
arrow-spacing: 2 | ||
dot-location: [2, "property"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
node_js: | ||
- "4" | ||
- "6" | ||
- "4" | ||
- "6" | ||
language: node_js | ||
script: | ||
make lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
lint: | ||
@./node_modules/.bin/eslint . | ||
|
||
test: | ||
@NODE_ENV=test ./node_modules/.bin/mocha \ | ||
--harmony \ | ||
--reporter spec \ | ||
--require should \ | ||
*/test.js | ||
|
||
.PHONY: test | ||
.PHONY: lint test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,31 @@ | ||
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') | ||
.expect(200) | ||
.expect('secret', done); | ||
}) | ||
}) | ||
}) | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,44 @@ | ||
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' }) | ||
.expect(200) | ||
.expect({ name: 'TOBI' }, done); | ||
}) | ||
}) | ||
}); | ||
}); | ||
|
||
describe('with urlencoded', function(){ | ||
it('should work', function(done){ | ||
describe('with urlencoded', function() { | ||
it('should work', function(done) { | ||
request | ||
.post('/uppercase') | ||
.send('name=tj') | ||
.expect(200) | ||
.expect({ name: 'TJ' }, done); | ||
}) | ||
}) | ||
|
||
}); | ||
}); | ||
|
||
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') | ||
.expect(400, done); | ||
}); | ||
}); | ||
}) | ||
}) | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.