Advertisement
ErolKZ

Untitled

Feb 21st, 2022
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. describe("Testing the object library", function () {
  2.  
  3. describe("First method tests", function () {
  4.  
  5. it("Should have an input like this: (string, number)", function () {
  6.  
  7. expect(() => library.calcPriceOfBook(123, 1978)).to.throw("Invalid input");
  8.  
  9. expect(() => library.calcPriceOfBook('dass', 'das')).to.throw("Invalid input");
  10.  
  11. expect(() => library.calcPriceOfBook(123, 'das')).to.throw("Invalid input");
  12.  
  13. expect(() => library.calcPriceOfBook('asda', 1988.12)).to.throw("Invalid input");
  14.  
  15. });
  16.  
  17.  
  18. it('Should calculate the price depending on the year', () => {
  19.  
  20. let returnValue = library.calcPriceOfBook('War and Peace', 1990);
  21.  
  22. let returnValue2 = library.calcPriceOfBook('War and Peace', 1970);
  23.  
  24. expect(returnValue).to.equal('Price of War and Peace is 20.00');
  25.  
  26. expect(returnValue2).to.equal('Price of War and Peace is 10.00');
  27.  
  28. });
  29.  
  30. });
  31.  
  32.  
  33. describe('Second method', () => {
  34.  
  35. it('Should include all books in library', () => {
  36.  
  37.  
  38.  
  39. });
  40.  
  41.  
  42. it('Should return proper strings', () => {
  43.  
  44. let returnValue = library.findBook(['some', 'troy'], 'some');
  45.  
  46. let returnValue2 = library.findBook(['some', 'troy'], 'dasda');
  47.  
  48. expect(returnValue).to.equal('We found the book you want.');
  49.  
  50. expect(returnValue2).to.equal('The book you are looking for is not here!');
  51.  
  52. });
  53.  
  54.  
  55. it('Should check the length of the array', () => {
  56.  
  57. expect(() => library.findBook([], 'some')).to.throw("No books currently available");
  58.  
  59. });
  60.  
  61. });
  62.  
  63.  
  64. describe('Third method', () => {
  65.  
  66. it('Should have a positive integer as a parameter', () => {
  67.  
  68. expect(() => library.arrangeTheBooks(-12)).to.throw("Invalid input");
  69.  
  70. expect(() => library.arrangeTheBooks(1.54)).to.throw("Invalid input");
  71.  
  72. });
  73.  
  74.  
  75. it('Should check the space for the books', () => {
  76.  
  77. expect(library.arrangeTheBooks(40)).to.equal('Great job, the books are arranged.');
  78.  
  79. expect(library.arrangeTheBooks(41)).to.equal('Insufficient space, more shelves need to be purchased.');
  80.  
  81. });
  82.  
  83. });
  84.  
  85.  
  86. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement