Skip to content

Commit

Permalink
fixes bubble sort
Browse files Browse the repository at this point in the history
  • Loading branch information
zhen0 committed Apr 3, 2019
1 parent 518dc91 commit fbe9e7d
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions bubblesort.spec.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
beforeAll(function() {
spyOn(bubble, "swap").and.callThrough(); // replace existing `tootsiepop['lick']` method
});
it("getting to the center of tootsiepop involves exactly three licks", function() {
bubble.bubbleSort([]);
expect(bubble.swap.calls.count()).toEqual(0);
describe("swap", function() {
beforeAll(function() {
spyOn(bubble, "swap").and.callThrough(); // replace existing `tootsiepop['lick']` method
});
it("has no swaps on empty array", function() {
bubble.bubbleSort([]);
expect(bubble.swap.calls.count()).toEqual(0);
});
it("has no swaps on an array of one", function() {
bubble.bubbleSort([3]);
expect(bubble.swap.calls.count()).toEqual(0);
});
it("has 1 swap on an array of two", function() {
bubble.bubbleSort([4, 2]);
expect(bubble.swap.calls.count()).toEqual(1);
});
it("has less than 10 swaps on an array of ten", function() {
bubble.bubbleSort([1, 2, 3, 5, 6, 8, 9, 10, 18]);
expect(bubble.swap.calls.count()).toBeLessThan(10);
});
});

describe("Bubble Sort", function() {
Expand Down

0 comments on commit fbe9e7d

Please sign in to comment.