Skip to content

Commit

Permalink
feat: remove auth from tests that don't require it
Browse files Browse the repository at this point in the history
  • Loading branch information
karashiiro committed Jul 13, 2023
1 parent fdf8647 commit c4bf626
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
12 changes: 6 additions & 6 deletions src/profile.test.ts
Original file line number Diff line number Diff line change
@@ -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 = {
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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');
});
4 changes: 2 additions & 2 deletions src/trends.test.ts
Original file line number Diff line number Diff line change
@@ -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());
Expand Down
13 changes: 6 additions & 7 deletions src/tweets.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { authSearchScraper } from './auth.test';
import { Scraper } from './scraper';
import { Mention, Tweet } from './tweets';

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

0 comments on commit c4bf626

Please sign in to comment.