Skip to content
Snippets Groups Projects
Select Git revision
  • 663d7e42b9f9c0436bf4f1e4fce11dbb82036a38
  • master default protected
  • renovate/configure
3 results

estimator.spec.ts

Blame
  • Jonas's avatar
    Jonas Zohren authored
    663d7e42
    History
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    estimator.spec.ts 2.92 KiB
    import { WorkPackage, calculateE, calculateV, calculateS } from "../estimator";
    import "mocha";
    import { assert } from "chai";
    
    const roundOne = (n) => Math.round(n * Math.pow(10, 1)) / Math.pow(10, 1);
    
    describe("Estimator Calculation", function () {
      describe("#calculateE()", function () {
        it("should return 100, if a and b are 100 and c undefined", function () {
          assert.equal(calculateE({ a: 100, b: 100 }), 100);
        });
    
        it("should return 100, if a and b are 100 and c null", function () {
          assert.equal(calculateE({ a: 100, b: 100, c: null }), 100);
        });
    
        it("should return 50, if a = 0, b = 100 and c null", function () {
          assert.equal(calculateE({ a: 0, b: 100, c: null }), 50);
        });
    
        it("should return 50, if a = 0, b = 100 and c = 50", function () {
          assert.equal(calculateE({ a: 0, b: 100, c: 50 }), 50);
        });
    
        describe("Vorlesungsbeispiele:", function () {
          it("should return 36.7, if {a,c,b} = {20,30,80}", function () {
            assert.equal(roundOne(calculateE({ a: 20, c: 30, b: 80 })), 36.7);
          });
    
          it("should return 20, if {a,c,b} = {10,20,30}", function () {
            assert.equal(roundOne(calculateE({ a: 10, c: 20, b: 30 })), 20);
          });
    
          it("should return 20.8, if {a,c,b} = {15,20,30}", function () {
            assert.equal(roundOne(calculateE({ a: 15, c: 20, b: 30 })), 20.8);
          });
    
          it("should return 9.5, if {a,c,b} = {5,8,20}", function () {
            assert.equal(roundOne(calculateE({ a: 5, c: 8, b: 20 })), 9.5);
          });
        });
      });
    
      describe("#calculateV()", function () {
        describe("Vorlesungsbeispiele:", function () {
          it("should return 36.7, if {a,c,b} = {20,30,80}", function () {
            assert.equal(roundOne(calculateE({ a: 20, c: 30, b: 80 })), 36.7);
          });
    
          it("should return 11.1, if {a,c,b} = {10,20,30}", function () {
            assert.equal(roundOne(calculateV({ a: 10, c: 20, b: 30 })), 11.1);
          });
    
          it("should return 6.3, if {a,c,b} = {15,20,30}", function () {
            assert.equal(roundOne(calculateV({ a: 15, c: 20, b: 30 })), 6.3);
          });
    
          it("should return 6.3, if {a,c,b} = {5,8,20}", function () {
            assert.equal(roundOne(calculateV({ a: 5, c: 8, b: 20 })), 6.3);
          });
        });
      });
    
      describe("#calculateS()", function () {
        describe("Vorlesungsbeispiele:", function () {
          it("should return 10, if {a,c,b} = {20,30,80}", function () {
            assert.equal(roundOne(calculateS({ a: 20, c: 30, b: 80 })), 10);
          });
    
          it("should return 3.3, if {a,c,b} = {10,20,30}", function () {
            assert.equal(roundOne(calculateS({ a: 10, c: 20, b: 30 })), 3.3);
          });
    
          it("should return 2.5, if {a,c,b} = {15,20,30}", function () {
            assert.equal(roundOne(calculateS({ a: 15, c: 20, b: 30 })), 2.5);
          });
    
          it("should return 2.5, if {a,c,b} = {5,8,20}", function () {
            assert.equal(roundOne(calculateS({ a: 5, c: 8, b: 20 })), 2.5);
          });
        });
      });
    });