chore(curriculum): remove logs from tests for inventory management lab (#59187)

This commit is contained in:
Ilenia
2025-03-09 07:26:41 +01:00
committed by GitHub
parent e23f1e2bc5
commit e0767a05e4
@@ -82,6 +82,8 @@ assert.isFunction(addProduct)
`addProduct({name: "FLOUR", quantity: 5})` should add `5` to `quantity` value of the object having `name` equal to `"flour"` in the `inventory` array.
```js
const temp = console.log;
console.log = () => {};
inventory.length = 0;
inventory.push({name: 'flour', quantity: 15});
inventory.push({name: 'rice', quantity: 10});
@@ -90,6 +92,7 @@ addProduct({name: 'Flour', quantity: 5});
addProduct({name: 'RICE', quantity: 5});
addProduct({name: 'SuGar', quantity: 5});
const expected = JSON.stringify([{name: 'flour', quantity: 20}, {name: 'rice', quantity: 15}, {name: 'sugar', quantity: 10}]);
console.log = temp;
assert.equal(JSON.stringify(inventory), expected)
```
@@ -120,6 +123,8 @@ assert.strictEqual(logArr[2], "sugar quantity updated")
`addProduct({name: "FLOUR", quantity: 5})` should push `{name: "flour", quantity: 5}` to the `inventory` array when no object having `name` equal to `"flour"` is found in the inventory.
```js
const temp = console.log;
console.log = () => {};
inventory.length = 0;
inventory.push({name: 'flour', quantity: 15});
inventory.push({name: 'rice', quantity: 10});
@@ -127,6 +132,7 @@ inventory.push({name: 'sugar', quantity: 5});
addProduct({name: 'SALT', quantity: 8});
addProduct({name: 'Spam', quantity: 1});
const expected = JSON.stringify([{name: 'flour', quantity: 15}, {name: 'rice', quantity: 10}, {name: 'sugar', quantity: 5}, {name: 'salt', quantity: 8}, {name: 'spam', quantity: 1}]);
console.log = temp;
assert.equal(JSON.stringify(inventory), expected);
```
@@ -183,6 +189,8 @@ assert.equal(logArr[1], "spam not found");
`removeProduct("FLOUR", 5)` should subtract `5` from the `quantity` value of the object having `name` equal to `"flour"` inside the `inventory` array.
```js
const temp = console.log;
console.log = () => {};
inventory.length = 0;
inventory.push({name: 'flour', quantity: 15});
inventory.push({name: 'rice', quantity: 10});
@@ -191,6 +199,7 @@ removeProduct("flour", 10);
removeProduct("RICE", 5);
removeProduct("Sugar", 2);
const expected = JSON.stringify([{name: 'flour', quantity: 5}, {name: 'rice', quantity: 5}, {name: 'sugar', quantity: 3}]);
console.log = temp;
assert.equal(JSON.stringify(inventory), expected)
```
@@ -221,6 +230,8 @@ assert.equal(logArr[2], "Remaining sugar pieces: 3");
If the `quantity` after the subtraction is zero, `removeProduct` should remove the product object from the inventory.
```js
const temp = console.log;
console.log = () => {};
inventory.length = 0;
inventory.push({name: 'flour', quantity: 15});
inventory.push({name: 'rice', quantity: 10});
@@ -228,6 +239,7 @@ inventory.push({name: 'sugar', quantity: 5});
removeProduct("flour", 15);
removeProduct("rice", 10);
const expected = JSON.stringify([{name: 'sugar', quantity: 5}]);
console.log = temp;
assert.equal(JSON.stringify(inventory), expected)
```