From b70d639180909bd1b6f55d5afcdbf4cd383c4518 Mon Sep 17 00:00:00 2001 From: Thomas Wilkerling Date: Thu, 17 Apr 2025 10:11:27 +0200 Subject: [PATCH] add test for context chain (term duplication) --- test/context.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/test/context.js b/test/context.js index e4dee3a..4b1544b 100644 --- a/test/context.js +++ b/test/context.js @@ -126,4 +126,34 @@ describe("Context", function(){ result = index.search("1 2 3", { context: false }); expect(result[0]).to.equal(1); }); + + it("Should have been handled properly the context chain (term deduplication)", function(){ + + let index = new Index({ context: true }); + index.add(1, "A A B B C C A A B B C C"); + + let result = index.search("A"); + expect(result).to.eql([1]); + + result = index.search("A A"); + expect(result).to.eql([1]); + + result = index.search("A A A"); + expect(result).to.eql([1]); + + result = index.search("A B A"); + expect(result).to.eql([1]); + + result = index.search("A B B"); + expect(result).to.eql([1]); + + result = index.search("B A B"); + expect(result).to.eql([1]); + + result = index.search("B A A"); + expect(result).to.eql([1]); + + result = index.search("C C B B A A"); + expect(result).to.eql([1]); + }); });