Passed
Push — master ( 2e2f15...a46986 )
by Miles MJ
01:52
created

spec/test/test.js   A

Complexity

Total Complexity 9
Complexity/F 1

Size

Lines of Code 44
Function Count 9

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 9
eloc 25
mnd 0
bc 0
fnc 9
dl 0
loc 44
rs 10
bpm 0
cpm 1
noi 0
c 0
b 0
f 0
1
var percent = 0;
2
describe("The arb.js test suite", function(){
3
  var arb = require("../../dist/arb.js");
4
  
5
  var mulTestPair = ["1234567890", "9876543210"];
6
  var mulTestAnswer = "12193263111263526900.0";
7
  var addTestPair = ["1234567890", "9876543210"];
8
  var addTestAnswer = "11111111100.0";
9
  var subTestPair = ["1234567890", "9876543210"];
10
  var subTestAnswer = "-8641975320.0";
11
  var divTestPair = ["1234567890", "9876543210"];
12
  var divTestAnswer = "0.1249999988609375000";
13
  
14
  
15
  describe("Addition tests", function(){
16
    it("should work properly on addition", function(){
17
      //console.info("Running Addition Test...");
18
      expect(arb(addTestPair[0]).add(addTestPair[1]).value).toBe(addTestAnswer);
19
    });
20
  });
21
  
22
  describe("Subtraction tests", function(){
23
    //console.info("Running Subtraction Test...");
24
    it("should work properly on subtraction", function(){
25
      expect(arb(subTestPair[0]).sub(subTestPair[1]).value).toBe(subTestAnswer);
26
    });
27
  });
28
  
29
  describe("Multiplication tests", function(){
30
    //console.info("Running multiplication Test...");
31
    it("should work properly on multiplication", function(){
32
      expect(arb(mulTestPair[0]).mul(mulTestPair[1]).value).toBe(mulTestAnswer);
33
    });
34
  });
35
  
36
  describe("Division tests", function(){
37
    //console.info("Running Division Test...");
38
    it("should work properly on division", function(){
39
      expect(arb(divTestPair[0]).div(divTestPair[1]).value.substr(0, 21)).toBe(divTestAnswer);
40
      expect(arb("1").div("0.0001").value).toBe("10000.0");
41
      expect(arb("1").div("89").value.substr(0, 22)).toBe("0.01123595505617977528");
42
    });
43
  });
44
});