en.javascript.info/1-js/04-object-basics/04-object-methods/7-calculator/_js.view/test.js
Mustafa Kemal Tuna afd41eaf86
each unit parts must be tested
For completeness of the test cases we could add tests for the read method. So every method can have individual test cases.
2021-01-12 05:22:25 +03:00

33 lines
694 B
JavaScript

describe("calculator", function() {
context("when 2 and 3 entered", function() {
beforeEach(function() {
sinon.stub(window, "prompt");
prompt.onCall(0).returns("2");
prompt.onCall(1).returns("3");
calculator.read();
});
afterEach(function() {
prompt.restore();
});
it('the read get two values and saves them as object properties', function () {
assert.equal(calculator.a, 2);
assert.equal(calculator.b, 3);
});
it("the sum is 5", function() {
assert.equal(calculator.sum(), 5);
});
it("the multiplication product is 6", function() {
assert.equal(calculator.mul(), 6);
});
});
});