describe("tanh", () => { it("tanh(1)==0.7615941559557649", () => { expect(NetMath.tanh(1)).to.equal(0.7615941559557649) }) it("tanh(0.5)==0.46211715726000974", () => { expect(NetMath.tanh(0.5)).to.equal(0.46211715726000974) }) it("tanh(0.5, true)==0.7864477329659275", () => { expect(NetMath.tanh(0.5, true)).to.equal(0.7864477329659275) }) it("tanh(1.5, true)==0.18070663892364855", () => { expect(NetMath.tanh(1.5, true)).to.equal(0.18070663892364855) }) it("Doesn't return NaN if the input value is too high", () => { expect(NetMath.tanh(900)).to.not.be.NaN expect(NetMath.tanh(900, true)).to.not.be.NaN }) })
describe("test addition", () => { it('simple addition', () => { //Arrange/Act const rtnValue = math.parseEquation('1 + 1'); //Assert expect(rtnValue).to.equal(2); }); it('invalid input', () => { //Arrange/Act const rtnValue = math.parseEquation('1 + one'); //Assert expect(rtnValue).to.be.NaN; }); it('invalid input between numbers', () => { //Arrange/Act const rtnValue = math.parseEquation('1 + 123asdf453'); //Assert expect(rtnValue).to.be.NaN; }); });
it("NaN", () => { expect(NaN).to.be.NaN; expect(undefined).not.to.be.NaN; expect(Infinity).not.to.be.NaN; expect("foo").not.to.be.NaN; expect({}).not.to.be.NaN; expect(4).not.to.be.NaN; expect([]).not.to.be.NaN; expect(NaN, "blah").not.to.be.NaN; }).to.throw(AssertionError, "blah: expected NaN not to be NaN"); expect(undefined).to.be.NaN; }).to.throw(AssertionError, "expected undefined to be NaN"); expect(Infinity).to.be.NaN; }).to.throw(AssertionError, "expected Infinity to be NaN"); expect("foo").to.be.NaN; }).to.throw(AssertionError, "expected 'foo' to be NaN"); expect({}).to.be.NaN; }).to.throw(AssertionError, "expected {} to be NaN"); expect(4).to.be.NaN; }).to.throw(AssertionError, "expected 4 to be NaN"); expect([]).to.be.NaN; }).to.throw(AssertionError, "expected [] to be NaN"); });