Skip to content

Updation required in Test Case for Calculator.js - Hard Problem in 01-js #14

@ankit-95

Description

@ankit-95

Before :

 test("calculate division by zero", () => {
    expect(() => calc.calculate("10 / 0")).toThrow(Error);
  });

After :

 test("calculate division by zero", () => {
    expect(() => calc.calculate("10 / 0").value()).toThrow(Error);
  });

I would recommend this changes as current code is not working even if error is thrown while checking for division by zero. i.e,
Below code is correct in my view, but still test case is failing.

divide(num) {
    if (num === 0) throw new Error("NaN");
    this.result /= num;
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions