Skip to content

Commit

Permalink
Added test for Damerau search (#595)
Browse files Browse the repository at this point in the history
* Added test for Damerau search

* Removed semicolons

* Space
  • Loading branch information
Hugo-ter-Doest authored Mar 27, 2021
1 parent 99334ee commit 0504789
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions spec/damerau_levenshtein_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down Expand Up @@ -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
})
})
})

0 comments on commit 0504789

Please sign in to comment.