From cadd50a7d5ff6512f3c60af9ddd26856a4390135 Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Wed, 8 May 2013 09:09:42 -0400 Subject: [PATCH] Test iD.util.editDistance --- test/spec/util.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/spec/util.js b/test/spec/util.js index c0000fd36..85d901259 100644 --- a/test/spec/util.js +++ b/test/spec/util.js @@ -24,6 +24,24 @@ describe('iD.Util', function() { expect(iD.util.getPrototypeOf(new a())).to.eql({ foo: 'foo' }); }); + describe('#editDistance', function() { + it('returns zero for same strings', function() { + expect(iD.util.editDistance('foo', 'foo')).to.eql(0); + }); + + it('reports an insertion of 1', function() { + expect(iD.util.editDistance('foo', 'fooa')).to.eql(1); + }); + + it('reports a replacement of 1', function() { + expect(iD.util.editDistance('foob', 'fooa')).to.eql(1); + }); + + it('does not fail on empty input', function() { + expect(iD.util.editDistance('', '')).to.eql(0); + }); + }); + describe('#asyncMap', function() { it('handles correct replies', function() { iD.util.asyncMap([1, 2, 3],