Skip to content

Commit

Permalink
lint++
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanong committed Aug 18, 2021
1 parent 2cd6618 commit 3435e78
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 58 deletions.
2 changes: 1 addition & 1 deletion __tests__/request/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('req.header', () => {

it('should set the request header object', () => {
const req = request();
req.header = {'X-Custom-Headerfield': 'Its one header, with headerfields'};
req.header = { 'X-Custom-Headerfield': 'Its one header, with headerfields' };
assert.deepStrictEqual(req.header, req.req.headers);
});
});
2 changes: 1 addition & 1 deletion __tests__/request/headers.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('req.headers', () => {

it('should set the request header object', () => {
const req = request();
req.headers = {'X-Custom-Headerfield': 'Its one header, with headerfields'};
req.headers = { 'X-Custom-Headerfield': 'Its one header, with headerfields' };
assert.deepStrictEqual(req.headers, req.req.headers);
});
});
20 changes: 10 additions & 10 deletions __tests__/request/host.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ describe('req.host', () => {
describe('when less then HTTP/2', () => {
it('should not use :authority header', () => {
const req = request({
'httpVersionMajor': 1,
'httpVersion': '1.1'
httpVersionMajor: 1,
httpVersion: '1.1'
});
req.header[':authority'] = 'foo.com:3000';
req.header.host = 'bar.com:8000';
Expand All @@ -33,8 +33,8 @@ describe('req.host', () => {
describe('when HTTP/2', () => {
it('should use :authority header', () => {
const req = request({
'httpVersionMajor': 2,
'httpVersion': '2.0'
httpVersionMajor: 2,
httpVersion: '2.0'
});
req.header[':authority'] = 'foo.com:3000';
req.header.host = 'bar.com:8000';
Expand All @@ -43,8 +43,8 @@ describe('req.host', () => {

it('should use host header as fallback', () => {
const req = request({
'httpVersionMajor': 2,
'httpVersion': '2.0'
httpVersionMajor: 2,
httpVersion: '2.0'
});
req.header.host = 'bar.com:8000';
assert.strictEqual(req.host, 'bar.com:8000');
Expand All @@ -62,8 +62,8 @@ describe('req.host', () => {

it('should be ignored on HTTP/2', () => {
const req = request({
'httpVersionMajor': 2,
'httpVersion': '2.0'
httpVersionMajor: 2,
httpVersion: '2.0'
});
req.header['x-forwarded-host'] = 'proxy.com:8080';
req.header[':authority'] = 'foo.com:3000';
Expand All @@ -83,8 +83,8 @@ describe('req.host', () => {

it('should be used on HTTP/2', () => {
const req = request({
'httpVersionMajor': 2,
'httpVersion': '2.0'
httpVersionMajor: 2,
httpVersion: '2.0'
});
req.app.proxy = true;
req.header['x-forwarded-host'] = 'proxy.com:8080';
Expand Down
4 changes: 2 additions & 2 deletions __tests__/response/attachment.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ describe('ctx.attachment([filename])', () => {

app.use((ctx, next) => {
ctx.attachment('path/to/include-no-ascii-char-中文名-ok.json');
ctx.body = {foo: 'bar'};
ctx.body = { foo: 'bar' };
});

return request(app.callback())
.get('/')
.expect('content-disposition', 'attachment; filename="include-no-ascii-char-???-ok.json"; filename*=UTF-8\'\'include-no-ascii-char-%E4%B8%AD%E6%96%87%E5%90%8D-ok.json')
.expect({foo: 'bar'})
.expect({ foo: 'bar' })
.expect(200);
});
});
Expand Down
4 changes: 2 additions & 2 deletions __tests__/response/flushHeaders.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ describe('ctx.flushHeaders()', () => {
app.use(ctx => {
ctx.type = 'json';
ctx.status = 200;
ctx.headers['Link'] = '</css/mycss.css>; as=style; rel=preload, <https://img.craftflair.com>; rel=preconnect; crossorigin';
ctx.headers.Link = '</css/mycss.css>; as=style; rel=preload, <https://img.craftflair.com>; rel=preconnect; crossorigin';
const stream = ctx.body = new PassThrough();
ctx.flushHeaders();

Expand Down Expand Up @@ -134,7 +134,7 @@ describe('ctx.flushHeaders()', () => {
app.use(ctx => {
ctx.type = 'json';
ctx.status = 200;
ctx.headers['Link'] = '</css/mycss.css>; as=style; rel=preload, <https://img.craftflair.com>; rel=preconnect; crossorigin';
ctx.headers.Link = '</css/mycss.css>; as=style; rel=preload, <https://img.craftflair.com>; rel=preconnect; crossorigin';
ctx.length = 20;
ctx.flushHeaders();
const stream = ctx.body = new PassThrough();
Expand Down
4 changes: 2 additions & 2 deletions __tests__/response/set.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ describe('ctx.set(name, val)', () => {

it('should set a field value of array', () => {
const ctx = context();
ctx.set('x-foo', ['foo', 'bar', 123 ]);
assert.deepStrictEqual(ctx.response.header['x-foo'], [ 'foo', 'bar', '123' ]);
ctx.set('x-foo', ['foo', 'bar', 123]);
assert.deepStrictEqual(ctx.response.header['x-foo'], ['foo', 'bar', '123']);
});
});

Expand Down
4 changes: 2 additions & 2 deletions __tests__/response/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ describe('res.status=', () => {
describe('and HTTP/2', () => {
it('should not set the status message', () => {
const res = response({
'httpVersionMajor': 2,
'httpVersion': '2.0'
httpVersionMajor: 2,
httpVersion: '2.0'
});
res.status = 200;
assert(!res.res.statusMessage);
Expand Down
48 changes: 10 additions & 38 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3435e78

Please sign in to comment.