Advertisement
Guest User

warehouse

a guest
Oct 17th, 2019
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. describe("Warehouse functionality", function() {
  2. it("constructor gets a num = 0 should throw error", function() {
  3. assert.throws(() => new Warehouse(0), "Invalid given warehouse space");
  4. });
  5. it("constructor gets a num < 0 should throw error", function() {
  6. assert.throws(() => new Warehouse(-1), "Invalid given warehouse space");
  7. });
  8. it("constructor gets a non-num should throw error", function() {
  9. assert.throws(() => new Warehouse("1"), "Invalid given warehouse space");
  10. });
  11. it("addProduct(type, product, quantity) error test", function() {
  12. let actual = new Warehouse(1);
  13. assert.throws(
  14. () => actual.addProduct("Food", "bar", 11),
  15. "There is not enough space or the warehouse is already full"
  16. );
  17. });
  18. it("addProduct(type, product, quantity) returns an object", function() {
  19. let actual = new Warehouse(1);
  20. assert.typeOf(actual.addProduct("Food", "neshto", 1), "object");
  21. });
  22. it("orderProducts(type) functionality", function() {
  23. let actual = new Warehouse(3);
  24. actual.addProduct("Food", "a", 1);
  25. actual.addProduct("Food", "b", 2);
  26. actual.orderProducts("Food");
  27. let check = Object.entries(actual.availableProducts["Food"]);
  28. assert.equal(check[0][1], 2);
  29. });
  30. it("revision() functionality with empty warehouse", function() {
  31. let actual = new Warehouse(3);
  32. assert.equal(actual.revision(), "The warehouse is empty");
  33. });
  34. it("scrapeAProduct(product, quantity) test", function() {
  35. let actual = new Warehouse(3);
  36. actual.addProduct("Food", "a", 1);
  37. assert.throws(() => actual.scrapeAProduct("b", 1), "b do not exists");
  38. });
  39. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement