From 050478994835d7caa95232af0fe240a3d9389976 Mon Sep 17 00:00:00 2001 From: Hugo ter Doest Date: Sat, 27 Mar 2021 19:40:58 +0100 Subject: [PATCH] Added test for Damerau search (#595) * Added test for Damerau search * Removed semicolons * Space --- spec/damerau_levenshtein_spec.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/spec/damerau_levenshtein_spec.js b/spec/damerau_levenshtein_spec.js index a768fc2ff..2731871cc 100644 --- a/spec/damerau_levenshtein_spec.js +++ b/spec/damerau_levenshtein_spec.js @@ -2,6 +2,8 @@ const damerauLevenshtein = require('../lib/natural/distance/levenshtein_distance') .DamerauLevenshteinDistance +const damerauLevenshteinSearch = require('../lib/natural/distance/levenshtein_distance') + .DamerauLevenshteinDistanceSearch describe('DamerauLevenshtein', function () { describe('default', function () { @@ -40,4 +42,15 @@ describe('DamerauLevenshtein', function () { expect(damerauLevenshtein('CA', 'ABC', restricted)).toBe(3) }) }) + + it('should combine search with Damerau', function () { + const source = 'The RainCoat BookStore' + const target = 'All the best books are here at the Rain Coats Book Store' + const result = damerauLevenshteinSearch(source, target) + expect(result).toEqual({ + substring: 'the Rain Coats Book Store', + distance: 4, + offset: 31 + }) + }) })