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