Aliendreamer

mathenforcer js problem 4

Feb 22nd, 2019
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. describe("mathEnforcer", function() {
  2.  
  3.  
  4.     describe("addFive", function() {
  5.         it("should return undefined when no parameters are given", () => {
  6.             let result = mathEnforcer.addFive();
  7.             assert.isUndefined(result);
  8.         });
  9.  
  10.        
  11.         it("should return undefined for invalid type of the parameter", () => {
  12.             let input = "test";
  13.             let result = mathEnforcer.addFive(input);
  14.             assert.isUndefined(result);
  15.         });
  16.  
  17.         it("should return NaN for invalid type of the parameter", () => {
  18.             let input = NaN;
  19.             let result = mathEnforcer.addFive(input);
  20.             assert.isNaN(result);
  21.         });
  22.  
  23.         it("should return 7.12 for floating point number as a parameter", () => {
  24.             let input = 2.12;
  25.             let result = mathEnforcer.addFive(input);
  26.             assert.closeTo(result, 7.12, 0.01);
  27.         });
  28.  
  29.         it("should return 7 for 2 number as a parameter", () => {
  30.             let input = 2;
  31.             let result = mathEnforcer.addFive(input);
  32.             assert.equal(result, 7);
  33.         });
  34.  
  35.         it("should return -3 for -8 number as a parameter", () => {
  36.             let input = -8;
  37.             let result = mathEnforcer.addFive(input);
  38.             assert.equal(result, -3);
  39.         });
  40.     });
  41.    
  42.     describe("subtractTen", function() {
  43.         it("should return undefined when no parameter is given", () => {
  44.             let result = mathEnforcer.subtractTen();
  45.             assert.isUndefined(result);
  46.         });
  47.        
  48.         it("should return undefined for invalid type of the parameter", () => {
  49.             let input = "test";
  50.             let result = mathEnforcer.subtractTen(input);
  51.             assert.isUndefined(result);
  52.         });
  53.  
  54.         it("should return NaN for invalid type of the parameter", () => {
  55.             let input = NaN;
  56.             let result = mathEnforcer.subtractTen(input);
  57.             assert.isNaN(result);
  58.         });
  59.        
  60.         it("should return 10 for integer number as a parameter", () => {
  61.             let input = 20;
  62.             let result = mathEnforcer.subtractTen(input);
  63.             assert.equal(result, 10);
  64.         });
  65.  
  66.         it("should return -20 for -10 as a parameter", () => {
  67.             let input = -10;
  68.             let result = mathEnforcer.subtractTen(input);
  69.             assert.equal(result, -20);
  70.         });
  71.  
  72.  
  73.         it("should return -10 for 0 number as a parameter", () => {
  74.             let input = 0;
  75.             let result = mathEnforcer.subtractTen(input);
  76.             assert.equal(result, -10);
  77.         });
  78.  
  79.         it("should return 10.1 for floating point number as a parameter", () => {
  80.             let input = 20.1;
  81.             let result = mathEnforcer.subtractTen(input);
  82.             assert.closeTo(result, 10.1, 0.01);
  83.         });
  84.     });
  85.    
  86.     describe("sum", function() {
  87.         it("should return undefined when no parameter is given", () => {
  88.             let result = mathEnforcer.sum();
  89.             assert.isUndefined(result);
  90.         });
  91.  
  92.         it("should return undefined for invalid type of the parameter", () => {
  93.             let input = "test";
  94.             let result = mathEnforcer.sum(2, input);
  95.             assert.isUndefined(result);
  96.         });
  97.        
  98.         it("should return undefined for invalid type of the parameter", () => {
  99.             let input = "test";
  100.             let result = mathEnforcer.sum(input, 2);
  101.             assert.isUndefined(result);
  102.         });
  103.  
  104.         it("should return NaN for invalid type of the parameter", () => {
  105.             let input = NaN;
  106.             let result = mathEnforcer.sum(input, input);
  107.             assert.isNaN(result);
  108.         });
  109.  
  110.         it("should return 10 for 5 as a parameter", () => {
  111.             let input = 5;
  112.             let result = mathEnforcer.sum(input, input);
  113.             assert.equal(result, 10);
  114.         });
  115.  
  116.         it("should return 0 for 0, 0 as a parameter", () => {
  117.             let input = 0;
  118.             let secondInput = 0;
  119.             let result = mathEnforcer.sum(input, secondInput);
  120.             assert.equal(result, 0);
  121.         });
  122.  
  123.         it("should return 0 for 5, -5 as a parameter", () => {
  124.             let input = 5;
  125.             let secondInput = -5;
  126.             let result = mathEnforcer.sum(input, secondInput);
  127.             assert.equal(result, 0);
  128.         });
  129.  
  130.         it("should return -10 for -5, -5 as a parameter", () => {
  131.             let input = -5;
  132.             let secondInput = -5;
  133.             let result = mathEnforcer.sum(input, secondInput);
  134.             assert.equal(result, -10);
  135.         });
  136.  
  137.         it("should return 5.5 for 2.75 as a parameter", () => {
  138.             let input = 2.75;
  139.             let result = mathEnforcer.sum(input, input);
  140.             assert.closeTo(result, 5.5, 0.01);
  141.         });
  142.     });
  143. });
Advertisement
Add Comment
Please, Sign In to add comment