[READ-ONLY] Mirror of https://github.com/FoxxMD/string-sameness. Compare the sameness of two strings foxxmd.github.io/string-sameness/
compare cosine-similarity dice-coefficient levenshtein-distance sameness string text typescript
0

Configure Feed

Select the types of activity you want to include in your feed.

test: Add close but not identical

FoxxMD (Oct 26, 2023, 1:20 PM EDT) 112606f5 a9eae897

+12 -3
+12 -3
tests/index.test.ts
··· 50 50 51 51 describe('Sanity Checks', function() { 52 52 53 - describe('scores identical when strings are identical', function() { 53 + describe('scores 100 when strings are identical', function() { 54 54 for(const [name, strat] of Object.entries(strategies)) { 55 55 it(`${name}: strings are identical`, function() { 56 56 const res = strat.strategy(sameString, sameString); 57 - assert.equal(100, res.score); 57 + assert.equal(res.score, 100); 58 + }); 59 + } 60 + }); 61 + 62 + describe('scores not 100 when strings are close but not identical', function() { 63 + for(const [name, strat] of Object.entries(strategies)) { 64 + it(`${name}: strings are close but not identical`, function() { 65 + const res = strat.strategy('Another Brick in the Wall, Pt. 1', 'Another Brick in the Wall, Pt. 2'); 66 + assert.isAtMost(res.score, 99); 58 67 }); 59 68 } 60 69 }); 61 70 62 71 describe('scores near zero when strings are completely different', function() { 63 72 for(const [name, strat] of Object.entries(strategies)) { 64 - it(`${name}: string are completely different`, function() { 73 + it(`${name}: strings are completely different`, function() { 65 74 const res = strat.strategy(sameString, 'pay bull blood for voice'); 66 75 assert.isAtMost(res.score, 10); 67 76 });