Skip to content

Commit

Permalink
migrate assert.strict => .strictEqual
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanong committed Aug 18, 2021
1 parent be3e8b6 commit 596cfd5
Show file tree
Hide file tree
Showing 50 changed files with 403 additions and 403 deletions.
4 changes: 2 additions & 2 deletions test/application/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});

Expand All @@ -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;
});

Expand Down
4 changes: 2 additions & 2 deletions test/application/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('app', () => {
});

app.on('error', err => {
assert.equal(err.message, 'boom');
assert.strictEqual(err.message, 'boom');
done();
});

Expand Down Expand Up @@ -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', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/application/inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
4 changes: 2 additions & 2 deletions test/application/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});

Expand All @@ -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;
});

Expand Down
52 changes: 26 additions & 26 deletions test/application/respond.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});

Expand All @@ -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);
});

Expand All @@ -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);
});

Expand All @@ -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);
});

Expand All @@ -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);
});

Expand All @@ -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);
});

Expand Down Expand Up @@ -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);
});
});

Expand All @@ -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);
});
});

Expand All @@ -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);
});
});

Expand All @@ -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');
});
});

Expand All @@ -407,7 +407,7 @@ describe('app.respond', () => {
.expect(200)
.expect('ok');

assert.equal(res.res.statusMessage, 'ok');
assert.strictEqual(res.res.statusMessage, 'ok');
});
});

Expand Down Expand Up @@ -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() => {
Expand All @@ -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() => {
Expand All @@ -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() => {
Expand All @@ -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);
});
});

Expand Down Expand Up @@ -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);
});

Expand All @@ -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);
});

Expand All @@ -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);
});

Expand All @@ -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);
});

Expand Down Expand Up @@ -716,7 +716,7 @@ describe('app.respond', () => {
});

app.on('error', err => {
assert.equal(err.message, 'boom');
assert.strictEqual(err.message, 'boom');
done();
});

Expand Down Expand Up @@ -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);
});
});

Expand Down Expand Up @@ -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);
});
});
});
6 changes: 3 additions & 3 deletions test/application/response.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});

Expand All @@ -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;
});

Expand All @@ -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() => {
Expand Down
2 changes: 1 addition & 1 deletion test/context/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
Expand Down
12 changes: 6 additions & 6 deletions test/context/cookies.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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);
});
});

Expand All @@ -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);
});
});
});
Expand Down
16 changes: 8 additions & 8 deletions test/context/onerror.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() => {
Expand Down Expand Up @@ -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();
});

Expand Down Expand Up @@ -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();
});

Expand Down
Loading

0 comments on commit 596cfd5

Please sign in to comment.