mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-04 15:39:42 +08:00
20 lines
612 B
JavaScript
20 lines
612 B
JavaScript
import { calculateLevenshteinDp } from '../LevenshteinDistance'
|
|
|
|
test('Should return the distance counting additions and removals', () => {
|
|
const from = 'kitten'
|
|
const to = 'sitting'
|
|
expect(calculateLevenshteinDp(from, to)).toBe(3)
|
|
})
|
|
|
|
test('Should return the distance based on replacements in the middle of the strings', () => {
|
|
const from = 'book'
|
|
const to = 'back'
|
|
expect(calculateLevenshteinDp(from, to)).toBe(2)
|
|
})
|
|
|
|
test('Should return the distance for strings with different length', () => {
|
|
const from = 'sunday'
|
|
const to = 'saturday'
|
|
expect(calculateLevenshteinDp(from, to)).toBe(3)
|
|
})
|