From c15ffefd9a80d167c54483189277fc6a2904f620 Mon Sep 17 00:00:00 2001 From: Justin Beckwith Date: Wed, 25 Jul 2018 09:49:35 -0700 Subject: [PATCH] test: use strictEqual in tests (#1246) --- package-lock.json | 52 ++++-------------- test/samples/test.samples.youtube.ts | 2 +- test/test.apikey.ts | 9 +-- test/test.auth.ts | 66 +++++++++++----------- test/test.clients.ts | 40 +++++++------- test/test.discover.ts | 12 ++-- test/test.drive.v2.ts | 30 +++++----- test/test.media.ts | 82 +++++++++++++++------------- test/test.options.ts | 33 +++++------ test/test.path.ts | 32 +++++------ test/test.query.ts | 46 ++++++++-------- test/test.transporters.ts | 34 ++++++------ test/test.urlshortener.v1.ts | 8 +-- 13 files changed, 214 insertions(+), 232 deletions(-) diff --git a/package-lock.json b/package-lock.json index ac2cfc5d85a..28bc3d3eace 100644 --- a/package-lock.json +++ b/package-lock.json @@ -433,7 +433,6 @@ "resolved": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz", "integrity": "sha1-DNkKVhCT810KmSVsIrcGlDP60Rc=", "dev": true, - "optional": true, "requires": { "kind-of": "^3.0.2", "longest": "^1.0.1", @@ -445,7 +444,6 @@ "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, - "optional": true, "requires": { "is-buffer": "^1.1.5" } @@ -518,15 +516,13 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", - "dev": true, - "optional": true + "dev": true }, "arr-flatten": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", - "dev": true, - "optional": true + "dev": true }, "arr-union": { "version": "3.1.0", @@ -870,7 +866,6 @@ "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz", "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", "dev": true, - "optional": true, "requires": { "arr-flatten": "^1.1.0", "array-unique": "^0.3.2", @@ -889,7 +884,6 @@ "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, - "optional": true, "requires": { "is-extendable": "^0.1.0" } @@ -2618,7 +2612,6 @@ "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", "dev": true, - "optional": true, "requires": { "extend-shallow": "^2.0.1", "is-number": "^3.0.0", @@ -2631,7 +2624,6 @@ "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, - "optional": true, "requires": { "is-extendable": "^0.1.0" } @@ -2739,7 +2731,6 @@ "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz", "integrity": "sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk=", "dev": true, - "optional": true, "requires": { "map-cache": "^0.2.2" } @@ -2787,8 +2778,7 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "aproba": { "version": "1.2.0", @@ -3190,8 +3180,7 @@ "safe-buffer": { "version": "5.1.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "safer-buffer": { "version": "2.1.2", @@ -3246,7 +3235,6 @@ "version": "3.0.1", "bundled": true, "dev": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -3290,14 +3278,12 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "yallist": { "version": "3.0.2", "bundled": true, - "dev": true, - "optional": true + "dev": true } } }, @@ -3942,8 +3928,7 @@ "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", - "dev": true, - "optional": true + "dev": true }, "is-fullwidth-code-point": { "version": "2.0.0", @@ -4378,8 +4363,7 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz", "integrity": "sha1-MKCy2jj3N3DoKUoNIuZiXtd9AJc=", - "dev": true, - "optional": true + "dev": true }, "loose-envify": { "version": "1.4.0", @@ -4901,7 +4885,6 @@ "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", "dev": true, - "optional": true, "requires": { "remove-trailing-separator": "^1.0.1" } @@ -5075,7 +5058,6 @@ "version": "0.1.4", "bundled": true, "dev": true, - "optional": true, "requires": { "kind-of": "^3.0.2", "longest": "^1.0.1", @@ -6018,8 +6000,7 @@ "longest": { "version": "1.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "lru-cache": { "version": "4.1.3", @@ -7154,7 +7135,6 @@ "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz", "integrity": "sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c=", "dev": true, - "optional": true, "requires": { "isobject": "^3.0.1" } @@ -7761,15 +7741,13 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", "integrity": "sha1-wkvOKig62tW8P1jg1IJJuSN52O8=", - "dev": true, - "optional": true + "dev": true }, "repeat-element": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.2.tgz", "integrity": "sha1-7wiaF40Ug7quTZPrmLT55OEdmQo=", - "dev": true, - "optional": true + "dev": true }, "repeat-string": { "version": "1.6.1", @@ -8181,7 +8159,6 @@ "resolved": "https://registry.npmjs.org/snapdragon-node/-/snapdragon-node-2.1.1.tgz", "integrity": "sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw==", "dev": true, - "optional": true, "requires": { "define-property": "^1.0.0", "isobject": "^3.0.0", @@ -8193,7 +8170,6 @@ "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", "dev": true, - "optional": true, "requires": { "is-descriptor": "^1.0.0" } @@ -8203,7 +8179,6 @@ "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", "dev": true, - "optional": true, "requires": { "kind-of": "^6.0.0" } @@ -8213,7 +8188,6 @@ "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", "dev": true, - "optional": true, "requires": { "kind-of": "^6.0.0" } @@ -8223,7 +8197,6 @@ "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", "dev": true, - "optional": true, "requires": { "is-accessor-descriptor": "^1.0.0", "is-data-descriptor": "^1.0.0", @@ -8237,7 +8210,6 @@ "resolved": "https://registry.npmjs.org/snapdragon-util/-/snapdragon-util-3.0.1.tgz", "integrity": "sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ==", "dev": true, - "optional": true, "requires": { "kind-of": "^3.2.0" }, @@ -8247,7 +8219,6 @@ "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, - "optional": true, "requires": { "is-buffer": "^1.1.5" } @@ -8643,7 +8614,6 @@ "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-2.1.1.tgz", "integrity": "sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg=", "dev": true, - "optional": true, "requires": { "is-number": "^3.0.0", "repeat-string": "^1.6.1" diff --git a/test/samples/test.samples.youtube.ts b/test/samples/test.samples.youtube.ts index 01019d966fd..6f4df926625 100644 --- a/test/samples/test.samples.youtube.ts +++ b/test/samples/test.samples.youtube.ts @@ -45,7 +45,7 @@ describe('YouTube samples', () => { .reply(200, {kind: 'youtube#video'}); const data = await samples.upload.runSample(someFile); assert(data); - assert.equal(data.kind, 'youtube#video'); + assert.strictEqual(data.kind, 'youtube#video'); scope.done(); }); }); diff --git a/test/test.apikey.ts b/test/test.apikey.ts index 47b9dcc85e0..16e3f9dba5a 100644 --- a/test/test.apikey.ts +++ b/test/test.apikey.ts @@ -23,20 +23,20 @@ import {Utils} from './utils'; async function testGet(drive: APIEndpoint) { nock(Utils.baseUrl).get('/drive/v2/files/123?key=APIKEY').reply(200); const res = await drive.files.get({fileId: '123', auth: 'APIKEY'}); - assert.equal(Utils.getQs(res), 'key=APIKEY'); + assert.strictEqual(Utils.getQs(res), 'key=APIKEY'); } async function testParams2(drive: APIEndpoint) { nock(Utils.baseUrl).get('/drive/v2/files/123?key=API%20KEY').reply(200); const res = await drive.files.get({fileId: '123', auth: 'API KEY'}); - assert.equal(Utils.getQs(res), 'key=API%20KEY'); + assert.strictEqual(Utils.getQs(res), 'key=API%20KEY'); } async function testKeyParam(drive: APIEndpoint) { nock(Utils.baseUrl).get('/drive/v2/files/123?key=abc123').reply(200); const res = await drive.files.get({fileId: '123', auth: 'API KEY', key: 'abc123'}); - assert.equal(Utils.getQs(res), 'key=abc123'); + assert.strictEqual(Utils.getQs(res), 'key=abc123'); } async function testAuthKey(urlshortener: APIEndpoint) { @@ -44,7 +44,8 @@ async function testAuthKey(urlshortener: APIEndpoint) { .get('/urlshortener/v1/url/history?key=YOUR%20API%20KEY') .reply(200); const res = await urlshortener.url.list({auth: 'YOUR API KEY'}); - assert.equal(Utils.getQs(res)!.indexOf('key=YOUR%20API%20KEY') > -1, true); + assert.strictEqual( + Utils.getQs(res)!.indexOf('key=YOUR%20API%20KEY') > -1, true); } describe('API key', () => { diff --git a/test/test.auth.ts b/test/test.auth.ts index 2d62066bcb6..d8d2446c7ce 100644 --- a/test/test.auth.ts +++ b/test/test.auth.ts @@ -29,35 +29,35 @@ describe('JWT client', () => { it('should create a jwt through googleapis', () => { const jwt = new googleapis.auth.JWT( 'someone@somewhere.com', 'file1', 'key1', 'scope1', 'subject1'); - assert.equal(jwt.email, 'someone@somewhere.com'); - assert.equal(jwt.keyFile, 'file1'); - assert.equal(jwt.key, 'key1'); - assert.equal(jwt.scopes, 'scope1'); - assert.equal(jwt.subject, 'subject1'); + assert.strictEqual(jwt.email, 'someone@somewhere.com'); + assert.strictEqual(jwt.keyFile, 'file1'); + assert.strictEqual(jwt.key, 'key1'); + assert.strictEqual(jwt.scopes, 'scope1'); + assert.strictEqual(jwt.subject, 'subject1'); }); it('should create scoped JWT', () => { const jwt = new googleapis.auth.JWT( 'someone@somewhere.com', 'file1', 'key1', undefined, 'subject1'); - assert.equal(jwt.scopes, null); - assert.equal(jwt.createScopedRequired(), true); + assert.strictEqual(jwt.scopes, undefined); + assert.strictEqual(jwt.createScopedRequired(), true); // Create a scoped version of the token now. const jwt2 = jwt.createScoped('scope1'); // The original token should be unchanged. - assert.equal(jwt.scopes, null); - assert.equal(jwt.createScopedRequired(), true); + assert.strictEqual(jwt.scopes, undefined); + assert.strictEqual(jwt.createScopedRequired(), true); // The new token should have scopes. - assert.equal(jwt2.scopes, 'scope1'); - assert.equal(jwt2.createScopedRequired(), false); + assert.strictEqual(jwt2.scopes, 'scope1'); + assert.strictEqual(jwt2.createScopedRequired(), false); }); }); describe('Compute client', () => { it('should create a computeclient', () => { const compute = new googleapis.auth.Compute(); - assert.equal(compute.createScopedRequired(), false); + assert.strictEqual(compute.createScopedRequired(), false); }); }); @@ -70,7 +70,7 @@ async function testNoTokens(urlshortener: APIEndpoint, client: OAuth2Client) { async function testNoBearer( urlshortener: APIEndpoint, oauth2client: OAuth2Client) { await urlshortener.url.list({auth: oauth2client}); - assert.equal(oauth2client.credentials.token_type, 'Bearer'); + assert.strictEqual(oauth2client.credentials.token_type, 'Bearer'); } async function testExpired( @@ -82,8 +82,8 @@ async function testExpired( if (!expiryDate) return; assert(expiryDate > now); assert(expiryDate < now + 5000); - assert.equal(oauth2client.credentials.refresh_token, 'abc'); - assert.equal(oauth2client.credentials.access_token, 'abc123'); + assert.strictEqual(oauth2client.credentials.refresh_token, 'abc'); + assert.strictEqual(oauth2client.credentials.access_token, 'abc123'); } async function testNoAccessToken( @@ -94,8 +94,8 @@ async function testNoAccessToken( assert.notEqual(expiryDate, undefined); assert(expiryDate! > now); assert(expiryDate! < now + 4000); - assert.equal(oauth2client.credentials.refresh_token, 'abc'); - assert.equal(oauth2client.credentials.access_token, 'abc123'); + assert.strictEqual(oauth2client.credentials.refresh_token, 'abc'); + assert.strictEqual(oauth2client.credentials.access_token, 'abc123'); } describe('OAuth2 client', () => { @@ -198,12 +198,13 @@ describe('OAuth2 client', () => { nock(Utils.baseUrl).get('/drive/v2/files/wat').reply(200); await localDrive.files.get({fileId: 'wat', auth: oauth2client}); - assert.equal(JSON.stringify(oauth2client.credentials), JSON.stringify({ - access_token: 'abc123', - refresh_token: 'abc', - expiry_date: tenMinutesFromNow, - token_type: 'Bearer' - })); + assert.strictEqual( + JSON.stringify(oauth2client.credentials), JSON.stringify({ + access_token: 'abc123', + refresh_token: 'abc', + expiry_date: tenMinutesFromNow, + token_type: 'Bearer' + })); assert.throws(() => { scope.done(); @@ -220,12 +221,13 @@ describe('OAuth2 client', () => { nock(Utils.baseUrl).get('/drive/v2/files/wat').reply(200); await remoteDrive.files.get({fileId: 'wat', auth: oauth2client}); - assert.equal(JSON.stringify(oauth2client.credentials), JSON.stringify({ - access_token: 'abc123', - refresh_token: 'abc', - expiry_date: tenMinutesFromNow, - token_type: 'Bearer' - })); + assert.strictEqual( + JSON.stringify(oauth2client.credentials), JSON.stringify({ + access_token: 'abc123', + refresh_token: 'abc', + expiry_date: tenMinutesFromNow, + token_type: 'Bearer' + })); assert.throws(() => { scope.done(); @@ -257,8 +259,8 @@ describe('OAuth2 client', () => { oauth2client.credentials = {access_token: 'abc', refresh_token: 'abc'}; const res = await oauth2client.revokeCredentials(); scope.done(); - assert.equal(res.data.success, true); - assert.deepEqual(oauth2client.credentials, {}); + assert.strictEqual(res.data.success, true); + assert.deepStrictEqual(oauth2client.credentials, {}); }); it('should clear credentials and return error if no access token to revoke', @@ -269,7 +271,7 @@ describe('OAuth2 client', () => { await assertRejects( oauth2client.revokeCredentials(), /Error: No access token to revoke./); - assert.deepEqual(oauth2client.credentials, {}); + assert.deepStrictEqual(oauth2client.credentials, {}); }); }); diff --git a/test/test.clients.ts b/test/test.clients.ts index dbaf977602b..a7d9761d7a3 100644 --- a/test/test.clients.ts +++ b/test/test.clients.ts @@ -50,40 +50,40 @@ describe('Clients', () => { it('should create request helpers according to resource on discovery API response', () => { let plus = localPlus; - assert.equal(typeof plus.people.get, 'function'); - assert.equal(typeof plus.activities.search, 'function'); - assert.equal(typeof plus.comments.list, 'function'); + assert.strictEqual(typeof plus.people.get, 'function'); + assert.strictEqual(typeof plus.activities.search, 'function'); + assert.strictEqual(typeof plus.comments.list, 'function'); plus = remotePlus; - assert.equal(typeof plus.people.get, 'function'); - assert.equal(typeof plus.activities.search, 'function'); - assert.equal(typeof plus.comments.list, 'function'); + assert.strictEqual(typeof plus.people.get, 'function'); + assert.strictEqual(typeof plus.activities.search, 'function'); + assert.strictEqual(typeof plus.comments.list, 'function'); }); it('should be able to gen top level methods', () => { - assert.equal(typeof localOauth2.tokeninfo, 'function'); - assert.equal(typeof remoteOauth2.tokeninfo, 'function'); + assert.strictEqual(typeof localOauth2.tokeninfo, 'function'); + assert.strictEqual(typeof remoteOauth2.tokeninfo, 'function'); }); it('should be able to gen top level methods and resources', () => { let oauth2 = localOauth2; - assert.equal(typeof oauth2.tokeninfo, 'function'); - assert.equal(typeof oauth2.userinfo, 'object'); + assert.strictEqual(typeof oauth2.tokeninfo, 'function'); + assert.strictEqual(typeof oauth2.userinfo, 'object'); oauth2 = remoteOauth2; - assert.equal(typeof oauth2.tokeninfo, 'function'); - assert.equal(typeof oauth2.userinfo, 'object'); + assert.strictEqual(typeof oauth2.tokeninfo, 'function'); + assert.strictEqual(typeof oauth2.userinfo, 'object'); }); it('should be able to gen nested resources and methods', () => { let oauth2 = localOauth2; - assert.equal(typeof oauth2.userinfo, 'object'); - assert.equal(typeof oauth2.userinfo.v2, 'object'); - assert.equal(typeof oauth2.userinfo.v2.me, 'object'); - assert.equal(typeof oauth2.userinfo.v2.me.get, 'function'); + assert.strictEqual(typeof oauth2.userinfo, 'object'); + assert.strictEqual(typeof oauth2.userinfo.v2, 'object'); + assert.strictEqual(typeof oauth2.userinfo.v2.me, 'object'); + assert.strictEqual(typeof oauth2.userinfo.v2.me.get, 'function'); oauth2 = remoteOauth2; - assert.equal(typeof oauth2.userinfo, 'object'); - assert.equal(typeof oauth2.userinfo.v2, 'object'); - assert.equal(typeof oauth2.userinfo.v2.me, 'object'); - assert.equal(typeof oauth2.userinfo.v2.me.get, 'function'); + assert.strictEqual(typeof oauth2.userinfo, 'object'); + assert.strictEqual(typeof oauth2.userinfo.v2, 'object'); + assert.strictEqual(typeof oauth2.userinfo.v2.me, 'object'); + assert.strictEqual(typeof oauth2.userinfo.v2.me.get, 'function'); }); it('should support default params', async () => { diff --git a/test/test.discover.ts b/test/test.discover.ts index a3dec8b2eb5..d7e5938e5e5 100644 --- a/test/test.discover.ts +++ b/test/test.discover.ts @@ -22,7 +22,7 @@ describe('GoogleApis#discover', () => { it('should get a list of supported apis', () => { const google = new GoogleApis(); const apis = google.getSupportedAPIs(); - assert.equal(Object.keys(apis).length, Object.keys(APIS).length); + assert.strictEqual(Object.keys(apis).length, Object.keys(APIS).length); assert(apis.drive.indexOf('v2') > -1); }); @@ -33,8 +33,8 @@ describe('GoogleApis#discover', () => { const g2 = google as any; const localDrive = google.drive('v2'); - assert.equal(typeof google.drive, 'function'); - assert.equal(typeof localDrive, 'object'); + assert.strictEqual(typeof google.drive, 'function'); + assert.strictEqual(typeof localDrive, 'object'); localApis.splice(localApis.indexOf('index.ts'), 1); localApis.splice(localApis.indexOf('index.d.ts'), 1); @@ -47,7 +47,7 @@ describe('GoogleApis#discover', () => { g2[name] = null; }); - assert.equal(google.drive, null); + assert.strictEqual(google.drive, null); google.discover('https://www.googleapis.com/discovery/v1/apis', (err) => { if (err) { @@ -66,8 +66,8 @@ describe('GoogleApis#discover', () => { }); const remoteDrive = google.drive('v2'); - assert.equal(typeof google.drive, 'function'); - assert.equal(typeof remoteDrive, 'object'); + assert.strictEqual(typeof google.drive, 'function'); + assert.strictEqual(typeof remoteDrive, 'object'); for (const key in localDrive) { if (localDrive.hasOwnProperty(key)) { diff --git a/test/test.drive.v2.ts b/test/test.drive.v2.ts index 4fb73b70d64..bcfdffad3e8 100644 --- a/test/test.drive.v2.ts +++ b/test/test.drive.v2.ts @@ -45,7 +45,7 @@ describe('drive:v2', () => { }); it('should be a function', (done) => { - assert.equal(typeof googleapis.drive, 'function'); + assert.strictEqual(typeof googleapis.drive, 'function'); done(); }); @@ -56,8 +56,8 @@ describe('drive:v2', () => { }); it('should be frozen (immutable)', (done) => { - assert.equal(Object.isFrozen(localDrive), true); - assert.equal(Object.isFrozen(remoteDrive), true); + assert.strictEqual(Object.isFrozen(localDrive), true); + assert.strictEqual(Object.isFrozen(remoteDrive), true); done(); }); @@ -69,8 +69,8 @@ describe('drive:v2', () => { }); it('should be an object', (done) => { - assert.equal(typeof localDrive.files, 'object'); - assert.equal(typeof remoteDrive.files, 'object'); + assert.strictEqual(typeof localDrive.files, 'object'); + assert.strictEqual(typeof remoteDrive.files, 'object'); done(); }); @@ -82,16 +82,16 @@ describe('drive:v2', () => { }); it('should be a function', (done) => { - assert.equal(typeof localDrive.files.insert, 'function'); - assert.equal(typeof remoteDrive.files.insert, 'function'); + assert.strictEqual(typeof localDrive.files.insert, 'function'); + assert.strictEqual(typeof remoteDrive.files.insert, 'function'); done(); }); it('should not return a Request object', (done) => { let req = localDrive.files.insert(Utils.noop); - assert.equal(req, undefined); + assert.strictEqual(req, undefined); req = remoteDrive.files.insert(Utils.noop); - assert.equal(req, undefined); + assert.strictEqual(req, undefined); done(); }); }); @@ -103,15 +103,15 @@ describe('drive:v2', () => { }); it('should be a function', () => { - assert.equal(typeof localDrive.files.get, 'function'); - assert.equal(typeof remoteDrive.files.get, 'function'); + assert.strictEqual(typeof localDrive.files.get, 'function'); + assert.strictEqual(typeof remoteDrive.files.get, 'function'); }); it('should not return a Request object', () => { let req = localDrive.files.get({fileId: '123'}, Utils.noop); - assert.equal(req, undefined); + assert.strictEqual(req, undefined); req = remoteDrive.files.get({fileId: '123'}, Utils.noop); - assert.equal(req, undefined); + assert.strictEqual(req, undefined); }); }); }); @@ -123,8 +123,8 @@ describe('drive:v2', () => { }); it('should be an object', () => { - assert.equal(typeof localDrive._options, 'object'); - assert.equal(typeof remoteDrive._options, 'object'); + assert.strictEqual(typeof localDrive._options, 'object'); + assert.strictEqual(typeof remoteDrive._options, 'object'); }); }); diff --git a/test/test.media.ts b/test/test.media.ts index fe83bab9fb8..93e080294d0 100644 --- a/test/test.media.ts +++ b/test/test.media.ts @@ -30,9 +30,10 @@ async function testMultpart(drive: drive_v2.Drive) { path.join(__dirname, '../../test/fixtures/media-response.txt'), {encoding: 'utf8'}); const res = await drive.files.insert({requestBody, media}); - assert.equal(res.config.method!.toLowerCase(), 'post'); - assert.equal(res.request.path, '/upload/drive/v2/files?uploadType=multipart'); - assert.equal( + assert.strictEqual(res.config.method!.toLowerCase(), 'post'); + assert.strictEqual( + res.request.path, '/upload/drive/v2/files?uploadType=multipart'); + assert.strictEqual( res.request.headers['content-type'].indexOf('multipart/related;'), 0); const boundary = res.request.headers['content-type'].replace(boundaryPrefix, ''); @@ -52,10 +53,11 @@ async function testMediaBody(drive: drive_v2.Drive) { path.join(__dirname, '../../test/fixtures/media-response.txt'), {encoding: 'utf8'}); const res = await drive.files.insert({requestBody, media}); - assert.equal(res.config.method!.toLowerCase(), 'post'); - assert.equal(res.config.maxContentLength, Math.pow(2, 31)); - assert.equal(res.request.path, '/upload/drive/v2/files?uploadType=multipart'); - assert.equal( + assert.strictEqual(res.config.method!.toLowerCase(), 'post'); + assert.strictEqual(res.config.maxContentLength, Math.pow(2, 31)); + assert.strictEqual( + res.request.path, '/upload/drive/v2/files?uploadType=multipart'); + assert.strictEqual( res.request.headers['content-type'].indexOf('multipart/related;'), 0); const boundary = res.request.headers['content-type'].replace(boundaryPrefix, ''); @@ -121,7 +123,7 @@ describe('Media', () => { } }); assert(progressEvents.length > 0); - assert.equal(progressEvents[0], fileSize); + assert.strictEqual(progressEvents[0], fileSize); scope.done(); }); @@ -134,11 +136,11 @@ describe('Media', () => { const res = await localDrive.files.insert( {requestBody: {}, media: {body: 'hello'}}); - assert.equal( + assert.strictEqual( JSON.stringify(res.data), JSON.stringify({fileId: 'abc123'})); const res2 = await remoteDrive.files.insert( {requestBody: {}, media: {body: 'hello'}}); - assert.equal( + assert.strictEqual( JSON.stringify(res2.data), JSON.stringify({fileId: 'abc123'})); }); @@ -149,10 +151,10 @@ describe('Media', () => { .times(2) .reply(200, {fileId: 'abc123'}); const res = await localDrive.files.insert({media: {body: 'hello'}}); - assert.equal( + assert.strictEqual( JSON.stringify(res.data), JSON.stringify({fileId: 'abc123'})); const res2 = await remoteDrive.files.insert({media: {body: 'hello'}}); - assert.equal( + assert.strictEqual( JSON.stringify(res2.data), JSON.stringify({fileId: 'abc123'})); }); @@ -167,13 +169,13 @@ describe('Media', () => { }); const media = {body: 'hey'}; const res = await localDrive.files.insert({media}); - assert.equal(res.config.method!.toLowerCase(), 'post'); - assert.equal( + assert.strictEqual(res.config.method!.toLowerCase(), 'post'); + assert.strictEqual( res.request.path, '/upload/drive/v2/files?uploadType=media'); assert.strictEqual(media.body, res.data); const res2 = await remoteDrive.files.insert({media}); - assert.equal(res.config.method!.toLowerCase(), 'post'); - assert.equal( + assert.strictEqual(res.config.method!.toLowerCase(), 'post'); + assert.strictEqual( res.request.path, '/upload/drive/v2/files?uploadType=media'); assert.strictEqual(media.body, res2.data); }); @@ -198,10 +200,12 @@ describe('Media', () => { .reply(200); const res = await localDrive.files.insert( {visibility: 'someValue', media: {body: 'wat'}}); - assert.equal(Utils.getQs(res), 'visibility=someValue&uploadType=media'); + assert.strictEqual( + Utils.getQs(res), 'visibility=someValue&uploadType=media'); const res2 = await remoteDrive.files.insert( {visibility: 'someValue', media: {body: 'wat'}}); - assert.equal(Utils.getQs(res2), 'visibility=someValue&uploadType=media'); + assert.strictEqual( + Utils.getQs(res2), 'visibility=someValue&uploadType=media'); }); it('should not multipart upload if no media body given', async () => { @@ -210,9 +214,9 @@ describe('Media', () => { .twice() .reply(200); const res = await localDrive.files.insert({visibility: 'someValue'}); - assert.equal(Utils.getQs(res), 'visibility=someValue'); + assert.strictEqual(Utils.getQs(res), 'visibility=someValue'); const res2 = await remoteDrive.files.insert({visibility: 'someValue'}); - assert.equal(Utils.getQs(res2), 'visibility=someValue'); + assert.strictEqual(Utils.getQs(res2), 'visibility=someValue'); }); it('should set text/plain when passed a string as media body', async () => { @@ -237,20 +241,20 @@ describe('Media', () => { // testing purposes }); const requestBody = { - message: {raw: (new Buffer('hello', 'binary')).toString('base64')} + message: {raw: Buffer.from('hello', 'binary').toString('base64')} }; const res = await localGmail.users.drafts.create( {userId: 'me', requestBody, media: {mimeType: 'message/rfc822'}} as gmail_v1.Params$Resource$Users$Drafts$Create); - assert.equal( + assert.strictEqual( res.request.headers['content-type'].indexOf('application/json'), 0); - assert.equal(JSON.stringify(res.data), JSON.stringify(requestBody)); + assert.strictEqual(JSON.stringify(res.data), JSON.stringify(requestBody)); const res2 = await remoteGmail.users.drafts.create( {userId: 'me', requestBody, media: {mimeType: 'message/rfc822'}} as gmail_v1.Params$Resource$Users$Drafts$Create); - assert.equal( + assert.strictEqual( res2.request.headers['content-type'].indexOf('application/json'), 0); - assert.equal(JSON.stringify(res2.data), JSON.stringify(requestBody)); + assert.strictEqual(JSON.stringify(res2.data), JSON.stringify(requestBody)); }); it('should accept readable stream as media body without metadata', @@ -265,19 +269,19 @@ describe('Media', () => { let body = fs.createReadStream( path.join(__dirname, '../../test/fixtures/mediabody.txt')); let expectedBody = fs.readFileSync( - path.join(__dirname, '../../test/fixtures/mediabody.txt')); + path.join(__dirname, '../../test/fixtures/mediabody.txt'), 'utf8'); const res = await localGmail.users.drafts.create( {userId: 'me', media: {mimeType: 'message/rfc822', body}} as gmail_v1.Params$Resource$Users$Drafts$Create); - assert.equal(res.data, expectedBody); + assert.strictEqual(res.data, expectedBody); body = fs.createReadStream( path.join(__dirname, '../../test/fixtures/mediabody.txt')); expectedBody = fs.readFileSync( - path.join(__dirname, '../../test/fixtures/mediabody.txt')); + path.join(__dirname, '../../test/fixtures/mediabody.txt'), 'utf8'); const res2 = await remoteGmail.users.drafts.create( {userId: 'me', media: {mimeType: 'message/rfc822', body}} as gmail_v1.Params$Resource$Users$Drafts$Create); - assert.equal(res2.data, expectedBody); + assert.strictEqual(res2.data, expectedBody); }); it('should accept readable stream as media body with metadata', async () => { @@ -290,7 +294,7 @@ describe('Media', () => { }); let requestBody = { - message: {raw: (new Buffer('hello', 'binary')).toString('base64')} + message: {raw: Buffer.from('hello', 'binary').toString('base64')} }; let body = fs.createReadStream( path.join(__dirname, '../../test/fixtures/mediabody.txt')); @@ -313,7 +317,7 @@ describe('Media', () => { .trim(); assert.strictEqual(expectedBody, res.data); requestBody = { - message: {raw: (new Buffer('hello', 'binary')).toString('base64')} + message: {raw: Buffer.from('hello', 'binary').toString('base64')} }; body = fs.createReadStream( path.join(__dirname, '../../test/fixtures/mediabody.txt')); @@ -347,29 +351,29 @@ describe('Media', () => { }); let requestBody = { - message: {raw: (new Buffer('hello', 'binary')).toString('base64')} + message: {raw: Buffer.from('hello', 'binary').toString('base64')} }; const body = fs.createReadStream( path.join(__dirname, '../../test/fixtures/mediabody.txt')); let media = {mimeType: 'message/rfc822', body}; const res = await localGmail.users.drafts.create( {userId: 'me', requestBody, media}); - assert.equal(typeof res.data, 'object'); + assert.strictEqual(typeof res.data, 'object'); // tslint:disable-next-line no-any - assert.equal((res.data as any).hello, 'world'); - assert.equal(typeof res, 'object'); + assert.strictEqual((res.data as any).hello, 'world'); + assert.strictEqual(typeof res, 'object'); requestBody = { - message: {raw: (new Buffer('hello', 'binary')).toString('base64')} + message: {raw: Buffer.from('hello', 'binary').toString('base64')} }; const body2 = fs.createReadStream( path.join(__dirname, '../../test/fixtures/mediabody.txt')); media = {mimeType: 'message/rfc822', body: body2}; const res2 = await remoteGmail.users.drafts.create( {userId: 'me', requestBody, media}); - assert.equal(typeof res2.data, 'object'); + assert.strictEqual(typeof res2.data, 'object'); // tslint:disable-next-line no-any - assert.equal((res2.data as any).hello, 'world'); - assert.equal(typeof res2, 'object'); + assert.strictEqual((res2.data as any).hello, 'world'); + assert.strictEqual(typeof res2, 'object'); }); after(() => { diff --git a/test/test.options.ts b/test/test.options.ts index 795caccbd19..e6055d50193 100644 --- a/test/test.options.ts +++ b/test/test.options.ts @@ -32,19 +32,19 @@ describe('Options', () => { it('should be a function', () => { const google = new GoogleApis(); - assert.equal(typeof google.options, 'function'); + assert.strictEqual(typeof google.options, 'function'); }); it('should expose _options', () => { const google = new GoogleApis(); google.options({params: {hello: 'world'}}); - assert.deepEqual(google._options, {params: {hello: 'world'}}); + assert.deepStrictEqual(google._options, {params: {hello: 'world'}}); }); it('should expose _options values', () => { const google = new GoogleApis(); google.options({params: {hello: 'world'}}); - assert.deepEqual(google._options.params.hello, 'world'); + assert.deepStrictEqual(google._options.params.hello, 'world'); }); it('should promote endpoint options over global options', async () => { @@ -53,7 +53,7 @@ describe('Options', () => { const drive = google.drive({version: 'v2', params: {hello: 'changed'}}); createNock('/drive/v2/files/123?hello=changed'); const res = await drive.files.get({fileId: '123'}); - assert.equal(res.config.params.hello, 'changed'); + assert.strictEqual(res.config.params.hello, 'changed'); }); it('should support global request params', async () => { @@ -91,7 +91,7 @@ describe('Options', () => { const drive = google.drive({version: 'v2', auth: 'apikey2'}); createNock('/drive/v2/files/woot?key=apikey3'); const res = await drive.files.get({auth: 'apikey3', fileId: 'woot'}); - assert.equal(Utils.getQs(res), 'key=apikey3'); + assert.strictEqual(Utils.getQs(res), 'key=apikey3'); }); it('should apply google options to request object like timeout', async () => { @@ -100,7 +100,7 @@ describe('Options', () => { const drive = google.drive({version: 'v2', auth: 'apikey2'}); createNock('/drive/v2/files/woot?key=apikey3'); const res = await drive.files.get({auth: 'apikey3', fileId: 'woot'}); - assert.equal(res.config.timeout, '12345'); + assert.strictEqual(res.config.timeout, 12345); }); it('should apply endpoint options to request object like timeout', @@ -110,8 +110,8 @@ describe('Options', () => { google.drive({version: 'v2', auth: 'apikey2', timeout: 23456}); createNock('/drive/v2/files/woot?key=apikey3'); const res = await drive.files.get({auth: 'apikey3', fileId: 'woot'}); - assert.equal(res.config.timeout, 23456); - assert.equal(Utils.getQs(res), 'key=apikey3'); + assert.strictEqual(res.config.timeout, 23456); + assert.strictEqual(Utils.getQs(res), 'key=apikey3'); }); it('should allow overriding endpoint options', async () => { @@ -123,11 +123,12 @@ describe('Options', () => { {fileId: 'woot'}, {url: 'https://myproxy.com/drive/v3/files/{fileId}', timeout: 12345}); - assert.equal( + assert.strictEqual( res.request.path, '/drive/v3/files/woot', 'Request used overridden url.'); - assert.equal(res.request.headers.host, 'myproxy.com'); - assert.equal(res.config.timeout, 12345, 'Axios used overridden timeout.'); + assert.strictEqual(res.request.headers.host, 'myproxy.com'); + assert.strictEqual( + res.config.timeout, 12345, 'Axios used overridden timeout.'); }); it('should apply endpoint options like timeout to oauth transporter', @@ -140,8 +141,8 @@ describe('Options', () => { google.drive({version: 'v2', auth: 'apikey2', timeout: 12345}); createNock('/drive/v2/files/woot'); const res = await drive.files.get({auth: authClient, fileId: 'woot'}); - assert.equal(res.config.timeout, 12345); - assert.equal(res.config.headers.Authorization, 'Bearer abc'); + assert.strictEqual(res.config.timeout, 12345); + assert.strictEqual(res.config.headers.Authorization, 'Bearer abc'); }); it('should allow overriding rootUrl via options', async () => { @@ -151,13 +152,13 @@ describe('Options', () => { const rootUrl = 'https://myrooturl.com'; nock(rootUrl).get('/drive/v3/files/woot').reply(200); const res = await drive.files.get({fileId}, {rootUrl}); - assert.equal( + assert.strictEqual( res.config.url, 'https://myrooturl.com/drive/v3/files/woot', 'Request used overridden rootUrl with trailing slash.'); nock(rootUrl).get('/drive/v3/files/woot').reply(200); const res2 = await drive.files.get({fileId}, {rootUrl}); - assert.equal( + assert.strictEqual( res.config.url, 'https://myrooturl.com/drive/v3/files/woot', 'Request used overridden rootUrl.'); }); @@ -171,7 +172,7 @@ describe('Options', () => { return true; } }); - assert.equal(res.status, 500); + assert.strictEqual(res.status, 500); }); after(() => { diff --git a/test/test.path.ts b/test/test.path.ts index 02c50b4be33..3d1dcbdae95 100644 --- a/test/test.path.ts +++ b/test/test.path.ts @@ -75,10 +75,10 @@ describe('Path params', () => { (done) => { localDrive.files.get({}, (err: Error, resp: {}) => { assert(err); - assert.equal(resp, null); + assert.strictEqual(resp, undefined); remoteDrive.files.get({}, (e: Error, resp2: {}) => { assert(e); - assert.equal(resp2, null); + assert.strictEqual(resp2, undefined); done(); }); }); @@ -86,17 +86,17 @@ describe('Path params', () => { it('should return null request object if not included and required', () => { let req = localDrive.files.get({}, Utils.noop); - assert.equal(req, null); + assert.strictEqual(req, undefined); req = remoteDrive.files.get({}, Utils.noop); - assert.equal(req, null); + assert.strictEqual(req, undefined); }); it('should return null request object if not included and required and no callback', () => { let req = localDrive.files.get({}, Utils.noop); - assert.equal(req, null); + assert.strictEqual(req, undefined); req = remoteDrive.files.get({}, Utils.noop); - assert.equal(req, null); + assert.strictEqual(req, undefined); }); it('should not be modifiable directly', () => { @@ -118,14 +118,14 @@ describe('Path params', () => { if (err) { return done(err); } - assert.equal(res.config.url, Utils.baseUrl + p); + assert.strictEqual(res.config.url, Utils.baseUrl + p); nock(Utils.baseUrl).get(p).reply(200); remoteDrive.files.get( {fileId: 'abc123'}, (err2: Error, res2: AxiosResponse) => { if (err2) { return done(err2); } - assert.equal(res2.config.url, Utils.baseUrl + p); + assert.strictEqual(res2.config.url, Utils.baseUrl + p); done(); }); }); @@ -139,14 +139,14 @@ describe('Path params', () => { if (err) { return done(err); } - assert.equal(Utils.getPath(res), p); + assert.strictEqual(Utils.getPath(res), p); nock(Utils.baseUrl).get(p).reply(200); remoteDrive.files.get( {fileId: '123abc'}, (err2: Error, res2: AxiosResponse) => { if (err2) { return done(err2); } - assert.equal(Utils.getPath(res), p); + assert.strictEqual(Utils.getPath(res), p); done(); }); }); @@ -161,7 +161,7 @@ describe('Path params', () => { return done(err); } const parm = Utils.getPath(res).split('/').pop(); - assert.equal(decodeURIComponent(parm!), 'p@ram'); + assert.strictEqual(decodeURIComponent(parm!), 'p@ram'); nock(Utils.baseUrl).get(p).reply(200); remoteDrive.files.get( {fileId: 'p@ram'}, (err2: Error, res2: AxiosResponse) => { @@ -169,7 +169,7 @@ describe('Path params', () => { return done(err2); } const parm = Utils.getPath(res).split('/').pop(); - assert.equal(decodeURIComponent(parm!), 'p@ram'); + assert.strictEqual(decodeURIComponent(parm!), 'p@ram'); done(); }); }); @@ -183,14 +183,14 @@ describe('Path params', () => { if (err) { return done(err); } - assert.equal(Utils.getQs(res), null); + assert.strictEqual(Utils.getQs(res), null); nock(Utils.baseUrl).get(p).reply(200); remoteDrive.files.get( {fileId: '123abc'}, (err2: Error, res2: AxiosResponse) => { if (err2) { return done(err2); } - assert.equal(Utils.getQs(res2), null); + assert.strictEqual(Utils.getQs(res2), null); done(); }); }); @@ -205,7 +205,7 @@ describe('Path params', () => { if (err) { return done(err); } - assert.equal(Utils.getQs(res), 'hello=world'); + assert.strictEqual(Utils.getQs(res), 'hello=world'); nock(Utils.baseUrl).get(p).reply(200); remoteDrive.files.get( {fileId: '123abc', hello: 'world'}, @@ -213,7 +213,7 @@ describe('Path params', () => { if (err2) { return done(err2); } - assert.equal(Utils.getQs(res), 'hello=world'); + assert.strictEqual(Utils.getQs(res), 'hello=world'); done(); }); }); diff --git a/test/test.query.ts b/test/test.query.ts index ba3deaedaac..edd6a889fef 100644 --- a/test/test.query.ts +++ b/test/test.query.ts @@ -49,28 +49,28 @@ describe('Query params', () => { it('should not append ? with no query parameters', async () => { nock(Utils.baseUrl).get('/drive/v2/files/ID').reply(200); const res = await localDrive.files.get({fileId: 'ID'}); - assert.equal(-1, res.config.url.indexOf('?')); + assert.strictEqual(-1, res.config.url.indexOf('?')); nock(Utils.baseUrl).get('/drive/v2/files/ID').reply(200); const res2 = await remoteDrive.files.get({fileId: 'ID'}); - assert.equal(-1, res2.config.url.indexOf('?')); + assert.strictEqual(-1, res2.config.url.indexOf('?')); }); it('should be null if no object passed', async () => { nock(Utils.baseUrl).get('/drive/v2/files').reply(200); const res = await localDrive.files.list(); - assert.equal(Utils.getQs(res), null); + assert.strictEqual(Utils.getQs(res), null); nock(Utils.baseUrl).get('/drive/v2/files').reply(200); const res2 = await remoteDrive.files.list(); - assert.equal(Utils.getQs(res2), null); + assert.strictEqual(Utils.getQs(res2), null); }); it('should be null if params passed are in path', async () => { nock(Utils.baseUrl).get('/drive/v2/files/123').reply(200); const res = await localDrive.files.get({fileId: '123'}); - assert.equal(Utils.getQs(res), null); + assert.strictEqual(Utils.getQs(res), null); nock(Utils.baseUrl).get('/drive/v2/files/123').reply(200); const res2 = await remoteDrive.files.get({fileId: '123'}); - assert.equal(Utils.getQs(res), null); + assert.strictEqual(Utils.getQs(res), null); }); it('should be set if params passed are optional query params', async () => { @@ -79,34 +79,34 @@ describe('Query params', () => { .reply(200); const res = await localDrive.files.get({fileId: '123', updateViewedDate: true}); - assert.equal(Utils.getQs(res), 'updateViewedDate=true'); + assert.strictEqual(Utils.getQs(res), 'updateViewedDate=true'); nock(Utils.baseUrl) .get('/drive/v2/files/123?updateViewedDate=true') .reply(200); const res2 = await remoteDrive.files.get({fileId: '123', updateViewedDate: true}); - assert.equal(Utils.getQs(res2), 'updateViewedDate=true'); + assert.strictEqual(Utils.getQs(res2), 'updateViewedDate=true'); }); it('should be set if params passed are unknown params', async () => { nock(Utils.baseUrl).get('/drive/v2/files/123?madeThisUp=hello').reply(200); const res = await localDrive.files.get({fileId: '123', madeThisUp: 'hello'}); - assert.equal(Utils.getQs(res), 'madeThisUp=hello'); + assert.strictEqual(Utils.getQs(res), 'madeThisUp=hello'); nock(Utils.baseUrl).get('/drive/v2/files/123?madeThisUp=hello').reply(200); const res2 = await remoteDrive.files.get({fileId: '123', madeThisUp: 'hello'}); - assert.equal(Utils.getQs(res2), 'madeThisUp=hello'); + assert.strictEqual(Utils.getQs(res2), 'madeThisUp=hello'); }); it('should be set if params passed are aliased names', async () => { nock(Utils.baseUrl).get('/drive/v2/files/123?resource=hello').reply(200); const res = await localDrive.files.get({fileId: '123', resource_: 'hello'}); - assert.equal(Utils.getQs(res), 'resource=hello'); + assert.strictEqual(Utils.getQs(res), 'resource=hello'); nock(Utils.baseUrl).get('/drive/v2/files/123?resource=hello').reply(200); const res2 = await remoteDrive.files.get({fileId: '123', resource_: 'hello'}); - assert.equal(Utils.getQs(res2), 'resource=hello'); + assert.strictEqual(Utils.getQs(res2), 'resource=hello'); }); it('should be set if params passed are falsy', async () => { @@ -121,7 +121,7 @@ describe('Query params', () => { autoDelete: false, deviceName: '' }); - assert.equal(Utils.getQs(res), 'autoDelete=false&deviceName='); + assert.strictEqual(Utils.getQs(res), 'autoDelete=false&deviceName='); nock(Utils.baseUrl) .post( '/compute/v1/projects//zones//instances//setDiskAutoDelete?autoDelete=false&deviceName=') @@ -133,7 +133,7 @@ describe('Query params', () => { autoDelete: false, deviceName: '' }); - assert.equal(Utils.getQs(res2), 'autoDelete=false&deviceName='); + assert.strictEqual(Utils.getQs(res2), 'autoDelete=false&deviceName='); nock(Utils.baseUrl) .post( @@ -141,7 +141,7 @@ describe('Query params', () => { .reply(200); const res3 = await localCompute.instanceGroupManagers.resize( {project: '', zone: '', instanceGroupManager: '', size: 0}); - assert.equal(Utils.getQs(res3), 'size=0'); + assert.strictEqual(Utils.getQs(res3), 'size=0'); nock(Utils.baseUrl) .post( @@ -149,7 +149,7 @@ describe('Query params', () => { .reply(200); const res4 = await remoteCompute.instanceGroupManagers.resize( {project: '', zone: '', instanceGroupManager: '', size: 0}); - assert.equal(Utils.getQs(res4), 'size=0'); + assert.strictEqual(Utils.getQs(res4), 'size=0'); }); it('should chain together with & in order', async () => { @@ -158,14 +158,14 @@ describe('Query params', () => { .reply(200); const res = await localDrive.files.get( {fileId: '123', madeThisUp: 'hello', thisToo: 'world'}); - assert.equal(Utils.getQs(res), 'madeThisUp=hello&thisToo=world'); + assert.strictEqual(Utils.getQs(res), 'madeThisUp=hello&thisToo=world'); nock(Utils.baseUrl) .get('/drive/v2/files/123?madeThisUp=hello&thisToo=world') .reply(200); const res2 = await remoteDrive.files.get( {fileId: '123', madeThisUp: 'hello', thisToo: 'world'}); - assert.equal(Utils.getQs(res2), 'madeThisUp=hello&thisToo=world'); + assert.strictEqual(Utils.getQs(res2), 'madeThisUp=hello&thisToo=world'); }); it('should not include auth if auth is an OAuth2Client object', async () => { @@ -175,12 +175,12 @@ describe('Query params', () => { nock(Utils.baseUrl).get('/drive/v2/files/123').reply(200); const res = await localDrive.files.get({fileId: '123', auth: oauth2client}); - assert.equal(Utils.getQs(res), null); + assert.strictEqual(Utils.getQs(res), null); nock(Utils.baseUrl).get('/drive/v2/files/123').reply(200); const res2 = await remoteDrive.files.get({fileId: '123', auth: oauth2client}); - assert.equal(Utils.getQs(res2), null); + assert.strictEqual(Utils.getQs(res2), null); }); it('should handle multi-value query params properly', async () => { @@ -190,7 +190,8 @@ describe('Query params', () => { .reply(200); const res = await localGmail.users.messages.get( {userId: 'me', id: 'abc123', metadataHeaders: ['To', 'Date']}); - assert.equal(Utils.getQs(res), 'metadataHeaders=To&metadataHeaders=Date'); + assert.strictEqual( + Utils.getQs(res), 'metadataHeaders=To&metadataHeaders=Date'); nock(Utils.baseUrl) .get( @@ -198,7 +199,8 @@ describe('Query params', () => { .reply(200); const res2 = await remoteGmail.users.messages.get( {userId: 'me', id: 'abc123', metadataHeaders: ['To', 'Date']}); - assert.equal(Utils.getQs(res2), 'metadataHeaders=To&metadataHeaders=Date'); + assert.strictEqual( + Utils.getQs(res2), 'metadataHeaders=To&metadataHeaders=Date'); }); after(() => { diff --git a/test/test.transporters.ts b/test/test.transporters.ts index 8be27188d56..a42bcec6f1a 100644 --- a/test/test.transporters.ts +++ b/test/test.transporters.ts @@ -22,7 +22,7 @@ async function testHeaders(drive: APIEndpoint) { nock(Utils.baseUrl).post('/drive/v2/files/a/comments').reply(200); const res = await drive.comments.insert( {fileId: 'a', headers: {'If-None-Match': '12345'}}); - assert.equal(res.config.headers['If-None-Match'], '12345'); + assert.strictEqual(res.config.headers['If-None-Match'], '12345'); } async function testContentType(drive: APIEndpoint) { @@ -39,30 +39,32 @@ async function testGzip(drive: APIEndpoint) { {reqheaders: {'Accept-Encoding': 'gzip'}}) .reply(200, {}); const res = await drive.files.list(); - assert.deepEqual(res.data, {}); + assert.deepStrictEqual(res.data, {}); // note: axios strips the `content-encoding` header from the response, // so that cannot be checked here. } async function testBody(drive: APIEndpoint) { - nock(Utils.baseUrl).get('/drive/v2/files').reply(200); + const scope = nock(Utils.baseUrl).get('/drive/v2/files').reply(200); const res = await drive.files.list(); - assert.equal(res.config.headers['content-type'], null); - assert.equal(res.request.body, null); + scope.done(); + assert.strictEqual(res.config.headers['content-type'], undefined); + assert.strictEqual(res.request.body, undefined); } async function testBodyDelete(drive: APIEndpoint) { - nock(Utils.baseUrl).delete('/drive/v2/files/test').reply(200); + const scope = nock(Utils.baseUrl).delete('/drive/v2/files/test').reply(200); const res = await drive.files.delete({fileId: 'test'}); - assert.equal(res.config.headers['content-type'], null); - assert.equal(res.request.body, null); + scope.done(); + assert.strictEqual(res.config.headers['content-type'], undefined); + assert.strictEqual(res.request.body, undefined); } function testResponseError(drive: APIEndpoint, cb: (err?: Error) => void) { drive.files.list({q: 'hello'}, (err: NodeJS.ErrnoException) => { assert(err instanceof Error); - assert.equal(err.message, 'Error!'); - assert.equal(err.code, 400); + assert.strictEqual(err.message, 'Error!'); + assert.strictEqual(err.code, 400); cb(); }); } @@ -70,8 +72,8 @@ function testResponseError(drive: APIEndpoint, cb: (err?: Error) => void) { function testNotObjectError(oauth2: APIEndpoint, cb: (err?: Error) => void) { oauth2.tokeninfo({access_token: 'hello'}, (err: NodeJS.ErrnoException) => { assert(err instanceof Error); - assert.equal(err.message, 'invalid_grant'); - assert.equal(err.code, 400); + assert.strictEqual(err.message, 'invalid_grant'); + assert.strictEqual(err.code, '400'); cb(); }); } @@ -82,9 +84,9 @@ function testBackendError( urlshortener.url.insert( {resource: obj}, (err: NodeJS.ErrnoException, result: {}) => { assert(err instanceof Error); - assert.equal(err.code, 500); - assert.equal(err.message, 'There was an error!'); - assert.equal(result, null); + assert.strictEqual(Number(err.code), 500); + assert.strictEqual(err.message, 'There was an error!'); + assert.strictEqual(result, undefined); cb(); }); } @@ -196,7 +198,7 @@ describe('Transporters', () => { it('should return 304 responses as success', async () => { const scope = nock(Utils.baseUrl).get('/drive/v2/files').reply(304); const res = await localDrive.files.list(); - assert.equal(res.status, 304); + assert.strictEqual(res.status, 304); }); it('should handle 5xx responses that include errors', (done) => { diff --git a/test/test.urlshortener.v1.ts b/test/test.urlshortener.v1.ts index b2b4c0eda06..2c69469fbf1 100644 --- a/test/test.urlshortener.v1.ts +++ b/test/test.urlshortener.v1.ts @@ -24,15 +24,15 @@ async function testSingleRequest(urlshortener: urlshortener_v1.Urlshortener) { const reqPath = '/urlshortener/v1/url'; nock(Utils.baseUrl).post(reqPath, requestBody).reply(200); const res = await urlshortener.url.insert({requestBody}); - assert.equal(res.config.method!.toLowerCase(), 'post'); + assert.strictEqual(res.config.method!.toLowerCase(), 'post'); } async function testParams(urlshortener: urlshortener_v1.Urlshortener) { const params = {shortUrl: 'a'}; nock(Utils.baseUrl).get('/urlshortener/v1/url?shortUrl=a').reply(200); const res = await urlshortener.url.get(params); - assert.equal(Utils.getQs(res), 'shortUrl=a'); - assert.equal(res.config.method!.toLowerCase(), 'get'); + assert.strictEqual(Utils.getQs(res), 'shortUrl=a'); + assert.strictEqual(res.config.method!.toLowerCase(), 'get'); } async function testInsert(urlshortener: urlshortener_v1.Urlshortener) { @@ -42,7 +42,7 @@ async function testInsert(urlshortener: urlshortener_v1.Urlshortener) { assert.notEqual(res.data, null); assert.notEqual(res.data.kind, null); assert.notEqual(res.data.id, null); - assert.equal(res.data.longUrl, 'http://google.com/'); + assert.strictEqual(res.data.longUrl, 'http://google.com/'); return res; }