From 2101e30b8c61071609b038dc1d20ba9432b53ab3 Mon Sep 17 00:00:00 2001 From: Corban-Lee Date: Thu, 22 May 2025 11:23:22 +0100 Subject: [PATCH] test(bot): test the LITERAL filter --- src/bot/__tests__/filters.test.ts | 47 ++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/src/bot/__tests__/filters.test.ts b/src/bot/__tests__/filters.test.ts index 4e6b07b..2250ca2 100644 --- a/src/bot/__tests__/filters.test.ts +++ b/src/bot/__tests__/filters.test.ts @@ -118,7 +118,52 @@ describe("Match: ANY", () => { runFilterTest(filter, testCases); }); -describe("Match: LITERAL", () => { }); +describe("Match: LITERAL", () => { + const filter: prisma.Filter = { + ...templateFilter, + name: "Block Weekly Pop Quiz", + value: String.raw`Pop Quiz`, + matching_algorithm: MatchingAlgorithms.EXACT, + is_insensitive: false + }; + + const testCases: FilterTestCase[] = [ + { + input: "Pop Quiz 01: Win potential prizes in our first weekly pop quiz!", + expected: true + }, + { + input: "The price of petrol has fallen for the first time in 5 years.", + expected: false + }, + { + input: "The President's expected to deliver a speech for the easter holidays", + expected: false + }, + { + input: "Pop Quiz: in todays quiz, the prizes include $1000 USD!", + expected: true + }, + { + input: "The number of pop quizes at our disposoal is near infinite.", + expected: false + }, + { + input: "Pop Quiz!", + expected: true + }, + { + input: "There will be no Pop Quiz this week.", + expected: true + }, + { + input: "There will be a pop quiz this week", + expected: false // case sensitive + } + ]; + + runFilterTest(filter, testCases); +}); describe("Match: REGEX", () => { const filter: prisma.Filter = {