Advertisement
dimoBs

Untitled

Dec 7th, 2021
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1. const { assert } = require('chai');
  2. const { expect } = require('chai');
  3. const library = require('./template');
  4.  
  5. describe("Test", function () {
  6. it("Test1", () => {
  7. assert.throws(() => library({}));
  8. assert.throws(() => library.calcPriceOfBook({}));
  9. assert.throws(() => library.calcPriceOfBook({}), 'Invalid input');
  10.  
  11. assert.equal(library.calcPriceOfBook('Pesho', 2000), 'Price of Pesho is 20.00');
  12. assert.equal(library.calcPriceOfBook('', 2000), 'Price of is 20.00');
  13. assert.throws(() => library.calcPriceOfBook(123, 2000), 'Invalid input');
  14. assert.throws(() => library.calcPriceOfBook(null, 2000), 'Invalid input');
  15. assert.equal(library.calcPriceOfBook('Pesho', 1000), 'Price of Pesho is 10.00');
  16. assert.equal(library.calcPriceOfBook('Pesho', 1000), 'Price of Pesho is 10.00');
  17. assert.equal(library.calcPriceOfBook('Pesho', -1000), 'Price of Pesho is 10.00');
  18. });
  19.  
  20. it("Test2", function () {
  21. assert.equal(library.findBook(['book1', 'book2'], 'book2') ,'We found the book you want.');
  22. assert.equal(library.findBook(['book1'], 'book1') ,'We found the book you want.');
  23. assert.throws(() => library.findBook([], 'book1'), 'No books currently available');
  24. assert.equal(library.findBook(['book1', 'book2'], 'book3') ,'The book you are looking for is not here!');
  25. });
  26.  
  27. it("Test3", function () {
  28. assert.throws(() => library.arrangeTheBooks(5.5), 'Invalid input');
  29. assert.throws(() => library.arrangeTheBooks(-5), 'Invalid input');
  30. assert.throws(() => library.arrangeTheBooks(''), 'Invalid input');
  31. assert.equal(library.arrangeTheBooks(5) ,'Great job, the books are arranged.');
  32. assert.equal(library.arrangeTheBooks(40) ,'Great job, the books are arranged.');
  33. assert.equal(library.arrangeTheBooks(41) ,'Insufficient space, more shelves need to be purchased.');
  34. assert.equal(library.arrangeTheBooks(5555), 'Insufficient space, more shelves need to be purchased.');
  35.  
  36.  
  37.  
  38.  
  39. });
  40. });
  41.  
  42. //assert.throws(() => numberOperations.numberChecker('str'), 'The input is not a number!');
  43. //assert.equal(dealership.newCarCost('Audi A4 B8', 100000), 85000);
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement