Skip to content

Commit 686c8a9

Browse files
committed
1 parent 00d997c commit 686c8a9

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

test/searching/binarysearch.spec.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ describe('Binary search', function () {
99
expect(binarySearch([1, 2, 3, 4, 6, 8], 1)).toBe(0);
1010
});
1111

12-
it('should find the eleent in position arr.length', function () {
13-
expect(binarySearch([1, 2, 3, 4, 6, 8], 1)).toBe(0);
12+
it('should find the element in position arr.length - 1', function () {
13+
var arr = [1, 2, 3, 4, 6, 8];
14+
expect(binarySearch(arr, 8)).toBe(arr.length - 1);
1415
});
1516

1617
it('should work with arrays with 2 elements', function () {
@@ -31,6 +32,7 @@ describe('Binary search', function () {
3132
});
3233

3334
it('should work with a key function', function () {
34-
expect(binarySearch([{ x: 1 }, { x: 2 }, { x: 3 }], { x: 2 }, function (o) { return o.x; })).toBe(1);
35+
expect(binarySearch([{ x: 1 }, { x: 2 }, { x: 3 }],
36+
{ x: 2 }, function (o) { return o.x; })).toBe(1);
3537
});
3638
});

0 commit comments

Comments
 (0)