UNPKG

math-base-geometry

Version:

utils for math geometry

83 lines (74 loc) 2.87 kB
// const triDim = require("./../libs/tri-dimensional").triDimensional; // const twoDim = require("./../libs/two-dimensional").twoDimensional; const math = require("./../index"); const triDim = math.triDim; const twoDim = math.twoDim; const triangle = require("./test-triangle"); const cylinder = require("./test-cylinder"); const expect = require('chai').expect; triangle.test(expect, twoDim); describe('Sphere', () => { describe("Surface Area", () => { context("With 3 decimals and R=5", () => { it("Should return 314.159", () => { expect(triDim.Sphere.surfaceArea(5, 3)).to.equal(314.159); }); }) context("No decimals limit and R=5", () => { it("Should return 314.1592653589793", () => { expect(triDim.Sphere.surfaceArea(5)).to.equal(314.1592653589793); }); }) }); describe("Volume", () => { context("With 3 decimals and R=5", () => { it("Should return 523.598", () => { expect(triDim.Sphere.volume(5, 3)).to.equal(523.599); }); }); context("No decimals limit and R=5", () => { it("Should return 523.5987755982989", () => { expect(triDim.Sphere.volume(5)).to.equal(523.5987755982989); }); }) }); }); describe('Circle', () => { describe("Diameter of a Circle ", () => { context("With 2 decimals and R=1.99212", () => { it("Should return 3.98", () => { expect(twoDim.Circle.diameter(1.99212, 2)).to.equal(3.98); }); }) context("No decimals limit and R=1.99212", () => { it("Should return 3.98424", () => { expect(twoDim.Circle.diameter(1.99212)).to.equal(3.98424); }); }) }); describe("Circumference of a Circle ", () => { context("With 3 decimals and R=1.99212", () => { it("Should return 12.516", () => { expect(twoDim.Circle.circumference(1.99212, 3)).to.equal(12.517); }); }); context("No decimals limit and R=1.99212", () => { it("Should return 12.516859114139", () => { expect(twoDim.Circle.circumference(1.99212)).to.equal(12.516859114138597); }); }) }); describe("Area of a Circle", () => { context("With 3 decimals and R=1.99212", () => { it("Should return 12.467", () => { expect(twoDim.Circle.area(1.99212, 3)).to.equal(12.468); }); }); context("No decimals limit and R=1.99212", () => { it("Should return 12.46754268922889", () => { expect(twoDim.Circle.area(1.99212)).to.equal(12.46754268922889); }); }); }); }); cylinder.test(expect, triDim);