fix(LevenshteinDistance.test.js): Fixed broken test

This commit is contained in:
Rak Laptudirm
2021-05-21 12:52:06 +05:30
parent 7992caa54f
commit b77c0a18e2

View File

@ -1,4 +1,4 @@
import levenshteinDistance from './LevenshteinDistance' import { levenshteinDistance } from './LevenshteinDistance'
describe('levenshteinDistance', () => { describe('levenshteinDistance', () => {
it('should calculate edit distance between two strings', () => { it('should calculate edit distance between two strings', () => {
@ -14,13 +14,13 @@ describe('levenshteinDistance', () => {
// Should just substitute i with o, m with g and insert e at end // Should just substitute i with o, m with g and insert e at end
expect(levenshteinDistance('firm', 'forge')).toBe(3) expect(levenshteinDistance('firm', 'forge')).toBe(3)
// Should just substitute i with s, g with i, h with t and delete f from front // Should just substitute f with s, g with t and delete h
expect(levenshteinDistance('fighting', 'sitting')).toBe(4) expect(levenshteinDistance('fighting', 'sitting')).toBe(3)
// Should add 4 letters b, a, s and e at the beginning. // Should add 4 letters b, a, s and e at the beginning.
expect(levenshteinDistance('ball', 'baseball')).toBe(4) expect(levenshteinDistance('ball', 'baseball')).toBe(4)
// Should delete 4 letters b, a, s and e at the beginning. // Should delete 4 letters b, a, s and e at the beginning and replace the last 4 with f, o, o, t
expect(levenshteinDistance('baseball', 'foot')).toBe(4) expect(levenshteinDistance('baseball', 'foot')).toBe(8)
}) })
}) })