This commit is contained in:
Ilya Kantor 2016-11-06 19:42:32 +03:00
parent 779601901f
commit 5372c18379
152 changed files with 482 additions and 371 deletions

View file

@ -0,0 +1,15 @@
let ladder = {
step: 0,
up: function() {
this.step++;
return this;
},
down: function() {
this.step--;
return this;
},
showStep: function() {
alert(this.step);
}
};

View file

@ -0,0 +1,40 @@
describe('Ladder', function() {
before(function() {
window.alert = sinon.stub(window, "alert");
});
beforeEach(function() {
ladder.step = 0;
});
it('up() should return this', function() {
assert.equal(ladder.up(), ladder);
});
it('down() should return this', function() {
assert.equal(ladder.down(), ladder);
});
it('showStep() should call alert', function() {
ladder.showStep();
assert(alert.called);
});
it('up() should increase step', function() {
assert.equal(ladder.up().up().step, 2);
});
it('down() should decrease step', function() {
assert.equal(ladder.down().step, -1);
});
it('down().up().up().up() ', function() {
assert.equal(ladder.down().up().up().up().step, 2);
});
after(function() {
ladder.step = 0;
alert.restore();
});
});