Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. describe("testing class Warehouse", function () {
  2.  
  3. let ware;
  4. beforeEach(function () {
  5. ware = new Warehouse(10);
  6. });
  7.  
  8. describe("testing the capacity getter and setter", function () {
  9.  
  10. it("testing capacity setter with non-number and with negative number", function () {
  11. let expected = () => {
  12. ware.capacity = '0';
  13. }
  14. expect(expected).to.throw('Invalid given warehouse space');
  15. });
  16. });
  17. describe("testing if all the methods exists", function () {
  18.  
  19. it("testing addProduct method with bigger number than capacity", function () {
  20. let expected = () => {
  21. ware.addProduct('Food', 'banana', 12);
  22. }
  23. expect(expected).to.throw('There is not enough space or the warehouse is already full');
  24. });
  25.  
  26. it("testing revision in empty warehouse", function () {
  27. let expected = ware.revision();
  28. expect(expected).to.be.equal('The warehouse is empty');
  29. });
  30.  
  31. it("testing scrapeAProduct method with non-existing product", function () {
  32. let expected = () => {
  33. ware.scrapeAProduct('orange', 2);
  34. }
  35. expect(expected).to.throw('orange do not exists');
  36. });
  37.  
  38. it("orderProducts(type) functionality", function () {
  39. let ware = new Warehouse(3);
  40. ware.addProduct("Food", "a", 1);
  41. ware.addProduct("Food", "b", 2);
  42. ware.orderProducts("Food");
  43. let expected = Object.entries(ware.availableProducts["Food"])[0][1];
  44. expect(expected).to.equal(2);
  45. });
  46. });
  47. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement