This commit is contained in:
Ilya Kantor 2016-07-31 00:28:27 +03:00
parent 9064e35f3f
commit 4c531b5ae7
371 changed files with 338 additions and 316 deletions

View file

@ -0,0 +1,15 @@
function Calculator() {
this.read = function() {
this.a = +prompt('a?', 0);
this.b = +prompt('b?', 0);
};
this.sum = function() {
return this.a + this.b;
};
this.mul = function() {
return this.a * this.b;
};
}

View file

@ -0,0 +1,25 @@
sinon.stub(window, "prompt")
prompt.onCall(0).returns("2");
prompt.onCall(1).returns("3");
describe("calculator", function() {
var calculator;
before(function() {
calculator = new Calculator();
calculator.read();
});
it("при вводе 2 и 3 сумма равна 5", function() {
assert.equal(calculator.sum(), 5);
});
it("при вводе 2 и 3 произведение равно 6", function() {
assert.equal(calculator.mul(), 6);
});
});
after(function() {
prompt.restore();
});