2024-01-01 16:14:25 +01:00
|
|
|
import { expect } from 'chai';
|
2025-09-07 22:15:14 +02:00
|
|
|
import * as similarityCache from '../../lib/services/similarity-check/similarityCache.js';
|
2024-01-01 16:14:25 +01:00
|
|
|
|
2021-06-28 08:52:09 +02:00
|
|
|
describe('similarityCheck', () => {
|
2025-09-07 22:15:14 +02:00
|
|
|
it('should return true on duplicate', () => {
|
|
|
|
|
similarityCache.addCacheEntry('Hello World', 'Test');
|
|
|
|
|
expect(similarityCache.hasSimilarEntries('Hello World', 'Test')).to.be.true;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should return true even if one value is null', () => {
|
|
|
|
|
similarityCache.addCacheEntry('Hello World', null);
|
|
|
|
|
expect(similarityCache.hasSimilarEntries('Hello World', null)).to.be.true;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should return true even if one value is an obj', () => {
|
|
|
|
|
similarityCache.addCacheEntry('Hello World', [{ TR: 'OLOLO' }]);
|
|
|
|
|
expect(similarityCache.hasSimilarEntries('Hello World', [{ TR: 'OLOLO' }])).to.be.true;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should return false when no duplicate', () => {
|
|
|
|
|
similarityCache.addCacheEntry('Hello World__', 'Test');
|
|
|
|
|
expect(similarityCache.hasSimilarEntries('Hello World___', 'Test')).to.be.false;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should return false when no duplicate', () => {
|
|
|
|
|
expect(similarityCache.hasSimilarEntries('Hello World', 'Test')).to.be.true;
|
|
|
|
|
similarityCache.invalidateAllForTest();
|
|
|
|
|
expect(similarityCache.hasSimilarEntries('Hello World', 'Test')).to.be.false;
|
2021-06-28 08:52:09 +02:00
|
|
|
});
|
|
|
|
|
});
|