Skip to content

Commit

Permalink
chore: fix README & update deps & fix test (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
atian25 authored and dead-horse committed Aug 8, 2017
1 parent e49252e commit a0d4df2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -42,9 +42,9 @@ exports.onerror = {
errorPageUrl: (err, ctx) => ctx.errorPageUrl || '/500',
};

// an accept detect function that mark all request with `x-request-with=XMLHttpRequest` header accepts json.
// an accept detect function that mark all request with `x-requested-with=XMLHttpRequest` header accepts json.
function accepts(ctx) {
if (ctx.get('x-request-with') === 'XMLHttpRequest') return 'json';
if (ctx.get('x-requested-with') === 'XMLHttpRequest') return 'json';
return 'html';
}
```
Expand Down
18 changes: 9 additions & 9 deletions package.json
Expand Up @@ -24,27 +24,27 @@
"cookie": "^0.3.1",
"koa-onerror": "^3.1.0",
"mustache": "^2.3.0",
"stack-trace": "0.0.10"
"stack-trace": "^0.0.10"
},
"devDependencies": {
"autod": "^2.8.0",
"egg": "^1.4.0",
"egg-bin": "^4.0.2",
"autod": "^2.9.0",
"egg": "^1.7.0",
"egg-bin": "^4.1.0",
"egg-ci": "^1.8.0",
"egg-mock": "^3.7.2",
"eslint": "^4.0.0",
"eslint-config-egg": "^4.2.1",
"egg-mock": "^3.9.0",
"eslint": "^4.4.1",
"eslint-config-egg": "^5.0.0",
"pedding": "^1.1.0",
"rimraf": "^2.6.1"
},
"engines": {
"node": ">=6.0.0"
},
"scripts": {
"test": "npm run lint && npm run test-local",
"test": "npm run lint -- --fix && npm run test-local",
"test-local": "egg-bin test",
"cov": "egg-bin cov",
"lint": "eslint --ext js --fix test config *.js",
"lint": "eslint .",
"ci": "npm run lint && npm run cov",
"autod": "autod"
},
Expand Down
6 changes: 3 additions & 3 deletions test/onerror.test.js
Expand Up @@ -96,12 +96,12 @@ describe('test/onerror.test.js', () => {

it('should support custom accpets return err.stack', () => {
mm(app.config.onerror, 'accepts', ctx => {
if (ctx.get('x-request-with') === 'XMLHttpRequest') return 'json';
if (ctx.get('x-requested-with') === 'XMLHttpRequest') return 'json';
return 'html';
});
return app.httpRequest()
.get('/user.json')
.set('x-request-with', 'XMLHttpRequest')
.set('x-requested-with', 'XMLHttpRequest')
.expect(/"message":"test error"/)
.expect(/"stack":/)
.expect(500);
Expand Down Expand Up @@ -236,7 +236,7 @@ describe('test/onerror.test.js', () => {
yield app.close();

const warnLog = path.join(__dirname, 'fixtures/onerror-4xx/logs/onerror-4xx/onerror-4xx-web.log');
assert(/POST \/body_parser] nodejs\.Error: request entity too large/.test(fs.readFileSync(warnLog, 'utf8')));
assert(/POST \/body_parser] nodejs\..*?Error: request entity too large/.test(fs.readFileSync(warnLog, 'utf8')));
});
}

Expand Down

0 comments on commit a0d4df2

Please sign in to comment.