dist-javascript-algorithms-and-data-structures
Version:
Algorithms and data-structures implemented on JavaScript
24 lines (20 loc) • 1.05 kB
JavaScript
;
var _hammingDistance = _interopRequireDefault(require("../hammingDistance"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
describe('hammingDistance', () => {
it('should throw an error when trying to compare the strings of different lengths', () => {
const compareStringsOfDifferentLength = () => {
(0, _hammingDistance.default)('a', 'aa');
};
expect(compareStringsOfDifferentLength).toThrowError();
});
it('should calculate difference between two strings', () => {
expect((0, _hammingDistance.default)('a', 'a')).toBe(0);
expect((0, _hammingDistance.default)('a', 'b')).toBe(1);
expect((0, _hammingDistance.default)('abc', 'add')).toBe(2);
expect((0, _hammingDistance.default)('karolin', 'kathrin')).toBe(3);
expect((0, _hammingDistance.default)('karolin', 'kerstin')).toBe(3);
expect((0, _hammingDistance.default)('1011101', '1001001')).toBe(2);
expect((0, _hammingDistance.default)('2173896', '2233796')).toBe(3);
});
});