From c4bf62661edbbffc2fa16a768ec0c92fc3bcda86 Mon Sep 17 00:00:00 2001 From: karashiiro <49822414+karashiiro@users.noreply.github.com> Date: Thu, 13 Jul 2023 18:25:09 +0900 Subject: [PATCH] feat: remove auth from tests that don't require it --- src/profile.test.ts | 12 ++++++------ src/trends.test.ts | 4 ++-- src/tweets.test.ts | 13 ++++++------- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/profile.test.ts b/src/profile.test.ts index 31b9ba20..94036acc 100644 --- a/src/profile.test.ts +++ b/src/profile.test.ts @@ -1,5 +1,5 @@ -import { authSearchScraper } from './auth.test'; import { Profile } from './profile'; +import { Scraper } from './scraper'; test('scraper can get profile', async () => { const expected: Profile = { @@ -19,7 +19,7 @@ test('scraper can get profile', async () => { website: 'https://nomadic.name', }; - const scraper = await authSearchScraper(); + const scraper = new Scraper(); const actual = await scraper.getProfile('nomadic_ua'); expect(actual.avatar).toEqual(expected.avatar); @@ -56,7 +56,7 @@ test('scraper can get partial private profile', async () => { website: undefined, }; - const scraper = await authSearchScraper(); + const scraper = new Scraper(); const actual = await scraper.getProfile('tomdumont'); expect(actual.avatar).toEqual(expected.avatar); @@ -75,16 +75,16 @@ test('scraper can get partial private profile', async () => { }); test('scraper cannot get suspended profile', async () => { - const scraper = await authSearchScraper(); + const scraper = new Scraper(); expect(scraper.getProfile('123')).rejects.toThrow(); }); test('scraper cannot get not found profile', async () => { - const scraper = await authSearchScraper(); + const scraper = new Scraper(); expect(scraper.getProfile('sample3123131')).rejects.toThrow(); }); test('scraper can get profile by screen name', async () => { - const scraper = await authSearchScraper(); + const scraper = new Scraper(); await scraper.getProfile('Twitter'); }); diff --git a/src/trends.test.ts b/src/trends.test.ts index 16de6434..990b7cbc 100644 --- a/src/trends.test.ts +++ b/src/trends.test.ts @@ -1,7 +1,7 @@ -import { authSearchScraper } from './auth.test'; +import { Scraper } from './scraper'; test('scraper can get trends', async () => { - const scraper = await authSearchScraper(); + const scraper = new Scraper(); const trends = await scraper.getTrends(); expect(trends).toHaveLength(20); trends.forEach((trend) => expect(trend).not.toBeFalsy()); diff --git a/src/tweets.test.ts b/src/tweets.test.ts index 48312fbb..cdf60878 100644 --- a/src/tweets.test.ts +++ b/src/tweets.test.ts @@ -1,4 +1,3 @@ -import { authSearchScraper } from './auth.test'; import { Scraper } from './scraper'; import { Mention, Tweet } from './tweets'; @@ -29,7 +28,7 @@ test('scraper can get tweet', async () => { ], }; - const scraper = await authSearchScraper(); + const scraper = new Scraper(); const actual = await scraper.getTweet('1328684389388185600'); delete actual?.likes; delete actual?.replies; @@ -76,7 +75,7 @@ test('scraper can get user mentions in tweets', async () => { }, ]; - const scraper = await authSearchScraper(); + const scraper = new Scraper(); const tweet = await scraper.getTweet('1554522888904101890'); expect(expected).toEqual(tweet?.mentions); }); @@ -106,7 +105,7 @@ test('scraper can get tweet quotes and replies', async () => { videos: [], }; - const scraper = await authSearchScraper(); + const scraper = new Scraper(); const quote = await scraper.getTweet('1237110897597976576'); expect(quote?.isQuoted).toBeTruthy(); delete quote?.quotedStatus?.likes; @@ -148,7 +147,7 @@ test('scraper can get retweet', async () => { videos: [], }; - const scraper = await authSearchScraper(); + const scraper = new Scraper(); const retweet = await scraper.getTweet('1362849141248974853'); expect(retweet?.isRetweet).toBeTruthy(); delete retweet?.retweetedStatus?.likes; @@ -179,7 +178,7 @@ test('scraper can get tweet views', async () => { videos: [], }; - const scraper = await authSearchScraper(); + const scraper = new Scraper(); const actual = await scraper.getTweet('1606055187348688896'); expect(actual?.views).toBeTruthy(); delete actual?.likes; @@ -190,7 +189,7 @@ test('scraper can get tweet views', async () => { }); test('scraper can get tweet thread', async () => { - const scraper = await authSearchScraper(); + const scraper = new Scraper(); const tweet = await scraper.getTweet('1665602315745673217'); expect(tweet).not.toBeNull(); expect(tweet?.isSelfThread).toBeTruthy();