diff --git a/src/__tests__/__fixtures__/config.ts b/src/__tests__/__fixtures__/config.ts index 986cca1..44153f3 100644 --- a/src/__tests__/__fixtures__/config.ts +++ b/src/__tests__/__fixtures__/config.ts @@ -19,7 +19,7 @@ export const getTweetDefaultConfigs = (overrides?: Partial, userCon minFavsToFollowers: 0.02, hashtagsLimit: 5, userConfig: getUserDefaultConfigs(userConfigOverrides), - wordBlockList: [] + wordBlocklist: [] }; return {...defaultConfigs, ...overrides}; diff --git a/src/__tests__/entities/tweet.test.ts b/src/__tests__/entities/tweet.test.ts index b3422a2..3f4837b 100644 --- a/src/__tests__/entities/tweet.test.ts +++ b/src/__tests__/entities/tweet.test.ts @@ -152,7 +152,7 @@ describe('Tweet', () => { text: 'this tweet has a bad word in it' }), getTweetDefaultConfigs({ - wordBlockList: ['bad', 'worst'] + wordBlocklist: ['bad', 'worst'] }) ); @@ -174,7 +174,7 @@ describe('Tweet', () => { text: '' }), getTweetDefaultConfigs({ - wordBlockList: ['bad', 'worst'] + wordBlocklist: ['bad', 'worst'] }) ); @@ -187,7 +187,7 @@ describe('Tweet', () => { text: 'this is a good tweet' }), getTweetDefaultConfigs({ - wordBlockList: ['bad', 'worst'] + wordBlocklist: ['bad', 'worst'] }) ); @@ -347,7 +347,7 @@ describe('Tweet', () => { statuses_count: 1000, }) }), getTweetDefaultConfigs({ - wordBlockList: ['worst'] + wordBlocklist: ['worst'] })); expect(tweet.isReTweetable()).toBe(false); diff --git a/src/entities/Tweet.ts b/src/entities/Tweet.ts index cdd8f85..6181c48 100644 --- a/src/entities/Tweet.ts +++ b/src/entities/Tweet.ts @@ -8,7 +8,7 @@ export type TweetConfig = { minFavsToFollowers: number, hashtagsLimit: number, userConfig: TweetUserConfig, - wordBlockList?: string[] + wordBlocklist?: string[] }; export default class Tweet extends ReTweetableAbstract { @@ -56,14 +56,14 @@ export default class Tweet extends ReTweetableAbstract { } hasBlockListedWord(): boolean { - if (!Helper.objectExists(this.config.wordBlockList) + if (!Helper.objectExists(this.config.wordBlocklist) || !Helper.objectExists(this.rawTweet.text)) { return false; } const tweetText = this.rawTweet.text.toLowerCase(); - return this.config.wordBlockList.some(blockListedWord => tweetText.includes(blockListedWord.toLowerCase())); + return this.config.wordBlocklist.some(blockListedWord => tweetText.includes(blockListedWord.toLowerCase())); } getRetweetValidations(): Validation[] {