Advertisement
Hectorjyoung

https://server5.eibok.com/itunes/ugix_reddit.php?id=us&cat=38

Feb 4th, 2023 (edited)
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.58 KB | None | 0 0
  1. https://server5.eibok.com/itunes/ugix_reddit.php?id=us&cat=38
  2. describe('Tests library', function () {
  3. describe('calcPriceOfBook ', function () {
  4. it('assert with valid params', function () {
  5. assert.equal(
  6. library.calcPriceOfBook('Some book', 1980),
  7. 'Price of Some book is 10.00'
  8. );
  9. assert.equal(
  10. library.calcPriceOfBook('Some book', 1979),
  11. 'Price of Some book is 10.00'
  12. );
  13. assert.equal(
  14. library.calcPriceOfBook('Some book', 1981),
  15. 'Price of Some book is 20.00'
  16. );
  17. assert.equal(
  18. library.calcPriceOfBook('Some book', 0),
  19. 'Price of Some book is 10.00'
  20. );
  21. });
  22.  
  23. it('assert with invalid params, expect to throw', function () {
  24. assert.Throw(
  25. () => library.calcPriceOfBook('Some book'),
  26. 'Invalid input'
  27. );
  28. assert.Throw(
  29. () => library.calcPriceOfBook('Some book', '1987'),
  30. 'Invalid input'
  31. );
  32. assert.Throw(
  33. () => library.calcPriceOfBook('Some book', [1987]),
  34. 'Invalid input'
  35. );
  36. assert.Throw(
  37. () => library.calcPriceOfBook('Some book', 1987.6),
  38. 'Invalid input'
  39. );
  40. assert.Throw(
  41. () => library.calcPriceOfBook(['Some book'], 0),
  42. 'Invalid input'
  43. );
  44. assert.Throw(() => library.calcPriceOfBook(0, 0), 'Invalid input');
  45. assert.Throw(() => library.calcPriceOfBook(1876), 'Invalid input');
  46. });
  47. });
  48.  
  49. describe('findBook', function () {
  50. it('assert with valid param', function () {
  51. assert.equal(
  52. library.findBook(
  53. ['Troy', 'Life Style', 'Torronto'],
  54. 'Some book'
  55. ),
  56. 'The book you are looking for is not here!'
  57. );
  58. assert.equal(
  59. library.findBook(['Troy', 'Life Style', 'Torronto'], 'Troy'),
  60. 'We found the book you want.'
  61. );
  62. });
  63. it('assert with valid param, [] - throw', function () {
  64. assert.Throw(
  65. () => library.findBook([], 'Some book'),
  66. 'No books currently available'
  67. );
  68. });
  69. });
  70. describe('arrangeTheBooks', function () {
  71. it('assert with valid params', function () {
  72. assert.equal(
  73. library.arrangeTheBooks(6),
  74. 'Great job, the books are arranged.'
  75. );
  76. assert.equal(
  77. library.arrangeTheBooks(40),
  78. 'Great job, the books are arranged.'
  79. );
  80. assert.equal(
  81. library.arrangeTheBooks(41),
  82. 'Insufficient space, more shelves need to be purchased.'
  83. );
  84. assert.equal(
  85. library.arrangeTheBooks(0),
  86. 'Great job, the books are arranged.'
  87. );
  88. });
  89. it('assert with invalid params', function () {
  90. assert.throw(() => library.arrangeTheBooks(-1), 'Invalid input');
  91.  
  92. assert.throw(() => library.arrangeTheBooks(), 'Invalid input');
  93. assert.throw(() => library.arrangeTheBooks(8.7), 'Invalid input');
  94.  
  95. assert.throw(() => library.arrangeTheBooks('8'), 'Invalid input');
  96. });
  97. });
  98. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement