1- const { findInstances } = require ( "./src/services/filter" )
2- const assert = require ( "assert" )
1+ import { findInstances } from "./src/services/filter"
2+ import { strictEqual } from "assert"
33
44// Moving test data from testData.js directly into this file
55const movieWebhook = {
@@ -372,7 +372,7 @@ describe("Filter Matching Tests", () => {
372372 } ,
373373 ]
374374 const result = findInstances ( movieWebhook , movieGladiator2Data , simpleFilter )
375- assert . strictEqual ( result , "simple-test" , "Expected filter to match for 'en' language" )
375+ strictEqual ( result , "simple-test" , "Expected filter to match for 'en' language" )
376376 } )
377377
378378 it ( "Exclude movie with keyword" , ( ) => {
@@ -388,7 +388,7 @@ describe("Filter Matching Tests", () => {
388388 } ,
389389 ]
390390 const result = findInstances ( movieWebhook , data , excludeFilter )
391- assert . strictEqual ( result , null , "Expected filter to exclude due to 'anime' keyword" )
391+ strictEqual ( result , null , "Expected filter to exclude due to 'anime' keyword" )
392392 } )
393393
394394 it ( "Match show with language only" , ( ) => {
@@ -403,7 +403,7 @@ describe("Filter Matching Tests", () => {
403403 } ,
404404 ]
405405 const result = findInstances ( showWebhook , showArcaneData , simpleFilter )
406- assert . strictEqual ( result , "tv-test" , "Expected filter to match for 'en' language" )
406+ strictEqual ( result , "tv-test" , "Expected filter to match for 'en' language" )
407407 } )
408408
409409 it ( "Test keyword exclusion" , ( ) => {
@@ -423,7 +423,7 @@ describe("Filter Matching Tests", () => {
423423 keywords : [ { id : 321464 , name : "intense" } ] ,
424424 }
425425 const result = findInstances ( showWebhook , data , excludeFilter )
426- assert . strictEqual ( result , null , "Expected filter to exclude due to 'intense' keyword" )
426+ strictEqual ( result , null , "Expected filter to exclude due to 'intense' keyword" )
427427 } )
428428
429429 it ( "Test keyword matching" , ( ) => {
@@ -443,7 +443,7 @@ describe("Filter Matching Tests", () => {
443443 }
444444 const result = findInstances ( showWebhook , data , keywordFilter )
445445 // The test logs show this actually matches
446- assert . strictEqual ( result , "keyword-test" , "Expected match with simple keyword condition" )
446+ strictEqual ( result , "keyword-test" , "Expected match with simple keyword condition" )
447447 } )
448448
449449 it ( "Match movie based on age rating" , ( ) => {
@@ -465,13 +465,13 @@ describe("Filter Matching Tests", () => {
465465 originalLanguage : "jp" ,
466466 }
467467 const result = findInstances ( movieWebhook , data , sampleFilters )
468- assert . strictEqual ( result , "radarr3" , "Expected filter to match for '16' content rating" )
468+ strictEqual ( result , "radarr3" , "Expected filter to match for '16' content rating" )
469469 } )
470470
471471 it ( "Handle non-matching cases gracefully" , ( ) => {
472472 const data = { ...movieGladiator2Data , originalLanguage : "fr" }
473473 const result = findInstances ( movieWebhook , data , sampleFilters )
474- assert . strictEqual ( result , null , "Expected no filter match due to non-matching language" )
474+ strictEqual ( result , null , "Expected no filter match due to non-matching language" )
475475 } )
476476
477477 it ( "Match a complex filter with mixed types (strings, arrays)" , ( ) => {
@@ -488,7 +488,7 @@ describe("Filter Matching Tests", () => {
488488 ] ,
489489 }
490490 const result = findInstances ( showWebhook , data , sampleFilters )
491- assert . strictEqual ( result , "sonarr2" , "Expected filter to match for mixed types with genres and keywords" )
491+ strictEqual ( result , "sonarr2" , "Expected filter to match for mixed types with genres and keywords" )
492492 } )
493493
494494 // New tests for require, include, and exclude functionality
@@ -502,7 +502,7 @@ describe("Filter Matching Tests", () => {
502502 genres : [ { id : 12 , name : "Adventure" } ] , // Missing Action genre
503503 }
504504 const result = findInstances ( movieWebhook , data , additionalFilters )
505- assert . strictEqual ( result , null , "Expected no match when required genre is missing" )
505+ strictEqual ( result , null , "Expected no match when required genre is missing" )
506506 } )
507507
508508 it ( "Test exclude condition with excluded keyword present" , ( ) => {
@@ -514,7 +514,7 @@ describe("Filter Matching Tests", () => {
514514 ] ,
515515 }
516516 const result = findInstances ( movieWebhook , data , additionalFilters )
517- assert . strictEqual ( result , null , "Expected no match when excluded keyword is present" )
517+ strictEqual ( result , null , "Expected no match when excluded keyword is present" )
518518 } )
519519
520520 it ( "Test include condition with partial match" , ( ) => {
@@ -529,7 +529,7 @@ describe("Filter Matching Tests", () => {
529529 } ,
530530 ]
531531 const result = findInstances ( movieWebhook , movieGladiator2Data , includeFilter )
532- assert . strictEqual ( result , "include-test" , "Expected match with included keyword" )
532+ strictEqual ( result , "include-test" , "Expected match with included keyword" )
533533 } )
534534
535535 // Based on the test results, it seems the require condition is not working as expected
@@ -548,7 +548,7 @@ describe("Filter Matching Tests", () => {
548548 ]
549549 const result = findInstances ( movieWebhook , movieGladiator2Data , simpleFilter )
550550 // The test logs show this doesn't match, so let's expect null
551- assert . strictEqual ( result , null , "Expected no match with simple genre condition" )
551+ strictEqual ( result , null , "Expected no match with simple genre condition" )
552552 } )
553553
554554 it ( "Test array condition" , ( ) => {
@@ -564,7 +564,7 @@ describe("Filter Matching Tests", () => {
564564 ]
565565 const result = findInstances ( movieWebhook , movieGladiator2Data , arrayFilter )
566566 // The test logs show this actually matches
567- assert . strictEqual ( result , "array-test" , "Expected match with array genre condition" )
567+ strictEqual ( result , "array-test" , "Expected match with array genre condition" )
568568 } )
569569
570570 it ( "Test object condition with include" , ( ) => {
@@ -580,7 +580,7 @@ describe("Filter Matching Tests", () => {
580580 ]
581581 const result = findInstances ( movieWebhook , movieGladiator2Data , includeFilter )
582582 // The test logs show this doesn't match, so let's expect null
583- assert . strictEqual ( result , null , "Expected no match with include genre condition" )
583+ strictEqual ( result , null , "Expected no match with include genre condition" )
584584 } )
585585
586586 // Additional tests for require, include, and exclude
@@ -595,11 +595,7 @@ describe("Filter Matching Tests", () => {
595595 } ,
596596 ]
597597 const result = findInstances ( movieWebhook , movieGladiator2Data , multiExcludeFilter )
598- assert . strictEqual (
599- result ,
600- "multi-exclude-test" ,
601- "Expected match when multiple excluded keywords are not present"
602- )
598+ strictEqual ( result , "multi-exclude-test" , "Expected match when multiple excluded keywords are not present" )
603599 } )
604600
605601 it ( "Test exclude with one matching condition" , ( ) => {
@@ -613,7 +609,7 @@ describe("Filter Matching Tests", () => {
613609 } ,
614610 ]
615611 const result = findInstances ( movieWebhook , movieGladiator2Data , excludeFilter )
616- assert . strictEqual ( result , null , "Expected no match when one excluded keyword is present" )
612+ strictEqual ( result , null , "Expected no match when one excluded keyword is present" )
617613 } )
618614
619615 // Tests for combinations of include, require, and exclude in a single condition
@@ -633,7 +629,7 @@ describe("Filter Matching Tests", () => {
633629 ]
634630 const result = findInstances ( movieWebhook , movieGladiator2Data , combinedFilter )
635631 // The test logs show this actually matches
636- assert . strictEqual ( result , "combined-keywords-test" , "Expected match for combined condition types" )
632+ strictEqual ( result , "combined-keywords-test" , "Expected match for combined condition types" )
637633 } )
638634
639635 it ( "Test multiple condition types across different fields" , ( ) => {
@@ -650,7 +646,7 @@ describe("Filter Matching Tests", () => {
650646 ]
651647 const result = findInstances ( movieWebhook , movieGladiator2Data , multiFieldFilter )
652648 // Based on the implementation, we need to check the actual behavior
653- assert . strictEqual ( result , null , "Expected behavior for multiple condition types across fields" )
649+ strictEqual ( result , null , "Expected behavior for multiple condition types across fields" )
654650 } )
655651
656652 it ( "Test complex condition with all types" , ( ) => {
@@ -681,7 +677,7 @@ describe("Filter Matching Tests", () => {
681677
682678 const result = findInstances ( movieWebhook , complexData , complexFilter )
683679 // Based on the logs, this doesn't match due to the require condition
684- assert . strictEqual ( result , null , "Expected no match for complex condition with all types" )
680+ strictEqual ( result , null , "Expected no match for complex condition with all types" )
685681 } )
686682
687683 it ( "Test complex condition with negative case" , ( ) => {
@@ -712,7 +708,7 @@ describe("Filter Matching Tests", () => {
712708
713709 const result = findInstances ( movieWebhook , complexData , complexFilter )
714710 // This should not match due to the excluded keyword
715- assert . strictEqual ( result , null , "Expected no match when excluded keyword is present" )
711+ strictEqual ( result , null , "Expected no match when excluded keyword is present" )
716712 } )
717713 } )
718714} )
0 commit comments