From 1e6d41a967bfb915873a4997cf7f19fac9102b37 Mon Sep 17 00:00:00 2001 From: Louis Grasset Date: Wed, 22 Nov 2023 23:05:11 +0100 Subject: [PATCH] test(tweet): extend coverage on getEligibleTweet --- .../tweet/__tests__/get-eligible-tweet.spec.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/helpers/tweet/__tests__/get-eligible-tweet.spec.ts b/src/helpers/tweet/__tests__/get-eligible-tweet.spec.ts index 4fc91e4..a401959 100644 --- a/src/helpers/tweet/__tests__/get-eligible-tweet.spec.ts +++ b/src/helpers/tweet/__tests__/get-eligible-tweet.spec.ts @@ -6,6 +6,7 @@ import { keepRecentTweets, keepSelfQuotes, keepSelfReplies } from "../index.js"; jest.mock("../../../constants.js", () => { return { TWITTER_HANDLE: "username", + DEBUG: true, }; }); jest.mock("../index.js", () => { @@ -17,6 +18,16 @@ jest.mock("../index.js", () => { }); describe("getEligibleTweet", () => { + const originalConsole = console.log; + const consoleMock = jest.fn(); + beforeEach(() => { + console.log = consoleMock; + }); + + afterAll(() => { + console.log = originalConsole; + }); + it.each` isNotRetweet | isSelfReply | isSelfQuote | isRecentTweet | keep ${false} | ${false} | ${false} | ${false} | ${false} @@ -49,6 +60,10 @@ describe("getEligibleTweet", () => { } : undefined, ); + + if (result) { + expect(consoleMock).toHaveBeenCalledTimes(1); + } }, ); });