Code coverage report for spec/algo/3-stacks/sort.spec.js

Statements: 100% (29 / 29)      Branches: 100% (0 / 0)      Functions: 100% (5 / 5)      Lines: 100% (29 / 29)      Ignored: none     

All files » spec/algo/3-stacks/ » sort.spec.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 451 1   1   1   1 3     1 1 1   1 1     1 1 1 1   1 1     1 1 1 1 1 1 1   1 1 1 1 1        
var sort = require("../../../lib/algorithms/3-stacks/sort.js");
var stack = require("../../../lib/dataStructures/stack.js");
 
describe('When sorting a stack, using only stacks', function () {
 
    var unsorted;
 
    beforeEach(function() {
        unsorted = new stack();
    });
 
    it('a stack of 1 element can be sorted.', function () {
        unsorted.push(10);
        var sorted = sort(unsorted);
 
        expect(sorted.length).toBe(1);
        expect(sorted.pop()).toBe(10);
    });
 
    it('a stack of 2 elements can be sorted.', function () {
        unsorted.push(10);
        unsorted.push(20);
        var sorted = sort(unsorted);
 
        expect(sorted.length).toBe(2);
        expect(sorted.pop()).toBe(20);
    });
 
    it('a stack of 5 elements can be sorted.', function () {
        unsorted.push(10);
        unsorted.push(20);
        unsorted.push(30);
        unsorted.push(40);
        unsorted.push(50);
        var sorted = sort(unsorted);
 
        expect(sorted.length).toBe(5);
        expect(sorted.pop()).toBe(50);
        expect(sorted.pop()).toBe(40);
        expect(sorted.pop()).toBe(30);
        expect(sorted.pop()).toBe(20);
    });
 
 
});