From 1f928fea9c94addc4174ced90c356bc7eb7a2098 Mon Sep 17 00:00:00 2001 From: Peter Hancock Date: Tue, 22 Sep 2020 14:52:00 +1000 Subject: [PATCH 1/6] skip brittle integration tests --- test/stream.test.js | 3 +-- test/twitter.test.js | 12 ++++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/test/stream.test.js b/test/stream.test.js index 3ba4f0f..1be06d8 100644 --- a/test/stream.test.js +++ b/test/stream.test.js @@ -92,8 +92,7 @@ function switchStream({ count, waitBetweenStreams, done, errorHandler }) { it('should default export to be a function', () => { expect(new Stream()).toBeInstanceOf(Stream); }); - -describe('streams', () => { +describe.skip('streams', () => { beforeEach(() => { console.log(new Date().toISOString(), 'Waiting 60s...'); return sleep(60 * 1000); diff --git a/test/twitter.test.js b/test/twitter.test.js index 0a6a40b..0fbf0a6 100644 --- a/test/twitter.test.js +++ b/test/twitter.test.js @@ -51,7 +51,7 @@ describe('core', () => { }); }); -describe('auth', () => { +describe.skip('auth', () => { it('should fail on invalid access_token_secret', async () => { const client = new Twitter({ subdomain: 'api', @@ -120,7 +120,7 @@ describe('auth', () => { }); }); -describe('rate limits', () => { +describe.skip('rate limits', () => { let client; beforeAll(() => (client = newClient())); @@ -148,7 +148,7 @@ describe('rate limits', () => { ); }); -describe('posting', () => { +describe.skip('posting', () => { let client; beforeAll(() => (client = newClient())); @@ -216,7 +216,7 @@ describe('posting', () => { }); }); -describe('uploading', () => { +describe.skip('uploading', () => { let uploadClient; beforeAll(() => (uploadClient = newClient('upload'))); @@ -239,7 +239,7 @@ describe('uploading', () => { }); }); -describe('putting', () => { +describe.skip('putting', () => { let client; beforeAll(() => (client = newClient())); /** @@ -277,7 +277,7 @@ describe('putting', () => { }); }); -describe('misc', () => { +describe.skip('misc', () => { let client; beforeAll(() => (client = newClient())); From 28a2485b5272de37959ad8a5553f6f9a34ebe0ba Mon Sep 17 00:00:00 2001 From: Peter Hancock Date: Wed, 23 Sep 2020 16:49:29 +1000 Subject: [PATCH 2/6] Update this.url via setApi(version) and add test --- test/twitter.test.js | 18 ++++++++++++------ twitter.js | 13 +++++++++++-- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/test/twitter.test.js b/test/twitter.test.js index 0fbf0a6..91d5f4d 100644 --- a/test/twitter.test.js +++ b/test/twitter.test.js @@ -45,13 +45,19 @@ describe('core', () => { expect(new Twitter().url).toEqual('https://api.twitter.com/1.1'); }); + it('should change the url on API change', () => { + const twitter = new Twitter(); + twitter.setApi(2); + expect(twitter.url).toEqual('https://api.twitter.com/2'); + }); + it('should return a stream API URL', () => { const options = { subdomain: 'stream' }; expect(new Twitter(options).url).toEqual('https://stream.twitter.com/1.1'); }); }); -describe.skip('auth', () => { +describe('auth', () => { it('should fail on invalid access_token_secret', async () => { const client = new Twitter({ subdomain: 'api', @@ -120,7 +126,7 @@ describe.skip('auth', () => { }); }); -describe.skip('rate limits', () => { +describe('rate limits', () => { let client; beforeAll(() => (client = newClient())); @@ -148,7 +154,7 @@ describe.skip('rate limits', () => { ); }); -describe.skip('posting', () => { +describe('posting', () => { let client; beforeAll(() => (client = newClient())); @@ -216,7 +222,7 @@ describe.skip('posting', () => { }); }); -describe.skip('uploading', () => { +describe('uploading', () => { let uploadClient; beforeAll(() => (uploadClient = newClient('upload'))); @@ -239,7 +245,7 @@ describe.skip('uploading', () => { }); }); -describe.skip('putting', () => { +describe('putting', () => { let client; beforeAll(() => (client = newClient())); /** @@ -277,7 +283,7 @@ describe.skip('putting', () => { }); }); -describe.skip('misc', () => { +describe('misc', () => { let client; beforeAll(() => (client = newClient())); diff --git a/twitter.js b/twitter.js index 273a647..dab9394 100644 --- a/twitter.js +++ b/twitter.js @@ -77,8 +77,8 @@ class Twitter { this.oauth = getUrl(config.subdomain, 'oauth'); this.config = config; } - - /** + + /** * Parse the JSON from a Response object and add the Headers under `_headers` * @param {Response} response - the Response object returned by Fetch * @return {Promise} @@ -129,6 +129,15 @@ class Twitter { } } + /** + * Change the version of the Twitter API. This is sticky and will remain at the new version until the next change + * @param {version} version - the Twitter API version, either 1.1 or 2 + */ + setApi(version) { + this.config.version = version; + this.url = getUrl(this.config.subdomain, this.config.version); + } + async getBearerToken() { const headers = { Authorization: From 6883caf0a094930af08e72911176e97b6414b9ec Mon Sep 17 00:00:00 2001 From: Peter Hancock Date: Wed, 23 Sep 2020 17:30:24 +1000 Subject: [PATCH 3/6] Remove skip on test --- test/stream.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/stream.test.js b/test/stream.test.js index 1be06d8..bb69a55 100644 --- a/test/stream.test.js +++ b/test/stream.test.js @@ -92,7 +92,7 @@ function switchStream({ count, waitBetweenStreams, done, errorHandler }) { it('should default export to be a function', () => { expect(new Stream()).toBeInstanceOf(Stream); }); -describe.skip('streams', () => { +describe('streams', () => { beforeEach(() => { console.log(new Date().toISOString(), 'Waiting 60s...'); return sleep(60 * 1000); From eb342e851428f62257a4ed61a66041dcfa87babf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Dec 2020 08:12:10 +0000 Subject: [PATCH 4/6] Bump ini from 1.3.5 to 1.3.8 Bumps [ini](https://github.com/isaacs/ini) from 1.3.5 to 1.3.8. - [Release notes](https://github.com/isaacs/ini/releases) - [Commits](https://github.com/isaacs/ini/compare/v1.3.5...v1.3.8) Signed-off-by: dependabot[bot] --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 591b456..fe8cd38 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3070,9 +3070,9 @@ inherits@2, inherits@^2.0.3, inherits@^2.0.4, inherits@~2.0.3: integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== ini@~1.3.0: - version "1.3.5" - resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.5.tgz#eee25f56db1c9ec6085e0c22778083f596abf927" - integrity sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw== + version "1.3.8" + resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.8.tgz#a29da425b48806f34767a4efce397269af28432c" + integrity sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew== inquirer@^7.0.0: version "7.1.0" From 0fe335328d3ee1130e1556f66f2dacdebd97f05d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Dec 2020 08:14:19 +0000 Subject: [PATCH 5/6] Bump bl from 4.0.2 to 4.0.3 Bumps [bl](https://github.com/rvagg/bl) from 4.0.2 to 4.0.3. - [Release notes](https://github.com/rvagg/bl/releases) - [Commits](https://github.com/rvagg/bl/compare/v4.0.2...v4.0.3) Signed-off-by: dependabot[bot] --- yarn.lock | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/yarn.lock b/yarn.lock index 591b456..1d05a5b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1014,10 +1014,10 @@ balanced-match@^1.0.0: resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" integrity sha1-ibTRmasr7kneFk6gK4nORi1xt2c= -base64-js@^1.0.2: - version "1.3.1" - resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.3.1.tgz#58ece8cb75dd07e71ed08c736abc5fac4dbf8df1" - integrity sha512-mLQ4i2QO1ytvGWFWmcngKO//JXAQueZvwEKtjgQFM4jIK0kU+ytMfplL8j+n5mspOfjHwoAg+9yhb7BwAHm36g== +base64-js@^1.3.1: + version "1.5.1" + resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" + integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA== base@^0.11.1: version "0.11.2" @@ -1045,9 +1045,9 @@ big.js@^5.2.2: integrity sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ== bl@^4.0.1: - version "4.0.2" - resolved "https://registry.yarnpkg.com/bl/-/bl-4.0.2.tgz#52b71e9088515d0606d9dd9cc7aa48dc1f98e73a" - integrity sha512-j4OH8f6Qg2bGuWfRiltT2HYGx0e1QcBTrK9KAHNMwMZdQnDZFk0ZSYIpADjYCB3U12nicC5tVJwSIhwOWjb4RQ== + version "4.0.3" + resolved "https://registry.yarnpkg.com/bl/-/bl-4.0.3.tgz#12d6287adc29080e22a705e5764b2a9522cdc489" + integrity sha512-fs4G6/Hu4/EE+F75J8DuN/0IpQqNjAdC7aEQv7Qt8MHGUH7Ckv2MwTEEeN9QehD0pfIDkMI1bkHYkKy7xHyKIg== dependencies: buffer "^5.5.0" inherits "^2.0.4" @@ -1171,12 +1171,12 @@ buffer-from@^1.0.0: integrity sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A== buffer@^5.5.0: - version "5.6.0" - resolved "https://registry.yarnpkg.com/buffer/-/buffer-5.6.0.tgz#a31749dc7d81d84db08abf937b6b8c4033f62786" - integrity sha512-/gDYp/UtU0eA1ys8bOs9J6a+E/KWIY+DZ+Q2WESNUA0jFRsJOc0SNUO6xJ5SGA1xueg3NL65W6s+NY5l9cunuw== + version "5.7.1" + resolved "https://registry.yarnpkg.com/buffer/-/buffer-5.7.1.tgz#ba62e7c13133053582197160851a8f648e99eed0" + integrity sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ== dependencies: - base64-js "^1.0.2" - ieee754 "^1.1.4" + base64-js "^1.3.1" + ieee754 "^1.1.13" builtin-modules@^3.1.0: version "3.1.0" @@ -2987,10 +2987,10 @@ icss-replace-symbols@1.1.0, icss-replace-symbols@^1.1.0: resolved "https://registry.yarnpkg.com/icss-replace-symbols/-/icss-replace-symbols-1.1.0.tgz#06ea6f83679a7749e386cfe1fe812ae5db223ded" integrity sha1-Bupvg2ead0njhs/h/oEq5dsiPe0= -ieee754@^1.1.4: - version "1.1.13" - resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.1.13.tgz#ec168558e95aa181fd87d37f55c32bbcb6708b84" - integrity sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg== +ieee754@^1.1.13: + version "1.2.1" + resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352" + integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA== ignore@^4.0.6: version "4.0.6" @@ -6085,7 +6085,7 @@ sade@^1.4.0: dependencies: mri "^1.1.0" -safe-buffer@^5.0.1, safe-buffer@^5.1.2, safe-buffer@~5.2.0: +safe-buffer@^5.0.1, safe-buffer@^5.1.2: version "5.2.0" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.0.tgz#b74daec49b1148f88c64b68d49b1e815c1f2f519" integrity sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg== @@ -6095,6 +6095,11 @@ safe-buffer@~5.1.0, safe-buffer@~5.1.1: resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== +safe-buffer@~5.2.0: + version "5.2.1" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" + integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== + safe-regex@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/safe-regex/-/safe-regex-1.1.0.tgz#40a3669f3b077d1e943d44629e157dd48023bf2e" From faf7be827d736913842f7c7cec02fcc599cca2db Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Dec 2020 08:14:35 +0000 Subject: [PATCH 6/6] Bump lodash from 4.17.15 to 4.17.20 Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.20. - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](https://github.com/lodash/lodash/compare/4.17.15...4.17.20) Signed-off-by: dependabot[bot] --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 591b456..8303577 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4059,9 +4059,9 @@ lodash.uniq@^4.5.0: integrity sha1-0CJTc662Uq3BvILklFM5qEJ1R3M= lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15: - version "4.17.15" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548" - integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A== + version "4.17.20" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52" + integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA== lolex@^5.0.0: version "5.1.2"