Advertisement
ErolKZ

Untitled

Feb 16th, 2022
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.49 KB | None | 0 0
  1.  
  2. let expect = require('chai').expect;
  3.  
  4. let mathEnforcer = require('./mathEnforcer');
  5.  
  6.  
  7.  
  8. describe('Mathematical operations', () => {
  9.  
  10. describe('addFive', () => {
  11.  
  12. it('Should return undefined - addfive', () => {
  13.  
  14. let returnValue = mathEnforcer.addFive('dassd');
  15.  
  16. expect(returnValue).to.be.undefined;
  17.  
  18. });
  19.  
  20.  
  21. it('Should add 5 - addfive', () => {
  22.  
  23. let returnValue = mathEnforcer.addFive(15);
  24.  
  25. expect(returnValue).to.be.closeTo(20, 0.01);
  26.  
  27. });
  28.  
  29.  
  30. it('Should add 5 - addfive2', () => {
  31.  
  32. let returnValue = mathEnforcer.addFive(-15);
  33.  
  34. expect(returnValue).to.be.closeTo(-10, 0.01);
  35.  
  36. });
  37.  
  38.  
  39. it('Should add 5 - addfive3', () => {
  40.  
  41. let returnValue = mathEnforcer.addFive(15.009);
  42.  
  43. expect(returnValue).to.be.closeTo(20, 0.01);
  44.  
  45. });
  46.  
  47.  
  48. });
  49.  
  50.  
  51. describe('subtractTen', () => {
  52.  
  53.  
  54. it('Should return undefined - subtractTen', () => {
  55.  
  56. let returnValue = mathEnforcer.subtractTen('dassd');
  57.  
  58. expect(returnValue).to.be.undefined;
  59.  
  60. });
  61.  
  62.  
  63. it('Should subtract ten - subtractTen', () => {
  64.  
  65. let returnValue = mathEnforcer.subtractTen(15);
  66.  
  67. expect(returnValue).to.be.closeTo(5, 0.01);
  68.  
  69. });
  70.  
  71.  
  72. it('Should subtract ten - subtractTen2', () => {
  73.  
  74. let returnValue = mathEnforcer.subtractTen(-15);
  75.  
  76. expect(returnValue).to.be.closeTo(-25, 0.01);
  77.  
  78. });
  79.  
  80.  
  81. it('Should subtract ten - subtractTen3', () => {
  82.  
  83. let returnValue = mathEnforcer.subtractTen(15.009);
  84.  
  85. expect(returnValue).to.be.closeTo(5, 0.01);
  86.  
  87. });
  88.  
  89. });
  90.  
  91.  
  92.  
  93. describe('sum', () => {
  94.  
  95. it('Should return undefined - sum', () => {
  96.  
  97. let returnValue = mathEnforcer.sum('das', 22);
  98.  
  99. expect(returnValue).to.be.undefined;
  100.  
  101. });
  102.  
  103.  
  104. it('Should return undefined2 - sum', () => {
  105.  
  106. let returnValue = mathEnforcer.sum(22, 'das');
  107.  
  108. expect(returnValue).to.be.undefined;
  109.  
  110. });
  111.  
  112.  
  113. it('Should return a sum - sum', () => {
  114.  
  115. let returnValue = mathEnforcer.sum(22, 12);
  116.  
  117. expect(returnValue).to.be.closeTo(34, 0.01);
  118.  
  119. });
  120.  
  121.  
  122. it('Should return a sum2 - sum2', () => {
  123.  
  124. let returnValue = mathEnforcer.sum(-15, 12);
  125.  
  126. expect(returnValue).to.be.closeTo(-3, 0.01);
  127.  
  128. });
  129.  
  130.  
  131. it('Should return a sum3 - sum3', () => {
  132.  
  133. let returnValue = mathEnforcer.sum(15, -12);
  134.  
  135. expect(returnValue).to.be.closeTo(3, 0.01);
  136.  
  137. });
  138.  
  139.  
  140. it('Should return a sum4 - sum4', () => {
  141.  
  142. let returnValue = mathEnforcer.sum(-15, -12);
  143.  
  144. expect(returnValue).to.be.closeTo(-27, 0.01);
  145.  
  146. });
  147.  
  148.  
  149. it('Should return undefined3 - sum', () => {
  150.  
  151. let returnValue = mathEnforcer.sum('sasd', 'das');
  152.  
  153. expect(returnValue).to.be.undefined;
  154.  
  155. });
  156.  
  157.  
  158. it('Should return a sum5 - sum5', () => {
  159.  
  160. let returnValue = mathEnforcer.sum(15.005, 2.003);
  161.  
  162. expect(returnValue).to.be.closeTo(17, 0.01);
  163.  
  164. });
  165.  
  166.  
  167. it('Should return a sum6 - sum6', () => {
  168.  
  169. let returnValue = mathEnforcer.sum(-15.005, -2.003);
  170.  
  171. expect(returnValue).to.be.closeTo(-17, 0.01);
  172.  
  173. });
  174.  
  175. });
  176.  
  177.  
  178. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement