Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* eslint-disable no-undef */
  2. const {
  3.   newString,
  4.   newNum,
  5.   newBool,
  6.   newSubtract,
  7.   newMultiply,
  8.   newModulo,
  9.   returnString,
  10.   areSameLength,
  11.   areEqual,
  12.   lessThanNinety,
  13.   greaterThanFifty,
  14.   add,
  15.   subtract,
  16.   divide,
  17.   multiply,
  18.   getRemainder,
  19.   isEven,
  20.   isOdd,
  21.   square,
  22.   cube,
  23.   raiseToPower,
  24.   roundNumber,
  25.   roundUp,
  26.   addExclamationPoint,
  27.   combineNames,
  28.   getGreeting,
  29.   getRectangleArea,
  30.   getTriangleArea,
  31. } = require('../homework');
  32.  
  33. describe('newString', function() {
  34.   it('should be a string', function() {
  35.     expect(typeof newString).toBe('string');
  36.   });
  37. });
  38.  
  39. describe('newNum', function() {
  40.   it('should be a number', function() {
  41.     expect(typeof newNum).toBe('number');
  42.   });
  43. });
  44.  
  45. describe('newBool', function() {
  46.   it('should be a boolean', function() {
  47.     expect(typeof newBool).toBe('boolean');
  48.   });
  49. });
  50.  
  51. describe('newSubtract', function() {
  52.   it('should be a boolean', function() {
  53.     expect(newSubtract).toBe(true);
  54.   });
  55. });
  56.  
  57. describe('newMultiply', function() {
  58.   it('should be a boolean', function() {
  59.     expect(newMultiply).toBe(true);
  60.   });
  61. });
  62.  
  63. describe('newModulo', function() {
  64.   it('should be a boolean', function() {
  65.     expect(newModulo).toBe(true);
  66.   });
  67. });
  68.  
  69. describe('returnString(str)', function() {
  70.   it('should return the string provided', function() {
  71.     let string = 'lambdaSchool';
  72.     expect(returnString(string)).toBe(string);
  73.   });
  74. });
  75.  
  76. describe('add(x, y)', function() {
  77.   it('should return the sum of the two arguments', function() {
  78.     expect(add(5, 5)).toBe(10);
  79.     expect(add(-1, 5)).toBe(4);
  80.   });
  81. });
  82.  
  83. describe('subtract(x, y)', function() {
  84.   it('should return the difference of the two arguments', function() {
  85.     expect(subtract(5, 5)).toBe(0);
  86.     expect(subtract(-1, 5)).toBe(-6);
  87.     expect(subtract(5, -5)).toBe(10);
  88.     expect(subtract(0, 0)).toBe(0);
  89.   });
  90. });
  91.  
  92. describe('divide(x, y)', function() {
  93.   it('should return the quotient of the two arguments', function() {
  94.     expect(divide(5, 5)).toBe(1);
  95.     expect(divide(10, 5)).toBe(2);
  96.     expect(divide(11, 2)).toBe(5.5);
  97.   });
  98. });
  99.  
  100. describe('multiply(x, y)', function() {
  101.   it('should return the product of the two arguments', function() {
  102.     expect(multiply(5, 5)).toBe(25);
  103.     expect(multiply(10, -5)).toBe(-50);
  104.     expect(multiply(11, 0)).toBe(0);
  105.   });
  106. });
  107.  
  108.  
  109. describe('areEqual(x, y)', function() {
  110.   it('should return true if the arguments are equal', function() {
  111.     expect(areEqual(15, 15)).toBe(true);
  112.     expect(areEqual(90, 50)).toBe(false);
  113.     expect(areEqual('test', 'test')).toBe(true);
  114.   });
  115. });
  116.  
  117. describe('areSameLength(str1, str2)', function() {
  118.   it('should return true if the arguments have the same length', function() {
  119.     expect(areSameLength('hi', 'there')).toBe(false);
  120.     expect(areSameLength('javascript', 'bumfuzzled')).toBe(true);
  121.   });
  122. });
  123.  
  124. describe('lessThanNinety(num)', function() {
  125.   it('should return true if the argument is less than ninety', function() {
  126.     expect(lessThanNinety(15)).toBe(true);
  127.     expect(lessThanNinety(90)).toBe(false);
  128.     expect(lessThanNinety(100)).toBe(false);
  129.   });
  130. });
  131.  
  132. describe('greaterThanFifty(num)', function() {
  133.   it('should return true if the argument is greater than fifty', function() {
  134.     expect(greaterThanFifty(15)).toBe(false);
  135.     expect(greaterThanFifty(50)).toBe(false);
  136.     expect(greaterThanFifty(60)).toBe(true);
  137.   });
  138. });
  139.  
  140. describe('getRemainder(x, y)', function() {
  141.   it('should return the division remainder of the two arguments', function() {
  142.     expect(getRemainder(5, 5)).toBe(0);
  143.     expect(getRemainder(10, 5)).toBe(0);
  144.     expect(getRemainder(11, 2)).toBe(1);
  145.   });
  146. });
  147.  
  148. describe('isEven(num)', function() {
  149.   it('should return the bool true if the argument is even, false otherwise', function() {
  150.     expect(isEven(6)).toBe(true);
  151.     expect(isEven(7)).toBe(false);
  152.     expect(isEven(0)).toBe(true);
  153.   });
  154. });
  155.  
  156. describe('isOdd(num)', function() {
  157.   it('should return the bool true if the argument is odd, false otherwise', function() {
  158.     expect(isOdd(6)).toBe(false);
  159.     expect(isOdd(7)).toBe(true);
  160.     expect(isOdd(0)).toBe(false);
  161.   });
  162. });
  163.  
  164. describe('square(num)', function() {
  165.   it('should return the argument after squaring it', function() {
  166.     expect(square(6)).toBe(36);
  167.     expect(square(7)).toBe(49);
  168.     expect(square(0)).toBe(0);
  169.     expect(square(-5)).toBe(25);
  170.   });
  171. });
  172.  
  173. describe('cube(num)', function() {
  174.   it('should return the argument after cubing it', function() {
  175.     expect(cube(3)).toBe(27);
  176.     expect(cube(0)).toBe(0);
  177.     expect(cube(-5)).toBe(-125);
  178.   });
  179. });
  180.  
  181. describe('raiseToPower(num, exponent)', function() {
  182.   it('should return the argument after raising it to the exponent\'s power', function() {
  183.     expect(raiseToPower(2, 2)).toBe(4);
  184.     expect(raiseToPower(2, 3)).toBe(8);
  185.     expect(raiseToPower(0, 5)).toBe(0);
  186.     expect(raiseToPower(10, 1)).toBe(10);
  187.   });
  188. });
  189.  
  190. describe('roundNumber(num)', function() {
  191.   it('should return the argument after rounding it', function() {
  192.     expect(roundNumber(1.5)).toBe(2);
  193.     expect(roundNumber(2)).toBe(2);
  194.     expect(roundNumber(0.1)).toBe(0);
  195.   });
  196. });
  197.  
  198. describe('roundUp(num)', function() {
  199.   it('should return the argument after rounding it up', function() {
  200.     expect(roundUp(1.5)).toBe(2);
  201.     expect(roundUp(2)).toBe(2);
  202.     expect(roundUp(0.1)).toBe(1);
  203.   });
  204. });
  205.  
  206. describe('addExclamationPoint(str)', function() {
  207.   it('should add an exclamation point to the end of the string', function() {
  208.     expect(addExclamationPoint('hello world')).toBe('hello world!');
  209.     expect(addExclamationPoint('LambdaSchool')).toBe('LambdaSchool!');
  210.   });
  211. });
  212.  
  213. describe('combineNames(firstName, lastName)', function() {
  214.   it('should return the two strings combined into one with a space separating them', function() {
  215.     expect(combineNames('hello', 'world')).toBe('hello world');
  216.     expect(combineNames('Lambda', 'School')).toBe('Lambda School');
  217.   });
  218. });
  219.  
  220. describe('getGreeting(name)', function() {
  221.   it('should return the string \'Hello {name}!\'', function() {
  222.     expect(getGreeting('Ben')).toBe('Hello Ben!');
  223.     expect(getGreeting('LambdaSchool')).toBe('Hello LambdaSchool!');
  224.   });
  225. });
  226.  
  227. describe('getRectangleArea(length, width)', function() {
  228.   it('should return the correct area', function() {
  229.     expect(getRectangleArea(2, 2)).toBe(4);
  230.     expect(getRectangleArea(3, 6)).toBe(18);
  231.     expect(getRectangleArea(0, 2)).toBe(0);
  232.   });
  233. });
  234.  
  235. describe('getTriangleArea(base, height)', function() {
  236.   it('should return the correct area', function() {
  237.     expect(getTriangleArea(2, 2)).toBe(2);
  238.     expect(getTriangleArea(0, 2)).toBe(0);
  239.   });
  240. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement