diff --git a/test/application/context.js b/test/application/context.js index bd5b9cbf8..ec4bc1823 100644 --- a/test/application/context.js +++ b/test/application/context.js @@ -12,7 +12,7 @@ describe('app.context', () => { it('should merge properties', () => { app1.use((ctx, next) => { - assert.equal(ctx.msg, 'hello'); + assert.strictEqual(ctx.msg, 'hello'); ctx.status = 204; }); @@ -23,7 +23,7 @@ describe('app.context', () => { it('should not affect the original prototype', () => { app2.use((ctx, next) => { - assert.equal(ctx.msg, undefined); + assert.strictEqual(ctx.msg, undefined); ctx.status = 204; }); diff --git a/test/application/index.js b/test/application/index.js index ec5ea25b1..64037a001 100644 --- a/test/application/index.js +++ b/test/application/index.js @@ -15,7 +15,7 @@ describe('app', () => { }); app.on('error', err => { - assert.equal(err.message, 'boom'); + assert.strictEqual(err.message, 'boom'); done(); }); @@ -51,7 +51,7 @@ describe('app', () => { process.env.NODE_ENV = ''; const app = new Koa(); process.env.NODE_ENV = NODE_ENV; - assert.equal(app.env, 'development'); + assert.strictEqual(app.env, 'development'); }); it('should set env from the constructor', () => { diff --git a/test/application/inspect.js b/test/application/inspect.js index 799201ce0..73bd34d23 100644 --- a/test/application/inspect.js +++ b/test/application/inspect.js @@ -9,7 +9,7 @@ const app = new Koa(); describe('app.inspect()', () => { it('should work', () => { const str = util.inspect(app); - assert.equal("{ subdomainOffset: 2, proxy: false, env: 'test' }", str); + assert.strictEqual("{ subdomainOffset: 2, proxy: false, env: 'test' }", str); }); it('should return a json representation', () => { diff --git a/test/application/request.js b/test/application/request.js index c852f7fe6..3e79887c5 100644 --- a/test/application/request.js +++ b/test/application/request.js @@ -12,7 +12,7 @@ describe('app.request', () => { it('should merge properties', () => { app1.use((ctx, next) => { - assert.equal(ctx.request.message, 'hello'); + assert.strictEqual(ctx.request.message, 'hello'); ctx.status = 204; }); @@ -23,7 +23,7 @@ describe('app.request', () => { it('should not affect the original prototype', () => { app2.use((ctx, next) => { - assert.equal(ctx.request.message, undefined); + assert.strictEqual(ctx.request.message, undefined); ctx.status = 204; }); diff --git a/test/application/respond.js b/test/application/respond.js index 1f9a17118..29e650d61 100644 --- a/test/application/respond.js +++ b/test/application/respond.js @@ -96,7 +96,7 @@ describe('app.respond', () => { .get('/') .expect(200); - assert.equal(res.headers.hasOwnProperty('Content-Type'), false); + assert.strictEqual(res.headers.hasOwnProperty('Content-Type'), false); }); }); @@ -114,8 +114,8 @@ describe('app.respond', () => { .head('/') .expect(200); - assert.equal(res.headers['content-type'], 'text/plain; charset=utf-8'); - assert.equal(res.headers['content-length'], '5'); + assert.strictEqual(res.headers['content-type'], 'text/plain; charset=utf-8'); + assert.strictEqual(res.headers['content-length'], '5'); assert(!res.text); }); @@ -132,8 +132,8 @@ describe('app.respond', () => { .head('/') .expect(200); - assert.equal(res.headers['content-type'], 'application/json; charset=utf-8'); - assert.equal(res.headers['content-length'], '17'); + assert.strictEqual(res.headers['content-type'], 'application/json; charset=utf-8'); + assert.strictEqual(res.headers['content-length'], '17'); assert(!res.text); }); @@ -150,8 +150,8 @@ describe('app.respond', () => { .head('/') .expect(200); - assert.equal(res.headers['content-type'], 'text/plain; charset=utf-8'); - assert.equal(res.headers['content-length'], '11'); + assert.strictEqual(res.headers['content-type'], 'text/plain; charset=utf-8'); + assert.strictEqual(res.headers['content-length'], '11'); assert(!res.text); }); @@ -168,8 +168,8 @@ describe('app.respond', () => { .head('/') .expect(200); - assert.equal(res.headers['content-type'], 'application/octet-stream'); - assert.equal(res.headers['content-length'], '11'); + assert.strictEqual(res.headers['content-type'], 'application/octet-stream'); + assert.strictEqual(res.headers['content-length'], '11'); assert(!res.text); }); @@ -189,7 +189,7 @@ describe('app.respond', () => { .head('/') .expect(200); - assert.equal(res.header['content-length'], length); + assert.strictEqual(res.header['content-length'], length); assert(!res.text); }); @@ -329,7 +329,7 @@ describe('app.respond', () => { .expect(204) .expect(''); - assert.equal(res.headers.hasOwnProperty('content-type'), false); + assert.strictEqual(res.headers.hasOwnProperty('content-type'), false); }); }); @@ -348,7 +348,7 @@ describe('app.respond', () => { .expect(205) .expect(''); - assert.equal(res.headers.hasOwnProperty('content-type'), false); + assert.strictEqual(res.headers.hasOwnProperty('content-type'), false); }); }); @@ -367,7 +367,7 @@ describe('app.respond', () => { .expect(304) .expect(''); - assert.equal(res.headers.hasOwnProperty('content-type'), false); + assert.strictEqual(res.headers.hasOwnProperty('content-type'), false); }); }); @@ -387,7 +387,7 @@ describe('app.respond', () => { .expect(700) .expect('custom status'); - assert.equal(res.res.statusMessage, 'custom status'); + assert.strictEqual(res.res.statusMessage, 'custom status'); }); }); @@ -407,7 +407,7 @@ describe('app.respond', () => { .expect(200) .expect('ok'); - assert.equal(res.res.statusMessage, 'ok'); + assert.strictEqual(res.res.statusMessage, 'ok'); }); }); @@ -444,7 +444,7 @@ describe('app.respond', () => { .expect(204) .expect(''); - assert.equal(res.headers.hasOwnProperty('content-type'), false); + assert.strictEqual(res.headers.hasOwnProperty('content-type'), false); }); it('should respond 204 with status=200', async() => { @@ -462,7 +462,7 @@ describe('app.respond', () => { .expect(204) .expect(''); - assert.equal(res.headers.hasOwnProperty('content-type'), false); + assert.strictEqual(res.headers.hasOwnProperty('content-type'), false); }); it('should respond 205 with status=205', async() => { @@ -480,7 +480,7 @@ describe('app.respond', () => { .expect(205) .expect(''); - assert.equal(res.headers.hasOwnProperty('content-type'), false); + assert.strictEqual(res.headers.hasOwnProperty('content-type'), false); }); it('should respond 304 with status=304', async() => { @@ -498,7 +498,7 @@ describe('app.respond', () => { .expect(304) .expect(''); - assert.equal(res.headers.hasOwnProperty('content-type'), false); + assert.strictEqual(res.headers.hasOwnProperty('content-type'), false); }); }); @@ -551,7 +551,7 @@ describe('app.respond', () => { .expect('Content-Type', 'application/json; charset=utf-8'); const pkg = require('../../package'); - assert.equal(res.headers.hasOwnProperty('content-length'), false); + assert.strictEqual(res.headers.hasOwnProperty('content-length'), false); assert.deepEqual(res.body, pkg); }); @@ -571,7 +571,7 @@ describe('app.respond', () => { .expect('Content-Type', 'application/json; charset=utf-8'); const pkg = require('../../package'); - assert.equal(res.headers.hasOwnProperty('content-length'), false); + assert.strictEqual(res.headers.hasOwnProperty('content-length'), false); assert.deepEqual(res.body, pkg); }); @@ -591,7 +591,7 @@ describe('app.respond', () => { .expect('Content-Type', 'application/json; charset=utf-8'); const pkg = require('../../package'); - assert.equal(res.headers.hasOwnProperty('content-length'), true); + assert.strictEqual(res.headers.hasOwnProperty('content-length'), true); assert.deepEqual(res.body, pkg); }); @@ -614,7 +614,7 @@ describe('app.respond', () => { .expect('Content-Type', 'application/json; charset=utf-8'); const pkg = require('../../package'); - assert.equal(res.headers.hasOwnProperty('content-length'), true); + assert.strictEqual(res.headers.hasOwnProperty('content-length'), true); assert.deepEqual(res.body, pkg); }); @@ -716,7 +716,7 @@ describe('app.respond', () => { }); app.on('error', err => { - assert.equal(err.message, 'boom'); + assert.strictEqual(err.message, 'boom'); done(); }); @@ -829,7 +829,7 @@ describe('app.respond', () => { .get('/') .expect(204); - assert.equal(res.headers.hasOwnProperty('content-type'), false); + assert.strictEqual(res.headers.hasOwnProperty('content-type'), false); }); }); @@ -866,7 +866,7 @@ describe('app.respond', () => { .expect('') .expect({}); - assert.equal(res.headers.hasOwnProperty('content-type'), false); + assert.strictEqual(res.headers.hasOwnProperty('content-type'), false); }); }); }); diff --git a/test/application/response.js b/test/application/response.js index c9c725334..1ed5571e1 100644 --- a/test/application/response.js +++ b/test/application/response.js @@ -15,7 +15,7 @@ describe('app.response', () => { it('should merge properties', () => { app1.use((ctx, next) => { - assert.equal(ctx.response.msg, 'hello'); + assert.strictEqual(ctx.response.msg, 'hello'); ctx.status = 204; }); @@ -26,7 +26,7 @@ describe('app.response', () => { it('should not affect the original prototype', () => { app2.use((ctx, next) => { - assert.equal(ctx.response.msg, undefined); + assert.strictEqual(ctx.response.msg, undefined); ctx.status = 204; }); @@ -43,7 +43,7 @@ describe('app.response', () => { const response = await request(app3.listen()) .get('/') .expect(404); - assert.equal(response.text, '404'); + assert.strictEqual(response.text, '404'); }); it('should set ._explicitNullBody correctly', async() => { diff --git a/test/context/assert.js b/test/context/assert.js index ff4243c7d..bc535a03c 100644 --- a/test/context/assert.js +++ b/test/context/assert.js @@ -12,7 +12,7 @@ describe('ctx.assert(value, status)', () => { ctx.assert(false, 404); throw new Error('asdf'); } catch (err) { - assert.equal(err.status, 404); + assert.strictEqual(err.status, 404); assert.strictEqual(err.expose, true); } }); diff --git a/test/context/cookies.js b/test/context/cookies.js index 4644f37d1..23e949758 100644 --- a/test/context/cookies.js +++ b/test/context/cookies.js @@ -22,7 +22,7 @@ describe('ctx.cookies', () => { .expect(204); const cookie = res.headers['set-cookie'].some(cookie => /^name=/.test(cookie)); - assert.equal(cookie, true); + assert.strictEqual(cookie, true); }); describe('with .signed', () => { @@ -62,8 +62,8 @@ describe('ctx.cookies', () => { const cookies = res.headers['set-cookie']; - assert.equal(cookies.some(cookie => /^name=/.test(cookie)), true); - assert.equal(cookies.some(cookie => /(,|^)name\.sig=/.test(cookie)), true); + assert.strictEqual(cookies.some(cookie => /^name=/.test(cookie)), true); + assert.strictEqual(cookies.some(cookie => /(,|^)name\.sig=/.test(cookie)), true); }); }); @@ -87,9 +87,9 @@ describe('ctx.cookies', () => { .expect(204); const cookies = res.headers['set-cookie']; - assert.equal(cookies.some(cookie => /^name=/.test(cookie)), true); - assert.equal(cookies.some(cookie => /(,|^)name\.sig=/.test(cookie)), true); - assert.equal(cookies.every(cookie => /secure/.test(cookie)), true); + assert.strictEqual(cookies.some(cookie => /^name=/.test(cookie)), true); + assert.strictEqual(cookies.some(cookie => /(,|^)name\.sig=/.test(cookie)), true); + assert.strictEqual(cookies.every(cookie => /secure/.test(cookie)), true); }); }); }); diff --git a/test/context/onerror.js b/test/context/onerror.js index 098df8ad4..1fa729c82 100644 --- a/test/context/onerror.js +++ b/test/context/onerror.js @@ -43,8 +43,8 @@ describe('ctx.onerror(err)', () => { .expect('Content-Type', 'text/plain; charset=utf-8') .expect('Content-Length', '4'); - assert.equal(res.headers.hasOwnProperty('vary'), false); - assert.equal(res.headers.hasOwnProperty('x-csrf-token'), false); + assert.strictEqual(res.headers.hasOwnProperty('vary'), false); + assert.strictEqual(res.headers.hasOwnProperty('x-csrf-token'), false); }); it('should set headers specified in the error', async() => { @@ -72,16 +72,16 @@ describe('ctx.onerror(err)', () => { .expect('Content-Type', 'text/plain; charset=utf-8') .expect('X-New-Header', 'Value'); - assert.equal(res.headers.hasOwnProperty('vary'), false); - assert.equal(res.headers.hasOwnProperty('x-csrf-token'), false); + assert.strictEqual(res.headers.hasOwnProperty('vary'), false); + assert.strictEqual(res.headers.hasOwnProperty('x-csrf-token'), false); }); it('should ignore error after headerSent', done => { const app = new Koa(); app.on('error', err => { - assert.equal(err.message, 'mock error'); - assert.equal(err.headerSent, true); + assert.strictEqual(err.message, 'mock error'); + assert.strictEqual(err.headerSent, true); done(); }); @@ -269,14 +269,14 @@ describe('ctx.onerror(err)', () => { ctx.onerror(new Error('error')); - assert.equal(removed, 2); + assert.strictEqual(removed, 2); }); it('should stringify error if it is an object', done => { const app = new Koa(); app.on('error', err => { - assert.equal(err, 'Error: non-error thrown: {"key":"value"}'); + assert.strictEqual(err, 'Error: non-error thrown: {"key":"value"}'); done(); }); diff --git a/test/context/throw.js b/test/context/throw.js index 5c091c8c6..4751af44a 100644 --- a/test/context/throw.js +++ b/test/context/throw.js @@ -11,8 +11,8 @@ describe('ctx.throw(msg)', () => { try { ctx.throw('boom'); } catch (err) { - assert.equal(err.status, 500); - assert.equal(err.expose, false); + assert.strictEqual(err.status, 500); + assert.strictEqual(err.expose, false); } }); }); @@ -25,9 +25,9 @@ describe('ctx.throw(err)', () => { try { ctx.throw(err); } catch (err) { - assert.equal(err.status, 500); - assert.equal(err.message, 'test'); - assert.equal(err.expose, false); + assert.strictEqual(err.status, 500); + assert.strictEqual(err.message, 'test'); + assert.strictEqual(err.expose, false); } }); }); @@ -40,9 +40,9 @@ describe('ctx.throw(err, status)', () => { try { ctx.throw(error, 422); } catch (err) { - assert.equal(err.status, 422); - assert.equal(err.message, 'test'); - assert.equal(err.expose, true); + assert.strictEqual(err.status, 422); + assert.strictEqual(err.message, 'test'); + assert.strictEqual(err.expose, true); } }); }); @@ -55,9 +55,9 @@ describe('ctx.throw(status, err)', () => { try { ctx.throw(422, error); } catch (err) { - assert.equal(err.status, 422); - assert.equal(err.message, 'test'); - assert.equal(err.expose, true); + assert.strictEqual(err.status, 422); + assert.strictEqual(err.message, 'test'); + assert.strictEqual(err.expose, true); } }); }); @@ -69,9 +69,9 @@ describe('ctx.throw(msg, status)', () => { try { ctx.throw('name required', 400); } catch (err) { - assert.equal(err.message, 'name required'); - assert.equal(err.status, 400); - assert.equal(err.expose, true); + assert.strictEqual(err.message, 'name required'); + assert.strictEqual(err.status, 400); + assert.strictEqual(err.expose, true); } }); }); @@ -83,9 +83,9 @@ describe('ctx.throw(status, msg)', () => { try { ctx.throw(400, 'name required'); } catch (err) { - assert.equal(err.message, 'name required'); - assert.equal(400, err.status); - assert.equal(true, err.expose); + assert.strictEqual(err.message, 'name required'); + assert.strictEqual(400, err.status); + assert.strictEqual(true, err.expose); } }); }); @@ -97,9 +97,9 @@ describe('ctx.throw(status)', () => { try { ctx.throw(400); } catch (err) { - assert.equal(err.message, 'Bad Request'); - assert.equal(err.status, 400); - assert.equal(err.expose, true); + assert.strictEqual(err.message, 'Bad Request'); + assert.strictEqual(err.status, 400); + assert.strictEqual(err.expose, true); } }); @@ -112,8 +112,8 @@ describe('ctx.throw(status)', () => { err.status = -1; ctx.throw(err); } catch (err) { - assert.equal(err.message, 'some error'); - assert.equal(err.expose, false); + assert.strictEqual(err.message, 'some error'); + assert.strictEqual(err.expose, false); } }); }); @@ -126,10 +126,10 @@ describe('ctx.throw(status, msg, props)', () => { try { ctx.throw(400, 'msg', { prop: true }); } catch (err) { - assert.equal(err.message, 'msg'); - assert.equal(err.status, 400); - assert.equal(err.expose, true); - assert.equal(err.prop, true); + assert.strictEqual(err.message, 'msg'); + assert.strictEqual(err.status, 400); + assert.strictEqual(err.expose, true); + assert.strictEqual(err.prop, true); } }); @@ -143,10 +143,10 @@ describe('ctx.throw(status, msg, props)', () => { status: -1 }); } catch (err) { - assert.equal(err.message, 'msg'); - assert.equal(err.status, 400); - assert.equal(err.expose, true); - assert.equal(err.prop, true); + assert.strictEqual(err.message, 'msg'); + assert.strictEqual(err.status, 400); + assert.strictEqual(err.expose, true); + assert.strictEqual(err.prop, true); } }); }); @@ -159,10 +159,10 @@ describe('ctx.throw(msg, props)', () => { try { ctx.throw('msg', { prop: true }); } catch (err) { - assert.equal(err.message, 'msg'); - assert.equal(err.status, 500); - assert.equal(err.expose, false); - assert.equal(err.prop, true); + assert.strictEqual(err.message, 'msg'); + assert.strictEqual(err.status, 500); + assert.strictEqual(err.expose, false); + assert.strictEqual(err.prop, true); } }); }); @@ -174,10 +174,10 @@ describe('ctx.throw(status, props)', () => { try { ctx.throw(400, { prop: true }); } catch (err) { - assert.equal(err.message, 'Bad Request'); - assert.equal(err.status, 400); - assert.equal(err.expose, true); - assert.equal(err.prop, true); + assert.strictEqual(err.message, 'Bad Request'); + assert.strictEqual(err.status, 400); + assert.strictEqual(err.expose, true); + assert.strictEqual(err.prop, true); } }); }); @@ -189,10 +189,10 @@ describe('ctx.throw(err, props)', () => { try { ctx.throw(new Error('test'), { prop: true }); } catch (err) { - assert.equal(err.message, 'test'); - assert.equal(err.status, 500); - assert.equal(err.expose, false); - assert.equal(err.prop, true); + assert.strictEqual(err.message, 'test'); + assert.strictEqual(err.status, 500); + assert.strictEqual(err.expose, false); + assert.strictEqual(err.prop, true); } }); }); diff --git a/test/request/accepts.js b/test/request/accepts.js index 4c680d942..b29877844 100644 --- a/test/request/accepts.js +++ b/test/request/accepts.js @@ -20,14 +20,14 @@ describe('ctx.accepts(types)', () => { it('should return false', () => { const ctx = context(); ctx.req.headers.accept = 'application/*;q=0.2, image/jpeg;q=0.8, text/html, text/plain'; - assert.equal(ctx.accepts('image/png', 'image/tiff'), false); + assert.strictEqual(ctx.accepts('image/png', 'image/tiff'), false); }); }); describe('when Accept is not populated', () => { it('should return the first type', () => { const ctx = context(); - assert.equal(ctx.accepts('text/html', 'text/plain', 'image/jpeg', 'application/*'), 'text/html'); + assert.strictEqual(ctx.accepts('text/html', 'text/plain', 'image/jpeg', 'application/*'), 'text/html'); }); }); }); @@ -36,11 +36,11 @@ describe('ctx.accepts(types)', () => { it('should convert to mime types', () => { const ctx = context(); ctx.req.headers.accept = 'text/plain, text/html'; - assert.equal(ctx.accepts('html'), 'html'); - assert.equal(ctx.accepts('.html'), '.html'); - assert.equal(ctx.accepts('txt'), 'txt'); - assert.equal(ctx.accepts('.txt'), '.txt'); - assert.equal(ctx.accepts('png'), false); + assert.strictEqual(ctx.accepts('html'), 'html'); + assert.strictEqual(ctx.accepts('.html'), '.html'); + assert.strictEqual(ctx.accepts('txt'), 'txt'); + assert.strictEqual(ctx.accepts('.txt'), '.txt'); + assert.strictEqual(ctx.accepts('png'), false); }); }); @@ -48,8 +48,8 @@ describe('ctx.accepts(types)', () => { it('should return the first match', () => { const ctx = context(); ctx.req.headers.accept = 'text/plain, text/html'; - assert.equal(ctx.accepts(['png', 'text', 'html']), 'text'); - assert.equal(ctx.accepts(['png', 'html']), 'html'); + assert.strictEqual(ctx.accepts(['png', 'text', 'html']), 'text'); + assert.strictEqual(ctx.accepts(['png', 'html']), 'html'); }); }); @@ -57,8 +57,8 @@ describe('ctx.accepts(types)', () => { it('should return the first match', () => { const ctx = context(); ctx.req.headers.accept = 'text/plain, text/html'; - assert.equal(ctx.accepts('png', 'text', 'html'), 'text'); - assert.equal(ctx.accepts('png', 'html'), 'html'); + assert.strictEqual(ctx.accepts('png', 'text', 'html'), 'text'); + assert.strictEqual(ctx.accepts('png', 'html'), 'html'); }); }); @@ -66,8 +66,8 @@ describe('ctx.accepts(types)', () => { it('should return the type', () => { const ctx = context(); ctx.req.headers.accept = 'text/plain, text/html'; - assert.equal(ctx.accepts('text/html'), 'text/html'); - assert.equal(ctx.accepts('text/plain'), 'text/plain'); + assert.strictEqual(ctx.accepts('text/html'), 'text/html'); + assert.strictEqual(ctx.accepts('text/plain'), 'text/plain'); }); }); @@ -75,9 +75,9 @@ describe('ctx.accepts(types)', () => { it('should return the type', () => { const ctx = context(); ctx.req.headers.accept = 'application/json, */*'; - assert.equal(ctx.accepts('text/html'), 'text/html'); - assert.equal(ctx.accepts('text/plain'), 'text/plain'); - assert.equal(ctx.accepts('image/png'), 'image/png'); + assert.strictEqual(ctx.accepts('text/html'), 'text/html'); + assert.strictEqual(ctx.accepts('text/plain'), 'text/plain'); + assert.strictEqual(ctx.accepts('image/png'), 'image/png'); }); }); @@ -85,10 +85,10 @@ describe('ctx.accepts(types)', () => { it('should return the type', () => { const ctx = context(); ctx.req.headers.accept = 'application/json, text/*'; - assert.equal(ctx.accepts('text/html'), 'text/html'); - assert.equal(ctx.accepts('text/plain'), 'text/plain'); - assert.equal(ctx.accepts('image/png'), false); - assert.equal(ctx.accepts('png'), false); + assert.strictEqual(ctx.accepts('text/html'), 'text/html'); + assert.strictEqual(ctx.accepts('text/plain'), 'text/plain'); + assert.strictEqual(ctx.accepts('image/png'), false); + assert.strictEqual(ctx.accepts('png'), false); }); }); }); diff --git a/test/request/acceptsCharsets.js b/test/request/acceptsCharsets.js index 0f09200e2..5b317cfa7 100644 --- a/test/request/acceptsCharsets.js +++ b/test/request/acceptsCharsets.js @@ -21,7 +21,7 @@ describe('ctx.acceptsCharsets()', () => { it('should return the best fit', () => { const ctx = context(); ctx.req.headers['accept-charset'] = 'utf-8, iso-8859-1;q=0.2, utf-7;q=0.5'; - assert.equal(ctx.acceptsCharsets('utf-7', 'utf-8'), 'utf-8'); + assert.strictEqual(ctx.acceptsCharsets('utf-7', 'utf-8'), 'utf-8'); }); }); @@ -29,7 +29,7 @@ describe('ctx.acceptsCharsets()', () => { it('should return false', () => { const ctx = context(); ctx.req.headers['accept-charset'] = 'utf-8, iso-8859-1;q=0.2, utf-7;q=0.5'; - assert.equal(ctx.acceptsCharsets('utf-16'), false); + assert.strictEqual(ctx.acceptsCharsets('utf-16'), false); }); }); }); @@ -37,7 +37,7 @@ describe('ctx.acceptsCharsets()', () => { describe('when Accept-Charset is not populated', () => { it('should return the first type', () => { const ctx = context(); - assert.equal(ctx.acceptsCharsets('utf-7', 'utf-8'), 'utf-7'); + assert.strictEqual(ctx.acceptsCharsets('utf-7', 'utf-8'), 'utf-7'); }); }); }); @@ -46,7 +46,7 @@ describe('ctx.acceptsCharsets()', () => { it('should return the best fit', () => { const ctx = context(); ctx.req.headers['accept-charset'] = 'utf-8, iso-8859-1;q=0.2, utf-7;q=0.5'; - assert.equal(ctx.acceptsCharsets(['utf-7', 'utf-8']), 'utf-8'); + assert.strictEqual(ctx.acceptsCharsets(['utf-7', 'utf-8']), 'utf-8'); }); }); }); diff --git a/test/request/acceptsEncodings.js b/test/request/acceptsEncodings.js index 13a5da80c..92e6f331f 100644 --- a/test/request/acceptsEncodings.js +++ b/test/request/acceptsEncodings.js @@ -11,7 +11,7 @@ describe('ctx.acceptsEncodings()', () => { const ctx = context(); ctx.req.headers['accept-encoding'] = 'gzip, compress;q=0.2'; assert.deepEqual(ctx.acceptsEncodings(), ['gzip', 'compress', 'identity']); - assert.equal(ctx.acceptsEncodings('gzip', 'compress'), 'gzip'); + assert.strictEqual(ctx.acceptsEncodings('gzip', 'compress'), 'gzip'); }); }); @@ -19,7 +19,7 @@ describe('ctx.acceptsEncodings()', () => { it('should return identity', () => { const ctx = context(); assert.deepEqual(ctx.acceptsEncodings(), ['identity']); - assert.equal(ctx.acceptsEncodings('gzip', 'deflate', 'identity'), 'identity'); + assert.strictEqual(ctx.acceptsEncodings('gzip', 'deflate', 'identity'), 'identity'); }); }); }); @@ -28,8 +28,8 @@ describe('ctx.acceptsEncodings()', () => { it('should return the best fit', () => { const ctx = context(); ctx.req.headers['accept-encoding'] = 'gzip, compress;q=0.2'; - assert.equal(ctx.acceptsEncodings('compress', 'gzip'), 'gzip'); - assert.equal(ctx.acceptsEncodings('gzip', 'compress'), 'gzip'); + assert.strictEqual(ctx.acceptsEncodings('compress', 'gzip'), 'gzip'); + assert.strictEqual(ctx.acceptsEncodings('gzip', 'compress'), 'gzip'); }); }); @@ -37,7 +37,7 @@ describe('ctx.acceptsEncodings()', () => { it('should return the best fit', () => { const ctx = context(); ctx.req.headers['accept-encoding'] = 'gzip, compress;q=0.2'; - assert.equal(ctx.acceptsEncodings(['compress', 'gzip']), 'gzip'); + assert.strictEqual(ctx.acceptsEncodings(['compress', 'gzip']), 'gzip'); }); }); }); diff --git a/test/request/acceptsLanguages.js b/test/request/acceptsLanguages.js index 7c84160b1..d9a33a574 100644 --- a/test/request/acceptsLanguages.js +++ b/test/request/acceptsLanguages.js @@ -21,7 +21,7 @@ describe('ctx.acceptsLanguages(langs)', () => { it('should return the best fit', () => { const ctx = context(); ctx.req.headers['accept-language'] = 'en;q=0.8, es, pt'; - assert.equal(ctx.acceptsLanguages('es', 'en'), 'es'); + assert.strictEqual(ctx.acceptsLanguages('es', 'en'), 'es'); }); }); @@ -29,7 +29,7 @@ describe('ctx.acceptsLanguages(langs)', () => { it('should return false', () => { const ctx = context(); ctx.req.headers['accept-language'] = 'en;q=0.8, es, pt'; - assert.equal(ctx.acceptsLanguages('fr', 'au'), false); + assert.strictEqual(ctx.acceptsLanguages('fr', 'au'), false); }); }); }); @@ -37,7 +37,7 @@ describe('ctx.acceptsLanguages(langs)', () => { describe('when Accept-Language is not populated', () => { it('should return the first type', () => { const ctx = context(); - assert.equal(ctx.acceptsLanguages('es', 'en'), 'es'); + assert.strictEqual(ctx.acceptsLanguages('es', 'en'), 'es'); }); }); }); @@ -46,7 +46,7 @@ describe('ctx.acceptsLanguages(langs)', () => { it('should return the best fit', () => { const ctx = context(); ctx.req.headers['accept-language'] = 'en;q=0.8, es, pt'; - assert.equal(ctx.acceptsLanguages(['es', 'en']), 'es'); + assert.strictEqual(ctx.acceptsLanguages(['es', 'en']), 'es'); }); }); }); diff --git a/test/request/charset.js b/test/request/charset.js index f2c01f8a4..832251a51 100644 --- a/test/request/charset.js +++ b/test/request/charset.js @@ -24,13 +24,13 @@ describe('req.charset', () => { it('should return the charset', () => { const req = request(); req.header['content-type'] = 'text/plain; charset=utf-8'; - assert.equal(req.charset, 'utf-8'); + assert.strictEqual(req.charset, 'utf-8'); }); it('should return "" if content-type is invalid', () => { const req = request(); req.header['content-type'] = 'application/json; application/text; charset=utf-8'; - assert.equal(req.charset, ''); + assert.strictEqual(req.charset, ''); }); }); }); diff --git a/test/request/fresh.js b/test/request/fresh.js index b452c1d6c..42ab3e74a 100644 --- a/test/request/fresh.js +++ b/test/request/fresh.js @@ -9,7 +9,7 @@ describe('ctx.fresh', () => { it('should return false', () => { const ctx = context(); ctx.req.method = 'POST'; - assert.equal(ctx.fresh, false); + assert.strictEqual(ctx.fresh, false); }); }); @@ -20,7 +20,7 @@ describe('ctx.fresh', () => { ctx.req.method = 'GET'; ctx.req.headers['if-none-match'] = '123'; ctx.set('ETag', '123'); - assert.equal(ctx.fresh, false); + assert.strictEqual(ctx.fresh, false); }); }); @@ -32,7 +32,7 @@ describe('ctx.fresh', () => { ctx.req.method = 'GET'; ctx.req.headers['if-none-match'] = '123'; ctx.set('ETag', '123'); - assert.equal(ctx.fresh, true); + assert.strictEqual(ctx.fresh, true); }); }); @@ -43,7 +43,7 @@ describe('ctx.fresh', () => { ctx.req.method = 'GET'; ctx.req.headers['if-none-match'] = '123'; ctx.set('ETag', 'hey'); - assert.equal(ctx.fresh, false); + assert.strictEqual(ctx.fresh, false); }); }); }); diff --git a/test/request/get.js b/test/request/get.js index 98e1c1275..fc9a96a8f 100644 --- a/test/request/get.js +++ b/test/request/get.js @@ -9,10 +9,10 @@ describe('ctx.get(name)', () => { const ctx = context(); ctx.req.headers.host = 'http://google.com'; ctx.req.headers.referer = 'http://google.com'; - assert.equal(ctx.get('HOST'), 'http://google.com'); - assert.equal(ctx.get('Host'), 'http://google.com'); - assert.equal(ctx.get('host'), 'http://google.com'); - assert.equal(ctx.get('referer'), 'http://google.com'); - assert.equal(ctx.get('referrer'), 'http://google.com'); + assert.strictEqual(ctx.get('HOST'), 'http://google.com'); + assert.strictEqual(ctx.get('Host'), 'http://google.com'); + assert.strictEqual(ctx.get('host'), 'http://google.com'); + assert.strictEqual(ctx.get('referer'), 'http://google.com'); + assert.strictEqual(ctx.get('referrer'), 'http://google.com'); }); }); diff --git a/test/request/host.js b/test/request/host.js index 0ad94868e..b56fc706a 100644 --- a/test/request/host.js +++ b/test/request/host.js @@ -8,13 +8,13 @@ describe('req.host', () => { it('should return host with port', () => { const req = request(); req.header.host = 'foo.com:3000'; - assert.equal(req.host, 'foo.com:3000'); + assert.strictEqual(req.host, 'foo.com:3000'); }); describe('with no host present', () => { it('should return ""', () => { const req = request(); - assert.equal(req.host, ''); + assert.strictEqual(req.host, ''); }); }); @@ -26,7 +26,7 @@ describe('req.host', () => { }); req.header[':authority'] = 'foo.com:3000'; req.header.host = 'bar.com:8000'; - assert.equal(req.host, 'bar.com:8000'); + assert.strictEqual(req.host, 'bar.com:8000'); }); }); @@ -38,7 +38,7 @@ describe('req.host', () => { }); req.header[':authority'] = 'foo.com:3000'; req.header.host = 'bar.com:8000'; - assert.equal(req.host, 'foo.com:3000'); + assert.strictEqual(req.host, 'foo.com:3000'); }); it('should use host header as fallback', () => { @@ -47,7 +47,7 @@ describe('req.host', () => { 'httpVersion': '2.0' }); req.header.host = 'bar.com:8000'; - assert.equal(req.host, 'bar.com:8000'); + assert.strictEqual(req.host, 'bar.com:8000'); }); }); @@ -57,7 +57,7 @@ describe('req.host', () => { const req = request(); req.header['x-forwarded-host'] = 'bar.com'; req.header.host = 'foo.com'; - assert.equal(req.host, 'foo.com'); + assert.strictEqual(req.host, 'foo.com'); }); it('should be ignored on HTTP/2', () => { @@ -68,7 +68,7 @@ describe('req.host', () => { req.header['x-forwarded-host'] = 'proxy.com:8080'; req.header[':authority'] = 'foo.com:3000'; req.header.host = 'bar.com:8000'; - assert.equal(req.host, 'foo.com:3000'); + assert.strictEqual(req.host, 'foo.com:3000'); }); }); @@ -78,7 +78,7 @@ describe('req.host', () => { req.app.proxy = true; req.header['x-forwarded-host'] = 'bar.com, baz.com'; req.header.host = 'foo.com'; - assert.equal(req.host, 'bar.com'); + assert.strictEqual(req.host, 'bar.com'); }); it('should be used on HTTP/2', () => { @@ -90,7 +90,7 @@ describe('req.host', () => { req.header['x-forwarded-host'] = 'proxy.com:8080'; req.header[':authority'] = 'foo.com:3000'; req.header.host = 'bar.com:8000'; - assert.equal(req.host, 'proxy.com:8080'); + assert.strictEqual(req.host, 'proxy.com:8080'); }); }); }); diff --git a/test/request/hostname.js b/test/request/hostname.js index dd9c61da1..bc70de1f1 100644 --- a/test/request/hostname.js +++ b/test/request/hostname.js @@ -8,13 +8,13 @@ describe('req.hostname', () => { it('should return hostname void of port', () => { const req = request(); req.header.host = 'foo.com:3000'; - assert.equal(req.hostname, 'foo.com'); + assert.strictEqual(req.hostname, 'foo.com'); }); describe('with no host present', () => { it('should return ""', () => { const req = request(); - assert.equal(req.hostname, ''); + assert.strictEqual(req.hostname, ''); }); }); @@ -22,31 +22,31 @@ describe('req.hostname', () => { it('should parse localhost void of port', () => { const req = request(); req.header.host = '[::1]'; - assert.equal(req.hostname, '[::1]'); + assert.strictEqual(req.hostname, '[::1]'); }); it('should parse localhost with port 80', () => { const req = request(); req.header.host = '[::1]:80'; - assert.equal(req.hostname, '[::1]'); + assert.strictEqual(req.hostname, '[::1]'); }); it('should parse localhost with non-special schema port', () => { const req = request(); req.header.host = '[::1]:1337'; - assert.equal(req.hostname, '[::1]'); + assert.strictEqual(req.hostname, '[::1]'); }); it('should reduce IPv6 with non-special schema port as hostname', () => { const req = request(); req.header.host = '[2001:cdba:0000:0000:0000:0000:3257:9652]:1337'; - assert.equal(req.hostname, '[2001:cdba::3257:9652]'); + assert.strictEqual(req.hostname, '[2001:cdba::3257:9652]'); }); it('should return empty string when invalid', () => { const req = request(); req.header.host = '[invalidIPv6]'; - assert.equal(req.hostname, ''); + assert.strictEqual(req.hostname, ''); }); }); @@ -56,7 +56,7 @@ describe('req.hostname', () => { const req = request(); req.header['x-forwarded-host'] = 'bar.com'; req.header.host = 'foo.com'; - assert.equal(req.hostname, 'foo.com'); + assert.strictEqual(req.hostname, 'foo.com'); }); }); @@ -66,7 +66,7 @@ describe('req.hostname', () => { req.app.proxy = true; req.header['x-forwarded-host'] = 'bar.com, baz.com'; req.header.host = 'foo.com'; - assert.equal(req.hostname, 'bar.com'); + assert.strictEqual(req.hostname, 'bar.com'); }); }); }); diff --git a/test/request/href.js b/test/request/href.js index ded3e8015..157ac9141 100644 --- a/test/request/href.js +++ b/test/request/href.js @@ -19,10 +19,10 @@ describe('ctx.href', () => { __proto__: Stream.Readable.prototype }; const ctx = context(req); - assert.equal(ctx.href, 'http://localhost/users/1?next=/dashboard'); + assert.strictEqual(ctx.href, 'http://localhost/users/1?next=/dashboard'); // change it also work ctx.url = '/foo/users/1?next=/dashboard'; - assert.equal(ctx.href, 'http://localhost/users/1?next=/dashboard'); + assert.strictEqual(ctx.href, 'http://localhost/users/1?next=/dashboard'); }); it('should work with `GET http://example.com/foo`', done => { @@ -37,12 +37,12 @@ describe('ctx.href', () => { path: 'http://example.com/foo', port: address.port }, res => { - assert.equal(res.statusCode, 200); + assert.strictEqual(res.statusCode, 200); let buf = ''; res.setEncoding('utf8'); res.on('data', s => buf += s); res.on('end', () => { - assert.equal(buf, 'http://example.com/foo'); + assert.strictEqual(buf, 'http://example.com/foo'); done(); }); }); diff --git a/test/request/idempotent.js b/test/request/idempotent.js index 230da031b..eaddaaed5 100644 --- a/test/request/idempotent.js +++ b/test/request/idempotent.js @@ -11,7 +11,7 @@ describe('ctx.idempotent', () => { function check(method){ const req = request(); req.method = method; - assert.equal(req.idempotent, true); + assert.strictEqual(req.idempotent, true); } }); }); @@ -20,7 +20,7 @@ describe('ctx.idempotent', () => { it('should return false', () => { const req = request(); req.method = 'POST'; - assert.equal(req.idempotent, false); + assert.strictEqual(req.idempotent, false); }); }); }); diff --git a/test/request/ip.js b/test/request/ip.js index 3375f700b..4ecd27ce2 100644 --- a/test/request/ip.js +++ b/test/request/ip.js @@ -15,7 +15,7 @@ describe('req.ip', () => { req.headers['x-forwarded-for'] = '127.0.0.1'; req.socket.remoteAddress = '127.0.0.2'; const request = Request(req, undefined, app); - assert.equal(request.ip, '127.0.0.1'); + assert.strictEqual(request.ip, '127.0.0.1'); }); }); @@ -24,7 +24,7 @@ describe('req.ip', () => { const req = { socket: new Stream.Duplex() }; req.socket.remoteAddress = '127.0.0.2'; const request = Request(req); - assert.equal(request.ip, '127.0.0.2'); + assert.strictEqual(request.ip, '127.0.0.2'); }); describe('with req.socket.remoteAddress not present', () => { @@ -34,7 +34,7 @@ describe('req.ip', () => { get: () => undefined, // So that the helper doesn't override it with a reasonable value set: () => {} }); - assert.equal(Request({ socket }).ip, ''); + assert.strictEqual(Request({ socket }).ip, ''); }); }); }); @@ -43,17 +43,17 @@ describe('req.ip', () => { const req = { socket: new Stream.Duplex() }; req.socket.remoteAddress = '127.0.0.2'; const request = Request(req); - assert.equal(request.ip, '127.0.0.2'); + assert.strictEqual(request.ip, '127.0.0.2'); req.socket.remoteAddress = '127.0.0.1'; - assert.equal(request.ip, '127.0.0.2'); + assert.strictEqual(request.ip, '127.0.0.2'); }); it('should reset ip work', () => { const req = { socket: new Stream.Duplex() }; req.socket.remoteAddress = '127.0.0.2'; const request = Request(req); - assert.equal(request.ip, '127.0.0.2'); + assert.strictEqual(request.ip, '127.0.0.2'); request.ip = '127.0.0.1'; - assert.equal(request.ip, '127.0.0.1'); + assert.strictEqual(request.ip, '127.0.0.1'); }); }); diff --git a/test/request/is.js b/test/request/is.js index 1db40c796..274ca0c39 100644 --- a/test/request/is.js +++ b/test/request/is.js @@ -10,16 +10,16 @@ describe('ctx.is(type)', () => { ctx.header['content-type'] = 'text/html; charset=utf-8'; ctx.header['transfer-encoding'] = 'chunked'; - assert.equal(ctx.is('text/*'), 'text/html'); + assert.strictEqual(ctx.is('text/*'), 'text/html'); }); describe('when no body is given', () => { it('should return null', () => { const ctx = context(); - assert.equal(ctx.is(), null); - assert.equal(ctx.is('image/*'), null); - assert.equal(ctx.is('image/*', 'text/*'), null); + assert.strictEqual(ctx.is(), null); + assert.strictEqual(ctx.is('image/*'), null); + assert.strictEqual(ctx.is('image/*', 'text/*'), null); }); }); @@ -28,9 +28,9 @@ describe('ctx.is(type)', () => { const ctx = context(); ctx.header['transfer-encoding'] = 'chunked'; - assert.equal(ctx.is(), false); - assert.equal(ctx.is('image/*'), false); - assert.equal(ctx.is('text/*', 'image/*'), false); + assert.strictEqual(ctx.is(), false); + assert.strictEqual(ctx.is('image/*'), false); + assert.strictEqual(ctx.is('text/*', 'image/*'), false); }); }); @@ -40,7 +40,7 @@ describe('ctx.is(type)', () => { ctx.header['content-type'] = 'image/png'; ctx.header['transfer-encoding'] = 'chunked'; - assert.equal(ctx.is(), 'image/png'); + assert.strictEqual(ctx.is(), 'image/png'); }); }); @@ -50,17 +50,17 @@ describe('ctx.is(type)', () => { ctx.header['content-type'] = 'image/png'; ctx.header['transfer-encoding'] = 'chunked'; - assert.equal(ctx.is('png'), 'png'); - assert.equal(ctx.is('.png'), '.png'); - assert.equal(ctx.is('image/png'), 'image/png'); - assert.equal(ctx.is('image/*'), 'image/png'); - assert.equal(ctx.is('*/png'), 'image/png'); - - assert.equal(ctx.is('jpeg'), false); - assert.equal(ctx.is('.jpeg'), false); - assert.equal(ctx.is('image/jpeg'), false); - assert.equal(ctx.is('text/*'), false); - assert.equal(ctx.is('*/jpeg'), false); + assert.strictEqual(ctx.is('png'), 'png'); + assert.strictEqual(ctx.is('.png'), '.png'); + assert.strictEqual(ctx.is('image/png'), 'image/png'); + assert.strictEqual(ctx.is('image/*'), 'image/png'); + assert.strictEqual(ctx.is('*/png'), 'image/png'); + + assert.strictEqual(ctx.is('jpeg'), false); + assert.strictEqual(ctx.is('.jpeg'), false); + assert.strictEqual(ctx.is('image/jpeg'), false); + assert.strictEqual(ctx.is('text/*'), false); + assert.strictEqual(ctx.is('*/jpeg'), false); }); }); @@ -70,22 +70,22 @@ describe('ctx.is(type)', () => { ctx.header['content-type'] = 'image/png'; ctx.header['transfer-encoding'] = 'chunked'; - assert.equal(ctx.is('png'), 'png'); - assert.equal(ctx.is('.png'), '.png'); - assert.equal(ctx.is('text/*', 'image/*'), 'image/png'); - assert.equal(ctx.is('image/*', 'text/*'), 'image/png'); - assert.equal(ctx.is('image/*', 'image/png'), 'image/png'); - assert.equal(ctx.is('image/png', 'image/*'), 'image/png'); - - assert.equal(ctx.is(['text/*', 'image/*']), 'image/png'); - assert.equal(ctx.is(['image/*', 'text/*']), 'image/png'); - assert.equal(ctx.is(['image/*', 'image/png']), 'image/png'); - assert.equal(ctx.is(['image/png', 'image/*']), 'image/png'); - - assert.equal(ctx.is('jpeg'), false); - assert.equal(ctx.is('.jpeg'), false); - assert.equal(ctx.is('text/*', 'application/*'), false); - assert.equal(ctx.is('text/html', 'text/plain', 'application/json; charset=utf-8'), false); + assert.strictEqual(ctx.is('png'), 'png'); + assert.strictEqual(ctx.is('.png'), '.png'); + assert.strictEqual(ctx.is('text/*', 'image/*'), 'image/png'); + assert.strictEqual(ctx.is('image/*', 'text/*'), 'image/png'); + assert.strictEqual(ctx.is('image/*', 'image/png'), 'image/png'); + assert.strictEqual(ctx.is('image/png', 'image/*'), 'image/png'); + + assert.strictEqual(ctx.is(['text/*', 'image/*']), 'image/png'); + assert.strictEqual(ctx.is(['image/*', 'text/*']), 'image/png'); + assert.strictEqual(ctx.is(['image/*', 'image/png']), 'image/png'); + assert.strictEqual(ctx.is(['image/png', 'image/*']), 'image/png'); + + assert.strictEqual(ctx.is('jpeg'), false); + assert.strictEqual(ctx.is('.jpeg'), false); + assert.strictEqual(ctx.is('text/*', 'application/*'), false); + assert.strictEqual(ctx.is('text/html', 'text/plain', 'application/json; charset=utf-8'), false); }); }); @@ -95,9 +95,9 @@ describe('ctx.is(type)', () => { ctx.header['content-type'] = 'application/x-www-form-urlencoded'; ctx.header['transfer-encoding'] = 'chunked'; - assert.equal(ctx.is('urlencoded'), 'urlencoded'); - assert.equal(ctx.is('json', 'urlencoded'), 'urlencoded'); - assert.equal(ctx.is('urlencoded', 'json'), 'urlencoded'); + assert.strictEqual(ctx.is('urlencoded'), 'urlencoded'); + assert.strictEqual(ctx.is('json', 'urlencoded'), 'urlencoded'); + assert.strictEqual(ctx.is('urlencoded', 'json'), 'urlencoded'); }); }); }); diff --git a/test/request/length.js b/test/request/length.js index 445ecd9e2..901dfa4ea 100644 --- a/test/request/length.js +++ b/test/request/length.js @@ -8,11 +8,11 @@ describe('ctx.length', () => { it('should return length in content-length', () => { const req = request(); req.header['content-length'] = '10'; - assert.equal(req.length, 10); + assert.strictEqual(req.length, 10); }); it('should return undefined with no content-length present', () => { const req = request(); - assert.equal(req.length, undefined); + assert.strictEqual(req.length, undefined); }); }); diff --git a/test/request/origin.js b/test/request/origin.js index b510b3ef4..886ae9d11 100644 --- a/test/request/origin.js +++ b/test/request/origin.js @@ -17,9 +17,9 @@ describe('ctx.origin', () => { __proto__: Stream.Readable.prototype }; const ctx = context(req); - assert.equal(ctx.origin, 'http://localhost'); + assert.strictEqual(ctx.origin, 'http://localhost'); // change it also work ctx.url = '/foo/users/1?next=/dashboard'; - assert.equal(ctx.origin, 'http://localhost'); + assert.strictEqual(ctx.origin, 'http://localhost'); }); }); diff --git a/test/request/path.js b/test/request/path.js index e432a30d5..7afae0498 100644 --- a/test/request/path.js +++ b/test/request/path.js @@ -9,7 +9,7 @@ describe('ctx.path', () => { it('should return the pathname', () => { const ctx = context(); ctx.url = '/login?next=/dashboard'; - assert.equal(ctx.path, '/login'); + assert.strictEqual(ctx.path, '/login'); }); }); @@ -19,22 +19,22 @@ describe('ctx.path=', () => { ctx.url = '/login?next=/dashboard'; ctx.path = '/logout'; - assert.equal(ctx.path, '/logout'); - assert.equal(ctx.url, '/logout?next=/dashboard'); + assert.strictEqual(ctx.path, '/logout'); + assert.strictEqual(ctx.url, '/logout?next=/dashboard'); }); it('should change .url but not .originalUrl', () => { const ctx = context({ url: '/login' }); ctx.path = '/logout'; - assert.equal(ctx.url, '/logout'); - assert.equal(ctx.originalUrl, '/login'); - assert.equal(ctx.request.originalUrl, '/login'); + assert.strictEqual(ctx.url, '/logout'); + assert.strictEqual(ctx.originalUrl, '/login'); + assert.strictEqual(ctx.request.originalUrl, '/login'); }); it('should not affect parseurl', () => { const ctx = context({ url: '/login?foo=bar' }); ctx.path = '/login'; const url = parseurl(ctx.req); - assert.equal(url.path, '/login?foo=bar'); + assert.strictEqual(url.path, '/login?foo=bar'); }); }); diff --git a/test/request/protocol.js b/test/request/protocol.js index 04d507920..b2acc53ef 100644 --- a/test/request/protocol.js +++ b/test/request/protocol.js @@ -9,7 +9,7 @@ describe('req.protocol', () => { it('should return "https"', () => { const req = request(); req.req.socket = { encrypted: true }; - assert.equal(req.protocol, 'https'); + assert.strictEqual(req.protocol, 'https'); }); }); @@ -17,7 +17,7 @@ describe('req.protocol', () => { it('should return "http"', () => { const req = request(); req.req.socket = {}; - assert.equal(req.protocol, 'http'); + assert.strictEqual(req.protocol, 'http'); }); }); @@ -28,7 +28,7 @@ describe('req.protocol', () => { req.app.proxy = true; req.req.socket = {}; req.header['x-forwarded-proto'] = 'https, http'; - assert.equal(req.protocol, 'https'); + assert.strictEqual(req.protocol, 'https'); }); describe('and X-Forwarded-Proto is empty', () => { @@ -37,7 +37,7 @@ describe('req.protocol', () => { req.app.proxy = true; req.req.socket = {}; req.header['x-forwarded-proto'] = ''; - assert.equal(req.protocol, 'http'); + assert.strictEqual(req.protocol, 'http'); }); }); }); @@ -47,7 +47,7 @@ describe('req.protocol', () => { const req = request(); req.req.socket = {}; req.header['x-forwarded-proto'] = 'https, http'; - assert.equal(req.protocol, 'http'); + assert.strictEqual(req.protocol, 'http'); }); }); }); diff --git a/test/request/query.js b/test/request/query.js index 217f98bf1..6b8eecd36 100644 --- a/test/request/query.js +++ b/test/request/query.js @@ -14,13 +14,13 @@ describe('ctx.query', () => { it('should return the same object each time it\'s accessed', () => { const ctx = context({ url: '/' }); ctx.query.a = '2'; - assert.equal(ctx.query.a, '2'); + assert.strictEqual(ctx.query.a, '2'); }); }); it('should return a parsed query string', () => { const ctx = context({ url: '/?page=2' }); - assert.equal(ctx.query.page, '2'); + assert.strictEqual(ctx.query.page, '2'); }); }); @@ -28,16 +28,16 @@ describe('ctx.query=', () => { it('should stringify and replace the query string and search', () => { const ctx = context({ url: '/store/shoes' }); ctx.query = { page: 2, color: 'blue' }; - assert.equal(ctx.url, '/store/shoes?page=2&color=blue'); - assert.equal(ctx.querystring, 'page=2&color=blue'); - assert.equal(ctx.search, '?page=2&color=blue'); + assert.strictEqual(ctx.url, '/store/shoes?page=2&color=blue'); + assert.strictEqual(ctx.querystring, 'page=2&color=blue'); + assert.strictEqual(ctx.search, '?page=2&color=blue'); }); it('should change .url but not .originalUrl', () => { const ctx = context({ url: '/store/shoes' }); ctx.query = { page: 2 }; - assert.equal(ctx.url, '/store/shoes?page=2'); - assert.equal(ctx.originalUrl, '/store/shoes'); - assert.equal(ctx.request.originalUrl, '/store/shoes'); + assert.strictEqual(ctx.url, '/store/shoes?page=2'); + assert.strictEqual(ctx.originalUrl, '/store/shoes'); + assert.strictEqual(ctx.request.originalUrl, '/store/shoes'); }); }); diff --git a/test/request/querystring.js b/test/request/querystring.js index 13287c16f..e2bbb6930 100644 --- a/test/request/querystring.js +++ b/test/request/querystring.js @@ -8,14 +8,14 @@ const parseurl = require('parseurl'); describe('ctx.querystring', () => { it('should return the querystring', () => { const ctx = context({ url: '/store/shoes?page=2&color=blue' }); - assert.equal(ctx.querystring, 'page=2&color=blue'); + assert.strictEqual(ctx.querystring, 'page=2&color=blue'); }); describe('when ctx.req not present', () => { it('should return an empty string', () => { const ctx = context(); ctx.request.req = null; - assert.equal(ctx.querystring, ''); + assert.strictEqual(ctx.querystring, ''); }); }); }); @@ -24,31 +24,31 @@ describe('ctx.querystring=', () => { it('should replace the querystring', () => { const ctx = context({ url: '/store/shoes' }); ctx.querystring = 'page=2&color=blue'; - assert.equal(ctx.url, '/store/shoes?page=2&color=blue'); - assert.equal(ctx.querystring, 'page=2&color=blue'); + assert.strictEqual(ctx.url, '/store/shoes?page=2&color=blue'); + assert.strictEqual(ctx.querystring, 'page=2&color=blue'); }); it('should update ctx.search and ctx.query', () => { const ctx = context({ url: '/store/shoes' }); ctx.querystring = 'page=2&color=blue'; - assert.equal(ctx.url, '/store/shoes?page=2&color=blue'); - assert.equal(ctx.search, '?page=2&color=blue'); - assert.equal(ctx.query.page, '2'); - assert.equal(ctx.query.color, 'blue'); + assert.strictEqual(ctx.url, '/store/shoes?page=2&color=blue'); + assert.strictEqual(ctx.search, '?page=2&color=blue'); + assert.strictEqual(ctx.query.page, '2'); + assert.strictEqual(ctx.query.color, 'blue'); }); it('should change .url but not .originalUrl', () => { const ctx = context({ url: '/store/shoes' }); ctx.querystring = 'page=2&color=blue'; - assert.equal(ctx.url, '/store/shoes?page=2&color=blue'); - assert.equal(ctx.originalUrl, '/store/shoes'); - assert.equal(ctx.request.originalUrl, '/store/shoes'); + assert.strictEqual(ctx.url, '/store/shoes?page=2&color=blue'); + assert.strictEqual(ctx.originalUrl, '/store/shoes'); + assert.strictEqual(ctx.request.originalUrl, '/store/shoes'); }); it('should not affect parseurl', () => { const ctx = context({ url: '/login?foo=bar' }); ctx.querystring = 'foo=bar'; const url = parseurl(ctx.req); - assert.equal(url.path, '/login?foo=bar'); + assert.strictEqual(url.path, '/login?foo=bar'); }); }); diff --git a/test/request/search.js b/test/request/search.js index 3efb66545..eaefeb0f7 100644 --- a/test/request/search.js +++ b/test/request/search.js @@ -8,31 +8,31 @@ describe('ctx.search=', () => { it('should replace the search', () => { const ctx = context({ url: '/store/shoes' }); ctx.search = '?page=2&color=blue'; - assert.equal(ctx.url, '/store/shoes?page=2&color=blue'); - assert.equal(ctx.search, '?page=2&color=blue'); + assert.strictEqual(ctx.url, '/store/shoes?page=2&color=blue'); + assert.strictEqual(ctx.search, '?page=2&color=blue'); }); it('should update ctx.querystring and ctx.query', () => { const ctx = context({ url: '/store/shoes' }); ctx.search = '?page=2&color=blue'; - assert.equal(ctx.url, '/store/shoes?page=2&color=blue'); - assert.equal(ctx.querystring, 'page=2&color=blue'); - assert.equal(ctx.query.page, '2'); - assert.equal(ctx.query.color, 'blue'); + assert.strictEqual(ctx.url, '/store/shoes?page=2&color=blue'); + assert.strictEqual(ctx.querystring, 'page=2&color=blue'); + assert.strictEqual(ctx.query.page, '2'); + assert.strictEqual(ctx.query.color, 'blue'); }); it('should change .url but not .originalUrl', () => { const ctx = context({ url: '/store/shoes' }); ctx.search = '?page=2&color=blue'; - assert.equal(ctx.url, '/store/shoes?page=2&color=blue'); - assert.equal(ctx.originalUrl, '/store/shoes'); - assert.equal(ctx.request.originalUrl, '/store/shoes'); + assert.strictEqual(ctx.url, '/store/shoes?page=2&color=blue'); + assert.strictEqual(ctx.originalUrl, '/store/shoes'); + assert.strictEqual(ctx.request.originalUrl, '/store/shoes'); }); describe('when missing', () => { it('should return ""', () => { const ctx = context({ url: '/store/shoes' }); - assert.equal(ctx.search, ''); + assert.strictEqual(ctx.search, ''); }); }); }); diff --git a/test/request/secure.js b/test/request/secure.js index aca7ebdd2..2eaf1dabe 100644 --- a/test/request/secure.js +++ b/test/request/secure.js @@ -8,6 +8,6 @@ describe('req.secure', () => { it('should return true when encrypted', () => { const req = request(); req.req.socket = { encrypted: true }; - assert.equal(req.secure, true); + assert.strictEqual(req.secure, true); }); }); diff --git a/test/request/stale.js b/test/request/stale.js index e7b1c3cc3..be41500f8 100644 --- a/test/request/stale.js +++ b/test/request/stale.js @@ -11,7 +11,7 @@ describe('req.stale', () => { ctx.method = 'GET'; ctx.req.headers['if-none-match'] = '"123"'; ctx.set('ETag', '"123"'); - assert.equal(ctx.fresh, true); - assert.equal(ctx.stale, false); + assert.strictEqual(ctx.fresh, true); + assert.strictEqual(ctx.stale, false); }); }); diff --git a/test/request/type.js b/test/request/type.js index 625ee8333..6927d6d25 100644 --- a/test/request/type.js +++ b/test/request/type.js @@ -8,11 +8,11 @@ describe('req.type', () => { it('should return type void of parameters', () => { const req = request(); req.header['content-type'] = 'text/html; charset=utf-8'; - assert.equal(req.type, 'text/html'); + assert.strictEqual(req.type, 'text/html'); }); it('should return empty string with no host present', () => { const req = request(); - assert.equal(req.type, ''); + assert.strictEqual(req.type, ''); }); }); diff --git a/test/response/append.js b/test/response/append.js index e40bd7515..0e9c4a0ba 100644 --- a/test/response/append.js +++ b/test/response/append.js @@ -28,7 +28,7 @@ describe('ctx.append(name, val)', () => { ctx.set('Link', ''); - assert.equal(ctx.response.header.link, ''); + assert.strictEqual(ctx.response.header.link, ''); }); it('should work with res.set(field, val) first', () => { diff --git a/test/response/attachment.js b/test/response/attachment.js index 450f74383..bea9356dc 100644 --- a/test/response/attachment.js +++ b/test/response/attachment.js @@ -12,7 +12,7 @@ describe('ctx.attachment([filename])', () => { const ctx = context(); ctx.attachment('path/to/tobi.png'); const str = 'attachment; filename="tobi.png"'; - assert.equal(ctx.response.header['content-disposition'], str); + assert.strictEqual(ctx.response.header['content-disposition'], str); }); }); @@ -20,7 +20,7 @@ describe('ctx.attachment([filename])', () => { it('should not set filename param', () => { const ctx = context(); ctx.attachment(); - assert.equal(ctx.response.header['content-disposition'], 'attachment'); + assert.strictEqual(ctx.response.header['content-disposition'], 'attachment'); }); }); @@ -29,7 +29,7 @@ describe('ctx.attachment([filename])', () => { const ctx = context(); ctx.attachment('path/to/include-no-ascii-char-中文名-ok.png'); const str = 'attachment; filename="include-no-ascii-char-???-ok.png"; filename*=UTF-8\'\'include-no-ascii-char-%E4%B8%AD%E6%96%87%E5%90%8D-ok.png'; - assert.equal(ctx.response.header['content-disposition'], str); + assert.strictEqual(ctx.response.header['content-disposition'], str); }); it('should work with http client', () => { @@ -61,7 +61,7 @@ describe('contentDisposition(filename, options)', () => { it('should default to true', () => { const ctx = context(); ctx.attachment('€ rates.pdf'); - assert.equal(ctx.response.header['content-disposition'], + assert.strictEqual(ctx.response.header['content-disposition'], 'attachment; filename="? rates.pdf"; filename*=UTF-8\'\'%E2%82%AC%20rates.pdf'); }); @@ -69,14 +69,14 @@ describe('contentDisposition(filename, options)', () => { it('should not generate ISO-8859-1 fallback', () => { const ctx = context(); ctx.attachment('£ and € rates.pdf', { fallback: false }); - assert.equal(ctx.response.header['content-disposition'], + assert.strictEqual(ctx.response.header['content-disposition'], 'attachment; filename*=UTF-8\'\'%C2%A3%20and%20%E2%82%AC%20rates.pdf'); }); it('should keep ISO-8859-1 filename', () => { const ctx = context(); ctx.attachment('£ rates.pdf', { fallback: false }); - assert.equal(ctx.response.header['content-disposition'], + assert.strictEqual(ctx.response.header['content-disposition'], 'attachment; filename="£ rates.pdf"'); }); }); @@ -85,14 +85,14 @@ describe('contentDisposition(filename, options)', () => { it('should generate ISO-8859-1 fallback', () => { const ctx = context(); ctx.attachment('£ and € rates.pdf', { fallback: true }); - assert.equal(ctx.response.header['content-disposition'], + assert.strictEqual(ctx.response.header['content-disposition'], 'attachment; filename="£ and ? rates.pdf"; filename*=UTF-8\'\'%C2%A3%20and%20%E2%82%AC%20rates.pdf'); }); it('should pass through ISO-8859-1 filename', () => { const ctx = context(); ctx.attachment('£ rates.pdf', { fallback: true }); - assert.equal(ctx.response.header['content-disposition'], + assert.strictEqual(ctx.response.header['content-disposition'], 'attachment; filename="£ rates.pdf"'); }); }); @@ -107,35 +107,35 @@ describe('contentDisposition(filename, options)', () => { it('should use as ISO-8859-1 fallback', () => { const ctx = context(); ctx.attachment('£ and € rates.pdf', { fallback: '£ and EURO rates.pdf' }); - assert.equal(ctx.response.header['content-disposition'], + assert.strictEqual(ctx.response.header['content-disposition'], 'attachment; filename="£ and EURO rates.pdf"; filename*=UTF-8\'\'%C2%A3%20and%20%E2%82%AC%20rates.pdf'); }); it('should use as fallback even when filename is ISO-8859-1', () => { const ctx = context(); ctx.attachment('"£ rates".pdf', { fallback: '£ rates.pdf' }); - assert.equal(ctx.response.header['content-disposition'], + assert.strictEqual(ctx.response.header['content-disposition'], 'attachment; filename="£ rates.pdf"; filename*=UTF-8\'\'%22%C2%A3%20rates%22.pdf'); }); it('should do nothing if equal to filename', () => { const ctx = context(); ctx.attachment('plans.pdf', { fallback: 'plans.pdf' }); - assert.equal(ctx.response.header['content-disposition'], + assert.strictEqual(ctx.response.header['content-disposition'], 'attachment; filename="plans.pdf"'); }); it('should use the basename of the string', () => { const ctx = context(); ctx.attachment('€ rates.pdf', { fallback: '/path/to/EURO rates.pdf' }); - assert.equal(ctx.response.header['content-disposition'], + assert.strictEqual(ctx.response.header['content-disposition'], 'attachment; filename="EURO rates.pdf"; filename*=UTF-8\'\'%E2%82%AC%20rates.pdf'); }); it('should do nothing without filename option', () => { const ctx = context(); ctx.attachment(undefined, { fallback: 'plans.pdf' }); - assert.equal(ctx.response.header['content-disposition'], + assert.strictEqual(ctx.response.header['content-disposition'], 'attachment'); }); }); @@ -145,7 +145,7 @@ describe('contentDisposition(filename, options)', () => { it('should default to attachment', () => { const ctx = context(); ctx.attachment(); - assert.equal(ctx.response.header['content-disposition'], + assert.strictEqual(ctx.response.header['content-disposition'], 'attachment'); }); @@ -164,21 +164,21 @@ describe('contentDisposition(filename, options)', () => { it('should create a header with inline type', () => { const ctx = context(); ctx.attachment(undefined, { type: 'inline' }); - assert.equal(ctx.response.header['content-disposition'], + assert.strictEqual(ctx.response.header['content-disposition'], 'inline'); }); it('should create a header with inline type and filename', () => { const ctx = context(); ctx.attachment('plans.pdf', { type: 'inline' }); - assert.equal(ctx.response.header['content-disposition'], + assert.strictEqual(ctx.response.header['content-disposition'], 'inline; filename="plans.pdf"'); }); it('should normalize type', () => { const ctx = context(); ctx.attachment(undefined, { type: 'INLINE' }); - assert.equal(ctx.response.header['content-disposition'], + assert.strictEqual(ctx.response.header['content-disposition'], 'inline'); }); }); diff --git a/test/response/body.js b/test/response/body.js index 9d5d57d9b..fce5676bb 100644 --- a/test/response/body.js +++ b/test/response/body.js @@ -12,7 +12,7 @@ describe('res.body=', () => { const res = response(); res.type = 'png'; res.body = Buffer.from('something'); - assert.equal('image/png', res.header['content-type']); + assert.strictEqual('image/png', res.header['content-type']); }); describe('when body is an object', () => { @@ -20,10 +20,10 @@ describe('res.body=', () => { const res = response(); res.body = 'hey'; - assert.equal('text/html; charset=utf-8', res.header['content-type']); + assert.strictEqual('text/html; charset=utf-8', res.header['content-type']); res.body = { foo: 'bar' }; - assert.equal('application/json; charset=utf-8', res.header['content-type']); + assert.strictEqual('application/json; charset=utf-8', res.header['content-type']); }); }); @@ -31,7 +31,7 @@ describe('res.body=', () => { const res = response(); res.type = 'html'; res.body = 'something'; - assert.equal(res.length, 9); + assert.strictEqual(res.length, 9); }); }); @@ -39,20 +39,20 @@ describe('res.body=', () => { it('should default to text', () => { const res = response(); res.body = 'Tobi'; - assert.equal('text/plain; charset=utf-8', res.header['content-type']); + assert.strictEqual('text/plain; charset=utf-8', res.header['content-type']); }); it('should set length', () => { const res = response(); res.body = 'Tobi'; - assert.equal('4', res.header['content-length']); + assert.strictEqual('4', res.header['content-length']); }); describe('and contains a non-leading <', () => { it('should default to text', () => { const res = response(); res.body = 'aklsdjf < klajsdlfjasd'; - assert.equal('text/plain; charset=utf-8', res.header['content-type']); + assert.strictEqual('text/plain; charset=utf-8', res.header['content-type']); }); }); }); @@ -61,14 +61,14 @@ describe('res.body=', () => { it('should default to html', () => { const res = response(); res.body = '

Tobi

'; - assert.equal('text/html; charset=utf-8', res.header['content-type']); + assert.strictEqual('text/html; charset=utf-8', res.header['content-type']); }); it('should set length', () => { const string = '

Tobi

'; const res = response(); res.body = string; - assert.equal(res.length, Buffer.byteLength(string)); + assert.strictEqual(res.length, Buffer.byteLength(string)); }); it('should set length when body is overridden', () => { @@ -76,14 +76,14 @@ describe('res.body=', () => { const res = response(); res.body = string; res.body = string + string; - assert.equal(res.length, 2 * Buffer.byteLength(string)); + assert.strictEqual(res.length, 2 * Buffer.byteLength(string)); }); describe('when it contains leading whitespace', () => { it('should default to html', () => { const res = response(); res.body = '

Tobi

'; - assert.equal('text/html; charset=utf-8', res.header['content-type']); + assert.strictEqual('text/html; charset=utf-8', res.header['content-type']); }); }); }); @@ -99,7 +99,7 @@ describe('res.body=', () => { const res = response(); res.body = '\n<俄语>данные'; - assert.equal('text/html; charset=utf-8', res.header['content-type']); + assert.strictEqual('text/html; charset=utf-8', res.header['content-type']); }); }); @@ -107,7 +107,7 @@ describe('res.body=', () => { it('should default to an octet stream', () => { const res = response(); res.body = fs.createReadStream('LICENSE'); - assert.equal('application/octet-stream', res.header['content-type']); + assert.strictEqual('application/octet-stream', res.header['content-type']); }); it('should add error handler to the stream, but only once', () => { @@ -125,13 +125,13 @@ describe('res.body=', () => { it('should default to an octet stream', () => { const res = response(); res.body = Buffer.from('hey'); - assert.equal('application/octet-stream', res.header['content-type']); + assert.strictEqual('application/octet-stream', res.header['content-type']); }); it('should set length', () => { const res = response(); res.body = Buffer.from('Tobi'); - assert.equal('4', res.header['content-length']); + assert.strictEqual('4', res.header['content-length']); }); }); @@ -139,7 +139,7 @@ describe('res.body=', () => { it('should default to json', () => { const res = response(); res.body = { foo: 'bar' }; - assert.equal('application/json; charset=utf-8', res.header['content-type']); + assert.strictEqual('application/json; charset=utf-8', res.header['content-type']); }); }); }); diff --git a/test/response/etag.js b/test/response/etag.js index a67ecdb72..81b41e854 100644 --- a/test/response/etag.js +++ b/test/response/etag.js @@ -8,19 +8,19 @@ describe('res.etag=', () => { it('should not modify an etag with quotes', () => { const res = response(); res.etag = '"asdf"'; - assert.equal(res.header.etag, '"asdf"'); + assert.strictEqual(res.header.etag, '"asdf"'); }); it('should not modify a weak etag', () => { const res = response(); res.etag = 'W/"asdf"'; - assert.equal(res.header.etag, 'W/"asdf"'); + assert.strictEqual(res.header.etag, 'W/"asdf"'); }); it('should add quotes around an etag if necessary', () => { const res = response(); res.etag = 'asdf'; - assert.equal(res.header.etag, '"asdf"'); + assert.strictEqual(res.header.etag, '"asdf"'); }); }); @@ -28,6 +28,6 @@ describe('res.etag', () => { it('should return etag', () => { const res = response(); res.etag = '"asdf"'; - assert.equal(res.etag, '"asdf"'); + assert.strictEqual(res.etag, '"asdf"'); }); }); diff --git a/test/response/flushHeaders.js b/test/response/flushHeaders.js index 4f2c2e50e..0f205cb9a 100644 --- a/test/response/flushHeaders.js +++ b/test/response/flushHeaders.js @@ -14,7 +14,7 @@ describe('ctx.flushHeaders()', () => { ctx.body = 'Body'; ctx.status = 200; ctx.flushHeaders(); - assert.equal(ctx.res.headersSent, true); + assert.strictEqual(ctx.res.headersSent, true); }); const server = app.listen(); @@ -80,8 +80,8 @@ describe('ctx.flushHeaders()', () => { .expect(401) .expect('Content-Type', 'text/plain'); - assert.equal(res.headers['x-shouldnt-work'], undefined, 'header set after flushHeaders'); - assert.equal(res.headers.vary, undefined, 'header set after flushHeaders'); + assert.strictEqual(res.headers['x-shouldnt-work'], undefined, 'header set after flushHeaders'); + assert.strictEqual(res.headers.vary, undefined, 'header set after flushHeaders'); }); it('should flush headers first and delay to send data', done => { diff --git a/test/response/inspect.js b/test/response/inspect.js index be7cbeb2b..e2be1e91e 100644 --- a/test/response/inspect.js +++ b/test/response/inspect.js @@ -11,8 +11,8 @@ describe('res.inspect()', () => { const res = response(); res.body = 'hello'; delete res.res; - assert.equal(res.inspect(), null); - assert.equal(util.inspect(res), 'undefined'); + assert.strictEqual(res.inspect(), null); + assert.strictEqual(util.inspect(res), 'undefined'); }); }); diff --git a/test/response/is.js b/test/response/is.js index b1dcccf8c..7faca1747 100644 --- a/test/response/is.js +++ b/test/response/is.js @@ -9,15 +9,15 @@ describe('response.is(type)', () => { const res = context().response; res.type = 'text/html; charset=utf-8'; - assert.equal(res.is('text/*'), 'text/html'); + assert.strictEqual(res.is('text/*'), 'text/html'); }); describe('when no type is set', () => { it('should return false', () => { const res = context().response; - assert.equal(res.is(), false); - assert.equal(res.is('html'), false); + assert.strictEqual(res.is(), false); + assert.strictEqual(res.is('html'), false); }); }); @@ -26,7 +26,7 @@ describe('response.is(type)', () => { const res = context().response; res.type = 'text/html; charset=utf-8'; - assert.equal(res.is(), 'text/html'); + assert.strictEqual(res.is(), 'text/html'); }); }); @@ -35,17 +35,17 @@ describe('response.is(type)', () => { const res = context().response; res.type = 'image/png'; - assert.equal(res.is('png'), 'png'); - assert.equal(res.is('.png'), '.png'); - assert.equal(res.is('image/png'), 'image/png'); - assert.equal(res.is('image/*'), 'image/png'); - assert.equal(res.is('*/png'), 'image/png'); - - assert.equal(res.is('jpeg'), false); - assert.equal(res.is('.jpeg'), false); - assert.equal(res.is('image/jpeg'), false); - assert.equal(res.is('text/*'), false); - assert.equal(res.is('*/jpeg'), false); + assert.strictEqual(res.is('png'), 'png'); + assert.strictEqual(res.is('.png'), '.png'); + assert.strictEqual(res.is('image/png'), 'image/png'); + assert.strictEqual(res.is('image/*'), 'image/png'); + assert.strictEqual(res.is('*/png'), 'image/png'); + + assert.strictEqual(res.is('jpeg'), false); + assert.strictEqual(res.is('.jpeg'), false); + assert.strictEqual(res.is('image/jpeg'), false); + assert.strictEqual(res.is('text/*'), false); + assert.strictEqual(res.is('*/jpeg'), false); }); }); @@ -54,22 +54,22 @@ describe('response.is(type)', () => { const res = context().response; res.type = 'image/png'; - assert.equal(res.is('png'), 'png'); - assert.equal(res.is('.png'), '.png'); - assert.equal(res.is('text/*', 'image/*'), 'image/png'); - assert.equal(res.is('image/*', 'text/*'), 'image/png'); - assert.equal(res.is('image/*', 'image/png'), 'image/png'); - assert.equal(res.is('image/png', 'image/*'), 'image/png'); - - assert.equal(res.is(['text/*', 'image/*']), 'image/png'); - assert.equal(res.is(['image/*', 'text/*']), 'image/png'); - assert.equal(res.is(['image/*', 'image/png']), 'image/png'); - assert.equal(res.is(['image/png', 'image/*']), 'image/png'); - - assert.equal(res.is('jpeg'), false); - assert.equal(res.is('.jpeg'), false); - assert.equal(res.is('text/*', 'application/*'), false); - assert.equal(res.is('text/html', 'text/plain', 'application/json; charset=utf-8'), false); + assert.strictEqual(res.is('png'), 'png'); + assert.strictEqual(res.is('.png'), '.png'); + assert.strictEqual(res.is('text/*', 'image/*'), 'image/png'); + assert.strictEqual(res.is('image/*', 'text/*'), 'image/png'); + assert.strictEqual(res.is('image/*', 'image/png'), 'image/png'); + assert.strictEqual(res.is('image/png', 'image/*'), 'image/png'); + + assert.strictEqual(res.is(['text/*', 'image/*']), 'image/png'); + assert.strictEqual(res.is(['image/*', 'text/*']), 'image/png'); + assert.strictEqual(res.is(['image/*', 'image/png']), 'image/png'); + assert.strictEqual(res.is(['image/png', 'image/*']), 'image/png'); + + assert.strictEqual(res.is('jpeg'), false); + assert.strictEqual(res.is('.jpeg'), false); + assert.strictEqual(res.is('text/*', 'application/*'), false); + assert.strictEqual(res.is('text/html', 'text/plain', 'application/json; charset=utf-8'), false); }); }); @@ -78,9 +78,9 @@ describe('response.is(type)', () => { const res = context().response; res.type = 'application/x-www-form-urlencoded'; - assert.equal(res.is('urlencoded'), 'urlencoded'); - assert.equal(res.is('json', 'urlencoded'), 'urlencoded'); - assert.equal(res.is('urlencoded', 'json'), 'urlencoded'); + assert.strictEqual(res.is('urlencoded'), 'urlencoded'); + assert.strictEqual(res.is('json', 'urlencoded'), 'urlencoded'); + assert.strictEqual(res.is('urlencoded', 'json'), 'urlencoded'); }); }); }); diff --git a/test/response/last-modified.js b/test/response/last-modified.js index 9bfd6029c..9e5fa4b39 100644 --- a/test/response/last-modified.js +++ b/test/response/last-modified.js @@ -9,14 +9,14 @@ describe('res.lastModified', () => { const res = response(); const date = new Date(); res.lastModified = date; - assert.equal(res.header['last-modified'], date.toUTCString()); + assert.strictEqual(res.header['last-modified'], date.toUTCString()); }); it('should work with date strings', () => { const res = response(); const date = new Date(); res.lastModified = date.toString(); - assert.equal(res.header['last-modified'], date.toUTCString()); + assert.strictEqual(res.header['last-modified'], date.toUTCString()); }); it('should get the header as a Date', () => { @@ -24,13 +24,13 @@ describe('res.lastModified', () => { const res = response(); const date = new Date(); res.lastModified = date; - assert.equal((res.lastModified.getTime() / 1000), Math.floor(date.getTime() / 1000)); + assert.strictEqual((res.lastModified.getTime() / 1000), Math.floor(date.getTime() / 1000)); }); describe('when lastModified not set', () => { it('should get undefined', () => { const res = response(); - assert.equal(res.lastModified, undefined); + assert.strictEqual(res.lastModified, undefined); }); }); }); diff --git a/test/response/length.js b/test/response/length.js index d64cfb329..6a45dca8b 100644 --- a/test/response/length.js +++ b/test/response/length.js @@ -10,14 +10,14 @@ describe('res.length', () => { it('should return a number', () => { const res = response(); res.set('Content-Length', '1024'); - assert.equal(res.length, 1024); + assert.strictEqual(res.length, 1024); }); describe('but not number', () => { it('should return 0', () => { const res = response(); res.set('Content-Length', 'hey'); - assert.equal(res.length, 0); + assert.strictEqual(res.length, 0); }); }); }); @@ -29,37 +29,37 @@ describe('res.length', () => { res.body = 'foo'; res.remove('Content-Length'); - assert.equal(res.length, 3); + assert.strictEqual(res.length, 3); res.body = 'foo'; - assert.equal(res.length, 3); + assert.strictEqual(res.length, 3); res.body = Buffer.from('foo bar'); res.remove('Content-Length'); - assert.equal(res.length, 7); + assert.strictEqual(res.length, 7); res.body = Buffer.from('foo bar'); - assert.equal(res.length, 7); + assert.strictEqual(res.length, 7); res.body = { hello: 'world' }; res.remove('Content-Length'); - assert.equal(res.length, 17); + assert.strictEqual(res.length, 17); res.body = { hello: 'world' }; - assert.equal(res.length, 17); + assert.strictEqual(res.length, 17); res.body = fs.createReadStream('package.json'); - assert.equal(res.length, undefined); + assert.strictEqual(res.length, undefined); res.body = null; - assert.equal(res.length, undefined); + assert.strictEqual(res.length, undefined); }); }); describe('and .body is not', () => { it('should return undefined', () => { const res = response(); - assert.equal(res.length, undefined); + assert.strictEqual(res.length, undefined); }); }); }); diff --git a/test/response/message.js b/test/response/message.js index d310d89d0..615a37d90 100644 --- a/test/response/message.js +++ b/test/response/message.js @@ -8,14 +8,14 @@ describe('res.message', () => { it('should return the response status message', () => { const res = response(); res.status = 200; - assert.equal(res.message, 'OK'); + assert.strictEqual(res.message, 'OK'); }); describe('when res.message not present', () => { it('should look up in statuses', () => { const res = response(); res.res.statusCode = 200; - assert.equal(res.message, 'OK'); + assert.strictEqual(res.message, 'OK'); }); }); }); @@ -25,7 +25,7 @@ describe('res.message=', () => { const res = response(); res.status = 200; res.message = 'ok'; - assert.equal(res.res.statusMessage, 'ok'); - assert.equal(res.inspect().message, 'ok'); + assert.strictEqual(res.res.statusMessage, 'ok'); + assert.strictEqual(res.inspect().message, 'ok'); }); }); diff --git a/test/response/redirect.js b/test/response/redirect.js index e9a29ac63..bc0fd3c8a 100644 --- a/test/response/redirect.js +++ b/test/response/redirect.js @@ -10,8 +10,8 @@ describe('ctx.redirect(url)', () => { it('should redirect to the given url', () => { const ctx = context(); ctx.redirect('http://google.com'); - assert.equal(ctx.response.header.location, 'http://google.com'); - assert.equal(ctx.status, 302); + assert.strictEqual(ctx.response.header.location, 'http://google.com'); + assert.strictEqual(ctx.status, 302); }); it('should auto fix not encode url', done => { @@ -25,8 +25,8 @@ describe('ctx.redirect(url)', () => { .get('/') .end((err, res) => { if (err) return done(err); - assert.equal(res.status, 302); - assert.equal(res.headers.location, 'http://google.com/%F0%9F%98%93'); + assert.strictEqual(res.status, 302); + assert.strictEqual(res.headers.location, 'http://google.com/%F0%9F%98%93'); done(); }); }); @@ -36,26 +36,26 @@ describe('ctx.redirect(url)', () => { const ctx = context(); ctx.req.headers.referrer = '/login'; ctx.redirect('back'); - assert.equal(ctx.response.header.location, '/login'); + assert.strictEqual(ctx.response.header.location, '/login'); }); it('should redirect to Referer', () => { const ctx = context(); ctx.req.headers.referer = '/login'; ctx.redirect('back'); - assert.equal(ctx.response.header.location, '/login'); + assert.strictEqual(ctx.response.header.location, '/login'); }); it('should default to alt', () => { const ctx = context(); ctx.redirect('back', '/index.html'); - assert.equal(ctx.response.header.location, '/index.html'); + assert.strictEqual(ctx.response.header.location, '/index.html'); }); it('should default redirect to /', () => { const ctx = context(); ctx.redirect('back'); - assert.equal(ctx.response.header.location, '/'); + assert.strictEqual(ctx.response.header.location, '/'); }); }); @@ -65,8 +65,8 @@ describe('ctx.redirect(url)', () => { const url = 'http://google.com'; ctx.header.accept = 'text/html'; ctx.redirect(url); - assert.equal(ctx.response.header['content-type'], 'text/html; charset=utf-8'); - assert.equal(ctx.body, `Redirecting to ${url}.`); + assert.strictEqual(ctx.response.header['content-type'], 'text/html; charset=utf-8'); + assert.strictEqual(ctx.body, `Redirecting to ${url}.`); }); it('should escape the url', () => { @@ -75,8 +75,8 @@ describe('ctx.redirect(url)', () => { ctx.header.accept = 'text/html'; ctx.redirect(url); url = escape(url); - assert.equal(ctx.response.header['content-type'], 'text/html; charset=utf-8'); - assert.equal(ctx.body, `Redirecting to ${url}.`); + assert.strictEqual(ctx.response.header['content-type'], 'text/html; charset=utf-8'); + assert.strictEqual(ctx.body, `Redirecting to ${url}.`); }); }); @@ -86,7 +86,7 @@ describe('ctx.redirect(url)', () => { const url = 'http://google.com'; ctx.header.accept = 'text/plain'; ctx.redirect(url); - assert.equal(ctx.body, `Redirecting to ${url}.`); + assert.strictEqual(ctx.body, `Redirecting to ${url}.`); }); }); @@ -97,8 +97,8 @@ describe('ctx.redirect(url)', () => { ctx.status = 301; ctx.header.accept = 'text/plain'; ctx.redirect('http://google.com'); - assert.equal(ctx.status, 301); - assert.equal(ctx.body, `Redirecting to ${url}.`); + assert.strictEqual(ctx.status, 301); + assert.strictEqual(ctx.body, `Redirecting to ${url}.`); }); }); @@ -109,8 +109,8 @@ describe('ctx.redirect(url)', () => { ctx.status = 304; ctx.header.accept = 'text/plain'; ctx.redirect('http://google.com'); - assert.equal(ctx.status, 302); - assert.equal(ctx.body, `Redirecting to ${url}.`); + assert.strictEqual(ctx.status, 302); + assert.strictEqual(ctx.body, `Redirecting to ${url}.`); }); }); @@ -121,9 +121,9 @@ describe('ctx.redirect(url)', () => { const url = 'http://google.com'; ctx.header.accept = 'text/plain'; ctx.redirect('http://google.com'); - assert.equal(ctx.status, 302); - assert.equal(ctx.body, `Redirecting to ${url}.`); - assert.equal(ctx.type, 'text/plain'); + assert.strictEqual(ctx.status, 302); + assert.strictEqual(ctx.body, `Redirecting to ${url}.`); + assert.strictEqual(ctx.type, 'text/plain'); }); }); }); diff --git a/test/response/set.js b/test/response/set.js index 22e9a3dd8..4902e7799 100644 --- a/test/response/set.js +++ b/test/response/set.js @@ -8,19 +8,19 @@ describe('ctx.set(name, val)', () => { it('should set a field value', () => { const ctx = context(); ctx.set('x-foo', 'bar'); - assert.equal(ctx.response.header['x-foo'], 'bar'); + assert.strictEqual(ctx.response.header['x-foo'], 'bar'); }); it('should coerce number to string', () => { const ctx = context(); ctx.set('x-foo', 5); - assert.equal(ctx.response.header['x-foo'], '5'); + assert.strictEqual(ctx.response.header['x-foo'], '5'); }); it('should coerce undefined to string', () => { const ctx = context(); ctx.set('x-foo', undefined); - assert.equal(ctx.response.header['x-foo'], 'undefined'); + assert.strictEqual(ctx.response.header['x-foo'], 'undefined'); }); it('should set a field value of array', () => { @@ -39,7 +39,7 @@ describe('ctx.set(object)', () => { bar: '2' }); - assert.equal(ctx.response.header.foo, '1'); - assert.equal(ctx.response.header.bar, '2'); + assert.strictEqual(ctx.response.header.foo, '1'); + assert.strictEqual(ctx.response.header.bar, '2'); }); }); diff --git a/test/response/socket.js b/test/response/socket.js index 6061e1dac..27c3ff0d8 100644 --- a/test/response/socket.js +++ b/test/response/socket.js @@ -8,6 +8,6 @@ const Stream = require('stream'); describe('res.socket', () => { it('should return the request socket object', () => { const res = response(); - assert.equal(res.socket instanceof Stream, true); + assert.strictEqual(res.socket instanceof Stream, true); }); }); diff --git a/test/response/status.js b/test/response/status.js index c4d6fe0fc..8b9fd35fe 100644 --- a/test/response/status.js +++ b/test/response/status.js @@ -13,7 +13,7 @@ describe('res.status=', () => { it('should set the status', () => { const res = response(); res.status = 403; - assert.equal(res.status, 403); + assert.strictEqual(res.status, 403); }); it('should not throw', () => { @@ -35,7 +35,7 @@ describe('res.status=', () => { it('should set the status', () => { const res = response(); res.status = 700; - assert.equal(res.status, 700); + assert.strictEqual(res.status, 700); }); it('should not throw', () => { @@ -80,10 +80,10 @@ describe('res.status=', () => { .get('/') .expect(status); - assert.equal(res.headers.hasOwnProperty('content-type'), false); - assert.equal(res.headers.hasOwnProperty('content-length'), false); - assert.equal(res.headers.hasOwnProperty('content-encoding'), false); - assert.equal(res.text.length, 0); + assert.strictEqual(res.headers.hasOwnProperty('content-type'), false); + assert.strictEqual(res.headers.hasOwnProperty('content-length'), false); + assert.strictEqual(res.headers.hasOwnProperty('content-encoding'), false); + assert.strictEqual(res.text.length, 0); }); it('should strip content related header fields after status set', async() => { @@ -101,10 +101,10 @@ describe('res.status=', () => { .get('/') .expect(status); - assert.equal(res.headers.hasOwnProperty('content-type'), false); - assert.equal(res.headers.hasOwnProperty('content-length'), false); - assert.equal(res.headers.hasOwnProperty('content-encoding'), false); - assert.equal(res.text.length, 0); + assert.strictEqual(res.headers.hasOwnProperty('content-type'), false); + assert.strictEqual(res.headers.hasOwnProperty('content-length'), false); + assert.strictEqual(res.headers.hasOwnProperty('content-encoding'), false); + assert.strictEqual(res.text.length, 0); }); } diff --git a/test/response/type.js b/test/response/type.js index f19b44b5f..cb98df384 100644 --- a/test/response/type.js +++ b/test/response/type.js @@ -9,8 +9,8 @@ describe('ctx.type=', () => { it('should set the Content-Type', () => { const ctx = context(); ctx.type = 'text/plain'; - assert.equal(ctx.type, 'text/plain'); - assert.equal(ctx.response.header['content-type'], 'text/plain; charset=utf-8'); + assert.strictEqual(ctx.type, 'text/plain'); + assert.strictEqual(ctx.response.header['content-type'], 'text/plain; charset=utf-8'); }); }); @@ -18,8 +18,8 @@ describe('ctx.type=', () => { it('should lookup the mime', () => { const ctx = context(); ctx.type = 'json'; - assert.equal(ctx.type, 'application/json'); - assert.equal(ctx.response.header['content-type'], 'application/json; charset=utf-8'); + assert.strictEqual(ctx.type, 'application/json'); + assert.strictEqual(ctx.response.header['content-type'], 'application/json; charset=utf-8'); }); }); @@ -27,8 +27,8 @@ describe('ctx.type=', () => { it('should default the charset', () => { const ctx = context(); ctx.type = 'text/html'; - assert.equal(ctx.type, 'text/html'); - assert.equal(ctx.response.header['content-type'], 'text/html; charset=utf-8'); + assert.strictEqual(ctx.type, 'text/html'); + assert.strictEqual(ctx.response.header['content-type'], 'text/html; charset=utf-8'); }); }); @@ -36,8 +36,8 @@ describe('ctx.type=', () => { it('should not default the charset', () => { const ctx = context(); ctx.type = 'text/html; charset=foo'; - assert.equal(ctx.type, 'text/html'); - assert.equal(ctx.response.header['content-type'], 'text/html; charset=foo'); + assert.strictEqual(ctx.type, 'text/html'); + assert.strictEqual(ctx.response.header['content-type'], 'text/html; charset=foo'); }); }); @@ -63,7 +63,7 @@ describe('ctx.type', () => { it('should return the mime', () => { const ctx = context(); ctx.type = 'json'; - assert.equal(ctx.type, 'application/json'); + assert.strictEqual(ctx.type, 'application/json'); }); }); }); diff --git a/test/response/vary.js b/test/response/vary.js index 2b195cf19..074bcb099 100644 --- a/test/response/vary.js +++ b/test/response/vary.js @@ -9,7 +9,7 @@ describe('ctx.vary(field)', () => { it('should set it', () => { const ctx = context(); ctx.vary('Accept'); - assert.equal(ctx.response.header.vary, 'Accept'); + assert.strictEqual(ctx.response.header.vary, 'Accept'); }); }); @@ -18,7 +18,7 @@ describe('ctx.vary(field)', () => { const ctx = context(); ctx.vary('Accept'); ctx.vary('Accept-Encoding'); - assert.equal(ctx.response.header.vary, 'Accept, Accept-Encoding'); + assert.strictEqual(ctx.response.header.vary, 'Accept, Accept-Encoding'); }); }); @@ -29,7 +29,7 @@ describe('ctx.vary(field)', () => { ctx.vary('Accept-Encoding'); ctx.vary('Accept'); ctx.vary('Accept-Encoding'); - assert.equal(ctx.response.header.vary, 'Accept, Accept-Encoding'); + assert.strictEqual(ctx.response.header.vary, 'Accept, Accept-Encoding'); }); }); }); diff --git a/test/response/writable.js b/test/response/writable.js index 40b75ead3..7d6cf3bbc 100644 --- a/test/response/writable.js +++ b/test/response/writable.js @@ -32,8 +32,8 @@ describe('res.writable', () => { const server = app.listen(); requestTwice(server, (_, datas) => { const responses = Buffer.concat(datas).toString(); - assert.equal(/request 1, writable: true/.test(responses), true); - assert.equal(/request 2, writable: true/.test(responses), true); + assert.strictEqual(/request 1, writable: true/.test(responses), true); + assert.strictEqual(/request 2, writable: true/.test(responses), true); done(); }); });