Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- describe("Warehouse functionality", function() {
- it("constructor gets a num = 0 should throw error", function() {
- assert.throws(() => new Warehouse(0), "Invalid given warehouse space");
- });
- it("constructor gets a num < 0 should throw error", function() {
- assert.throws(() => new Warehouse(-1), "Invalid given warehouse space");
- });
- it("constructor gets a non-num should throw error", function() {
- assert.throws(() => new Warehouse("1"), "Invalid given warehouse space");
- });
- it("addProduct(type, product, quantity) error test", function() {
- let actual = new Warehouse(1);
- assert.throws(
- () => actual.addProduct("Food", "bar", 11),
- "There is not enough space or the warehouse is already full"
- );
- });
- it("addProduct(type, product, quantity) returns an object", function() {
- let actual = new Warehouse(1);
- assert.typeOf(actual.addProduct("Food", "neshto", 1), "object");
- });
- it("orderProducts(type) functionality", function() {
- let actual = new Warehouse(3);
- actual.addProduct("Food", "a", 1);
- actual.addProduct("Food", "b", 2);
- actual.orderProducts("Food");
- let check = Object.entries(actual.availableProducts["Food"]);
- assert.equal(check[0][1], 2);
- });
- it("revision() functionality with empty warehouse", function() {
- let actual = new Warehouse(3);
- assert.equal(actual.revision(), "The warehouse is empty");
- });
- it("scrapeAProduct(product, quantity) test", function() {
- let actual = new Warehouse(3);
- actual.addProduct("Food", "a", 1);
- assert.throws(() => actual.scrapeAProduct("b", 1), "b do not exists");
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement