From 05c351a10bb5c048efeaf642d02ae5312d04ff64 Mon Sep 17 00:00:00 2001 From: Tugbanur Date: Mon, 15 Jul 2024 00:04:53 +0200 Subject: [PATCH] tested --- .../assignment/ex1-doubleEvenNumbers.test.js | 6 +- .../Week3/assignment/ex2-mondaysWorth.test.js | 8 +- .../Week3/assignment/ex3-lemonAllergy.test.js | 19 +- .../ex4-observable/ex4-observable.js | 5 +- .../Week3/assignment/ex5-wallet/index.js | 10 +- 1-JavaScript/Week3/assignment/package.json | 4 +- 1-JavaScript/Week3/package.json | 11 - .../ex1-doubleEvenNumbers.test.pass.txt | 1 + .../ex1-doubleEvenNumbers.test.todo.txt | 1 - .../ex2-mondaysWorth.test.pass.txt | 1 + .../ex2-mondaysWorth.test.todo.txt | 1 - .../ex3-lemonAllergy.test.pass.txt | 1 + .../ex3-lemonAllergy.test.todo.txt | 1 - .../test-reports/ex4-observable.pass.txt | 1 + .../test-reports/ex4-observable.todo.txt | 1 - .../Week3/test-reports/ex5-wallet.pass.txt | 1 + .../Week3/test-reports/ex5-wallet.todo.txt | 1 - test-runner.log | 480 ++++++++++++++++++ 18 files changed, 515 insertions(+), 38 deletions(-) delete mode 100644 1-JavaScript/Week3/package.json create mode 100644 1-JavaScript/Week3/test-reports/ex1-doubleEvenNumbers.test.pass.txt delete mode 100644 1-JavaScript/Week3/test-reports/ex1-doubleEvenNumbers.test.todo.txt create mode 100644 1-JavaScript/Week3/test-reports/ex2-mondaysWorth.test.pass.txt delete mode 100644 1-JavaScript/Week3/test-reports/ex2-mondaysWorth.test.todo.txt create mode 100644 1-JavaScript/Week3/test-reports/ex3-lemonAllergy.test.pass.txt delete mode 100644 1-JavaScript/Week3/test-reports/ex3-lemonAllergy.test.todo.txt create mode 100644 1-JavaScript/Week3/test-reports/ex4-observable.pass.txt delete mode 100644 1-JavaScript/Week3/test-reports/ex4-observable.todo.txt create mode 100644 1-JavaScript/Week3/test-reports/ex5-wallet.pass.txt delete mode 100644 1-JavaScript/Week3/test-reports/ex5-wallet.todo.txt diff --git a/1-JavaScript/Week3/assignment/ex1-doubleEvenNumbers.test.js b/1-JavaScript/Week3/assignment/ex1-doubleEvenNumbers.test.js index 86418f0..b985870 100644 --- a/1-JavaScript/Week3/assignment/ex1-doubleEvenNumbers.test.js +++ b/1-JavaScript/Week3/assignment/ex1-doubleEvenNumbers.test.js @@ -11,11 +11,11 @@ Let's rewrite it (or _refactor_ it, as experienced developers would call it): ------------------------------------------------------------------------------*/ // ! Function to be tested function doubleEvenNumbers(numbers) { - return numbers + return numbers .filter(number => number % 2 === 0) - .map(number => number * 2) + .map(number => number * 2); -} + } // // ! Unit test (using Jest) test('doubleEvenNumbers should take the even numbers and double them', () => { diff --git a/1-JavaScript/Week3/assignment/ex2-mondaysWorth.test.js b/1-JavaScript/Week3/assignment/ex2-mondaysWorth.test.js index 24a125e..44b0cf7 100644 --- a/1-JavaScript/Week3/assignment/ex2-mondaysWorth.test.js +++ b/1-JavaScript/Week3/assignment/ex2-mondaysWorth.test.js @@ -31,8 +31,12 @@ const mondayTasks = [ const hourlyRate = 25; -function computeEarnings(/* TODO parameter(s) go here */) { - // TODO complete this function +function computeEarnings(tasks, hourlyRate) { + const totalEarnings = tasks + .map(task => (task.duration / 60) * hourlyRate) + .reduce((acc, earnings) => acc + earnings, 0); + + return `€${totalEarnings.toFixed(2)}`; } // ! Unit tests (using Jest) diff --git a/1-JavaScript/Week3/assignment/ex3-lemonAllergy.test.js b/1-JavaScript/Week3/assignment/ex3-lemonAllergy.test.js index 9a3a024..213f7a3 100644 --- a/1-JavaScript/Week3/assignment/ex3-lemonAllergy.test.js +++ b/1-JavaScript/Week3/assignment/ex3-lemonAllergy.test.js @@ -26,26 +26,29 @@ const fruitBasket = [ ]; // ! Function under test -function sanitizeFruitBasket(/* TODO parameter(s) go here */) { - // TODO complete this function +function sanitizeFruitBasket(arr, fruitName) { + const unwantedFruit = arr.filter(fruit => fruit !== fruitName) + return unwantedFruit; + } +console.log(sanitizeFruitBasket(fruitBasket, 'lemon')); // ! Unit tests (using Jest) describe('sanitizeFruitBasket', () => { test('should take two parameters', () => { - // TODO replace next line with your code - expect(false).toBe(true); + expect(sanitizeFruitBasket.length).toBe(2); }); test('should not modify the original `fruitBasket` array', () => { // Save the original contents of the fruit basket const originalFruitBasketContents = [...fruitBasket]; - // TODO replace next line with your code - expect(false).toBe(true); + sanitizeFruitBasket(fruitBasket, 'lemon'); + expect(fruitBasket).toEqual(originalFruitBasketContents); }); test('should return a new array that does not include the unwanted `lemon`', () => { - // TODO replace next line with your code - expect(false).toBe(true); + const result = sanitizeFruitBasket(fruitBasket, 'lemon'); + const expected = ['apple', 'grapefruit', 'banana', 'watermelon']; + expect(result).toEqual(expected); }); }); diff --git a/1-JavaScript/Week3/assignment/ex4-observable/ex4-observable.js b/1-JavaScript/Week3/assignment/ex4-observable/ex4-observable.js index 5af1d0e..0571aa8 100644 --- a/1-JavaScript/Week3/assignment/ex4-observable/ex4-observable.js +++ b/1-JavaScript/Week3/assignment/ex4-observable/ex4-observable.js @@ -17,13 +17,14 @@ function createObservable() { const subscribers = []; return { subscribe: function (subscriber) { - // TODO complete this function + subscribers.push(subscriber); }, notify: function (message) { - // TODO complete this function + subscribers.forEach(subscriber => subscriber(message)); }, }; } + // ! Do not change or remove the code below module.exports = createObservable; diff --git a/1-JavaScript/Week3/assignment/ex5-wallet/index.js b/1-JavaScript/Week3/assignment/ex5-wallet/index.js index 2cacd1b..769fcc2 100644 --- a/1-JavaScript/Week3/assignment/ex5-wallet/index.js +++ b/1-JavaScript/Week3/assignment/ex5-wallet/index.js @@ -77,7 +77,7 @@ const quiz = { b: 'cash, name', c: 'amount, this, wallet' }, - answer: undefined, + answer:'b', }, q2: { question: 'What is in the Call Stack, from top to bottom?', @@ -86,7 +86,7 @@ const quiz = { b: 'anonymous, transferInto', c: 'transferInto, anonymous' }, - answer: undefined, + answer: 'c', }, q3: { question: 'What tooltip appears when hovering over the third debug button?', @@ -95,7 +95,7 @@ const quiz = { b: 'Step out of current function', c: 'Step' }, - answer: undefined, + answer: 'a', }, q4: { question: 'What is displayed in the console?', @@ -104,7 +104,7 @@ const quiz = { b: 'Transferring € 50,00 from Jack to undefined', c: 'Transferring € 50,00 from Jack to Jane' }, - answer: undefined, + answer: 'a', }, q5: { question: 'The owner of the wallet with insufficient funds is:', @@ -113,6 +113,6 @@ const quiz = { b: 'Joe', c: 'Jane' }, - answer: undefined, + answer: 'c', }, }; diff --git a/1-JavaScript/Week3/assignment/package.json b/1-JavaScript/Week3/assignment/package.json index e368782..8ebe706 100644 --- a/1-JavaScript/Week3/assignment/package.json +++ b/1-JavaScript/Week3/assignment/package.json @@ -8,8 +8,8 @@ "keywords": [], "author": "", "license": "ISC", - "description": "", "devDependencies": { "jest": "^29.7.0" - } + }, + "description": "" } diff --git a/1-JavaScript/Week3/package.json b/1-JavaScript/Week3/package.json deleted file mode 100644 index 01f890b..0000000 --- a/1-JavaScript/Week3/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "week3", - "version": "1.0.0", - "description": "assignments", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "", - "license": "ISC" -} diff --git a/1-JavaScript/Week3/test-reports/ex1-doubleEvenNumbers.test.pass.txt b/1-JavaScript/Week3/test-reports/ex1-doubleEvenNumbers.test.pass.txt new file mode 100644 index 0000000..4952ced --- /dev/null +++ b/1-JavaScript/Week3/test-reports/ex1-doubleEvenNumbers.test.pass.txt @@ -0,0 +1 @@ +All tests passed \ No newline at end of file diff --git a/1-JavaScript/Week3/test-reports/ex1-doubleEvenNumbers.test.todo.txt b/1-JavaScript/Week3/test-reports/ex1-doubleEvenNumbers.test.todo.txt deleted file mode 100644 index d8d8689..0000000 --- a/1-JavaScript/Week3/test-reports/ex1-doubleEvenNumbers.test.todo.txt +++ /dev/null @@ -1 +0,0 @@ -This test has not been run. \ No newline at end of file diff --git a/1-JavaScript/Week3/test-reports/ex2-mondaysWorth.test.pass.txt b/1-JavaScript/Week3/test-reports/ex2-mondaysWorth.test.pass.txt new file mode 100644 index 0000000..4952ced --- /dev/null +++ b/1-JavaScript/Week3/test-reports/ex2-mondaysWorth.test.pass.txt @@ -0,0 +1 @@ +All tests passed \ No newline at end of file diff --git a/1-JavaScript/Week3/test-reports/ex2-mondaysWorth.test.todo.txt b/1-JavaScript/Week3/test-reports/ex2-mondaysWorth.test.todo.txt deleted file mode 100644 index d8d8689..0000000 --- a/1-JavaScript/Week3/test-reports/ex2-mondaysWorth.test.todo.txt +++ /dev/null @@ -1 +0,0 @@ -This test has not been run. \ No newline at end of file diff --git a/1-JavaScript/Week3/test-reports/ex3-lemonAllergy.test.pass.txt b/1-JavaScript/Week3/test-reports/ex3-lemonAllergy.test.pass.txt new file mode 100644 index 0000000..4952ced --- /dev/null +++ b/1-JavaScript/Week3/test-reports/ex3-lemonAllergy.test.pass.txt @@ -0,0 +1 @@ +All tests passed \ No newline at end of file diff --git a/1-JavaScript/Week3/test-reports/ex3-lemonAllergy.test.todo.txt b/1-JavaScript/Week3/test-reports/ex3-lemonAllergy.test.todo.txt deleted file mode 100644 index d8d8689..0000000 --- a/1-JavaScript/Week3/test-reports/ex3-lemonAllergy.test.todo.txt +++ /dev/null @@ -1 +0,0 @@ -This test has not been run. \ No newline at end of file diff --git a/1-JavaScript/Week3/test-reports/ex4-observable.pass.txt b/1-JavaScript/Week3/test-reports/ex4-observable.pass.txt new file mode 100644 index 0000000..4952ced --- /dev/null +++ b/1-JavaScript/Week3/test-reports/ex4-observable.pass.txt @@ -0,0 +1 @@ +All tests passed \ No newline at end of file diff --git a/1-JavaScript/Week3/test-reports/ex4-observable.todo.txt b/1-JavaScript/Week3/test-reports/ex4-observable.todo.txt deleted file mode 100644 index d8d8689..0000000 --- a/1-JavaScript/Week3/test-reports/ex4-observable.todo.txt +++ /dev/null @@ -1 +0,0 @@ -This test has not been run. \ No newline at end of file diff --git a/1-JavaScript/Week3/test-reports/ex5-wallet.pass.txt b/1-JavaScript/Week3/test-reports/ex5-wallet.pass.txt new file mode 100644 index 0000000..4952ced --- /dev/null +++ b/1-JavaScript/Week3/test-reports/ex5-wallet.pass.txt @@ -0,0 +1 @@ +All tests passed \ No newline at end of file diff --git a/1-JavaScript/Week3/test-reports/ex5-wallet.todo.txt b/1-JavaScript/Week3/test-reports/ex5-wallet.todo.txt deleted file mode 100644 index d8d8689..0000000 --- a/1-JavaScript/Week3/test-reports/ex5-wallet.todo.txt +++ /dev/null @@ -1 +0,0 @@ -This test has not been run. \ No newline at end of file diff --git a/test-runner.log b/test-runner.log index 9ad2007..8853c96 100644 --- a/test-runner.log +++ b/test-runner.log @@ -376,3 +376,483 @@ Command failed: npx jest ex3-tellFortune.test.js --colors --reporters="/Users/ha 2024-07-11 08:16:34 info: ------------------------------------------- 2024-07-11 08:16:34 warn: A unit test file was not provided. 2024-07-11 08:16:36 info: All steps were completed successfully +2024-07-14 02:20:31 info: ------------------------------------------- +2024-07-14 02:20:31 info: >>> Running Unit Test `ex7-mindPrivacy` <<< +2024-07-14 02:20:31 info: ------------------------------------------- +2024-07-14 02:20:31 warn: A unit test file was not provided. +2024-07-14 02:20:34 info: All steps were completed successfully +2024-07-14 02:21:12 info: ------------------------------------------------------ +2024-07-14 02:21:12 info: >>> Running Unit Test `ex1-doubleEvenNumbers.test` <<< +2024-07-14 02:21:12 info: ------------------------------------------------------ +2024-07-14 02:21:14 info: All unit tests passed. +2024-07-14 02:21:17 info: All steps were completed successfully +2024-07-14 02:22:08 info: ------------------------------------------------------ +2024-07-14 02:22:08 info: >>> Running Unit Test `ex1-doubleEvenNumbers.test` <<< +2024-07-14 02:22:08 info: ------------------------------------------------------ +2024-07-14 02:22:10 info: All unit tests passed. +2024-07-14 02:22:12 info: All steps were completed successfully +2024-07-14 02:22:25 info: ------------------------------------------------------ +2024-07-14 02:22:25 info: >>> Running Unit Test `ex1-doubleEvenNumbers.test` <<< +2024-07-14 02:22:25 info: ------------------------------------------------------ +2024-07-14 02:22:26 info: All unit tests passed. +2024-07-14 02:22:29 info: All steps were completed successfully +2024-07-14 02:22:42 info: ------------------------------------------------- +2024-07-14 02:22:42 info: >>> Running Unit Test `ex2-mondaysWorth.test` <<< +2024-07-14 02:22:42 info: ------------------------------------------------- +2024-07-14 02:22:43 error: *** Unit Test Error Report *** + +Command failed: npx jest ex2-mondaysWorth.test.js --colors + FAIL 1-JavaScript/Week3/assignment/ex2-mondaysWorth.test.js + computeEarnings + ✕ should take two parameters (4 ms) + ✕ should compute the earnings as a formatted Euro amount (2 ms) + + ● computeEarnings › should take two parameters + + expect(received).toHaveLength(expected) + + Expected length: 2 + Received length: 0 + Received function: [Function computeEarnings] + + 41 | // The `.length` property indicates the number of parameters expected by + 42 | // the function. + > 43 | expect(computeEarnings).toHaveLength(2); + | ^ + 44 | }); + 45 | + 46 | test('should compute the earnings as a formatted Euro amount', () => { + + at Object.toHaveLength (1-JavaScript/Week3/assignment/ex2-mondaysWorth.test.js:43:29) + + ● computeEarnings › should compute the earnings as a formatted Euro amount + + expect(received).toBe(expected) // Object.is equality + + Expected: "€187.50" + Received: undefined + + 47 | const result = computeEarnings(mondayTasks, hourlyRate); + 48 | const expected = '€187.50'; + > 49 | expect(result).toBe(expected); + | ^ + 50 | }); + 51 | }); + 52 | + + at Object.toBe (1-JavaScript/Week3/assignment/ex2-mondaysWorth.test.js:49:20) + +Test Suites: 1 failed, 1 total +Tests: 2 failed, 2 total +Snapshots: 0 total +Time: 0.41 s +Ran all test suites matching /ex2-mondaysWorth.test.js/i. +2024-07-14 04:22:32 info: ------------------------------------------------- +2024-07-14 04:22:32 info: >>> Running Unit Test `ex2-mondaysWorth.test` <<< +2024-07-14 04:22:32 info: ------------------------------------------------- +2024-07-14 04:22:34 error: *** Unit Test Error Report *** + +Command failed: npx jest ex2-mondaysWorth.test.js --colors + FAIL 1-JavaScript/Week3/assignment/ex2-mondaysWorth.test.js + computeEarnings + ✕ should take two parameters (4 ms) + ✕ should compute the earnings as a formatted Euro amount + + ● computeEarnings › should take two parameters + + expect(received).toHaveLength(expected) + + Expected length: 2 + Received length: 1 + Received function: [Function computeEarnings] + + 42 | // The `.length` property indicates the number of parameters expected by + 43 | // the function. + > 44 | expect(computeEarnings).toHaveLength(2); + | ^ + 45 | }); + 46 | + 47 | test('should compute the earnings as a formatted Euro amount', () => { + + at Object.toHaveLength (1-JavaScript/Week3/assignment/ex2-mondaysWorth.test.js:44:29) + + ● computeEarnings › should compute the earnings as a formatted Euro amount + + ReferenceError: duration is not defined + + 33 | + 34 | function computeEarnings(arr) { + > 35 | const totalEarrngs = mondayTasks.map(durationTime => durationTime * duration) + | ^ + 36 | // TODO complete this function + 37 | } + 38 | + + at duration (1-JavaScript/Week3/assignment/ex2-mondaysWorth.test.js:35:71) + at Array.map () + at map (1-JavaScript/Week3/assignment/ex2-mondaysWorth.test.js:35:36) + at Object.computeEarnings (1-JavaScript/Week3/assignment/ex2-mondaysWorth.test.js:48:20) + +Test Suites: 1 failed, 1 total +Tests: 2 failed, 2 total +Snapshots: 0 total +Time: 0.418 s, estimated 1 s +Ran all test suites matching /ex2-mondaysWorth.test.js/i. +2024-07-14 04:22:35 error: *** ESLint Report *** + +ex2-mondaysWorth.test.js + 34:26 error 'arr' is defined but never used no-unused-vars + 35:9 error 'totalEarrngs' is assigned a value but never used no-unused-vars + 35:71 error 'duration' is not defined no-undef + +✖ 3 problems (3 errors, 0 warnings) + + +2024-07-14 04:22:36 error: *** Spell Checker Report *** + +/Users/hackyourfuture/Desktop/assignments-cohort49/1-JavaScript/Week3/assignment/ex2-mondaysWorth.test.js:35:14 - Unknown word (Earrngs) + +2024-07-14 04:23:19 info: ------------------------------------------------- +2024-07-14 04:23:19 info: >>> Running Unit Test `ex2-mondaysWorth.test` <<< +2024-07-14 04:23:19 info: ------------------------------------------------- +2024-07-14 04:23:20 info: All unit tests passed. +2024-07-14 04:23:23 info: All steps were completed successfully +2024-07-14 05:22:51 info: ------------------------------------------------- +2024-07-14 05:22:51 info: >>> Running Unit Test `ex3-lemonAllergy.test` <<< +2024-07-14 05:22:51 info: ------------------------------------------------- +2024-07-14 05:22:53 error: *** Unit Test Error Report *** + +Command failed: npx jest ex3-lemonAllergy.test.js --colors + FAIL 1-JavaScript/Week3/assignment/ex3-lemonAllergy.test.js + sanitizeFruitBasket + ✕ should take two parameters (4 ms) + ✕ should not modify the original `fruitBasket` array (1 ms) + ✕ should return a new array that does not include the unwanted `lemon` (1 ms) + + ● sanitizeFruitBasket › should take two parameters + + expect(received).toBe(expected) // Object.is equality + + Expected: true + Received: false + + 38 | test('should take two parameters', () => { + 39 | // TODO replace next line with your code + > 40 | expect(false).toBe(true); + | ^ + 41 | }); + 42 | + 43 | test('should not modify the original `fruitBasket` array', () => { + + at Object.toBe (1-JavaScript/Week3/assignment/ex3-lemonAllergy.test.js:40:19) + + ● sanitizeFruitBasket › should not modify the original `fruitBasket` array + + expect(received).toBe(expected) // Object.is equality + + Expected: true + Received: false + + 45 | const originalFruitBasketContents = [...fruitBasket]; + 46 | // TODO replace next line with your code + > 47 | expect(false).toBe(true); + | ^ + 48 | }); + 49 | + 50 | test('should return a new array that does not include the unwanted `lemon`', () => { + + at Object.toBe (1-JavaScript/Week3/assignment/ex3-lemonAllergy.test.js:47:19) + + ● sanitizeFruitBasket › should return a new array that does not include the unwanted `lemon` + + expect(received).toBe(expected) // Object.is equality + + Expected: true + Received: false + + 50 | test('should return a new array that does not include the unwanted `lemon`', () => { + 51 | // TODO replace next line with your code + > 52 | expect(false).toBe(true); + | ^ + 53 | }); + 54 | }); + 55 | + + at Object.toBe (1-JavaScript/Week3/assignment/ex3-lemonAllergy.test.js:52:19) + +Test Suites: 1 failed, 1 total +Tests: 3 failed, 3 total +Snapshots: 0 total +Time: 0.423 s +Ran all test suites matching /ex3-lemonAllergy.test.js/i. +2024-07-14 05:22:54 error: *** ESLint Report *** + +ex3-lemonAllergy.test.js + 29:10 error 'sanitizeFruitBasket' is defined but never used no-unused-vars + 29:35 error 'fruitName' is defined but never used no-unused-vars + 45:11 error 'originalFruitBasketContents' is assigned a value but never used no-unused-vars + +✖ 3 problems (3 errors, 0 warnings) + + +2024-07-14 05:27:27 info: ------------------------------------------------- +2024-07-14 05:27:27 info: >>> Running Unit Test `ex3-lemonAllergy.test` <<< +2024-07-14 05:27:27 info: ------------------------------------------------- +2024-07-14 05:27:28 error: *** Unit Test Error Report *** + +console.log + [ + 'apple', + 'lemon', + 'grapefruit', + 'lemon', + 'banana', + 'watermelon', + 'lemon' + ] lemon + + at Object.log (1-JavaScript/Week3/assignment/ex3-lemonAllergy.test.js:34:9) + + + +Command failed: npx jest ex3-lemonAllergy.test.js --colors + FAIL 1-JavaScript/Week3/assignment/ex3-lemonAllergy.test.js + sanitizeFruitBasket + ✕ should take two parameters (5 ms) + ✕ should not modify the original `fruitBasket` array + ✕ should return a new array that does not include the unwanted `lemon` (1 ms) + + ● sanitizeFruitBasket › should take two parameters + + expect(received).toBe(expected) // Object.is equality + + Expected: true + Received: false + + 39 | test('should take two parameters', () => { + 40 | // TODO replace next line with your code + > 41 | expect(false).toBe(true); + | ^ + 42 | }); + 43 | + 44 | test('should not modify the original `fruitBasket` array', () => { + + at Object.toBe (1-JavaScript/Week3/assignment/ex3-lemonAllergy.test.js:41:19) + + ● sanitizeFruitBasket › should not modify the original `fruitBasket` array + + expect(received).toBe(expected) // Object.is equality + + Expected: true + Received: false + + 46 | const originalFruitBasketContents = [...fruitBasket]; + 47 | // TODO replace next line with your code + > 48 | expect(false).toBe(true); + | ^ + 49 | }); + 50 | + 51 | test('should return a new array that does not include the unwanted `lemon`', () => { + + at Object.toBe (1-JavaScript/Week3/assignment/ex3-lemonAllergy.test.js:48:19) + + ● sanitizeFruitBasket › should return a new array that does not include the unwanted `lemon` + + expect(received).toBe(expected) // Object.is equality + + Expected: true + Received: false + + 51 | test('should return a new array that does not include the unwanted `lemon`', () => { + 52 | // TODO replace next line with your code + > 53 | expect(false).toBe(true); + | ^ + 54 | }); + 55 | }); + 56 | + + at Object.toBe (1-JavaScript/Week3/assignment/ex3-lemonAllergy.test.js:53:19) + +Test Suites: 1 failed, 1 total +Tests: 3 failed, 3 total +Snapshots: 0 total +Time: 0.422 s, estimated 1 s +Ran all test suites matching /ex3-lemonAllergy.test.js/i. +2024-07-14 05:27:29 error: *** ESLint Report *** + +ex3-lemonAllergy.test.js + 29:10 error 'sanitizeFruitBasket' is defined but never used no-unused-vars + 46:11 error 'originalFruitBasketContents' is assigned a value but never used no-unused-vars + +✖ 2 problems (2 errors, 0 warnings) + + +2024-07-14 05:39:02 info: ------------------------------------------------- +2024-07-14 05:39:02 info: >>> Running Unit Test `ex3-lemonAllergy.test` <<< +2024-07-14 05:39:02 info: ------------------------------------------------- +2024-07-14 05:39:03 error: *** Unit Test Error Report *** + +Command failed: npx jest ex3-lemonAllergy.test.js --colors + FAIL 1-JavaScript/Week3/assignment/ex3-lemonAllergy.test.js + sanitizeFruitBasket + ✓ should take two parameters (2 ms) + ✕ should not modify the original `fruitBasket` array (1 ms) + ✕ should return a new array that does not include the unwanted `lemon` (4 ms) + + ● sanitizeFruitBasket › should not modify the original `fruitBasket` array + + TypeError: arr.filter is not a function + + 28 | // ! Function under test + 29 | function sanitizeFruitBasket(arr, fruitName) { + > 30 | const unwantedFruit = arr.filter(fruit => fruit !== fruitName) + | ^ + 31 | return unwantedFruit; + 32 | + 33 | } + + at filter (1-JavaScript/Week3/assignment/ex3-lemonAllergy.test.js:30:29) + at Object.sanitizeFruitBasket (1-JavaScript/Week3/assignment/ex3-lemonAllergy.test.js:45:5) + + ● sanitizeFruitBasket › should return a new array that does not include the unwanted `lemon` + + expect(received).toBe(expected) // Object.is equality + + If it should pass with deep equality, replace "toBe" with "toStrictEqual" + + Expected: ["apple", "grapefruit", "banana", "watermelon"] + Received: serializes to the same string + + 50 | const result = sanitizeFruitBasket(fruitBasket, 'lemon'); + 51 | const expected = ['apple', 'grapefruit', 'banana', 'watermelon']; + > 52 | expect(result).toBe(expected); + | ^ + 53 | }); + 54 | }); + 55 | + + at Object.toBe (1-JavaScript/Week3/assignment/ex3-lemonAllergy.test.js:52:20) + +Test Suites: 1 failed, 1 total +Tests: 2 failed, 1 passed, 3 total +Snapshots: 0 total +Time: 0.407 s, estimated 1 s +Ran all test suites matching /ex3-lemonAllergy.test.js/i. +2024-07-14 05:40:32 info: ------------------------------------------------- +2024-07-14 05:40:32 info: >>> Running Unit Test `ex3-lemonAllergy.test` <<< +2024-07-14 05:40:32 info: ------------------------------------------------- +2024-07-14 05:40:33 error: *** Unit Test Error Report *** + +Command failed: npx jest ex3-lemonAllergy.test.js --colors + FAIL 1-JavaScript/Week3/assignment/ex3-lemonAllergy.test.js + sanitizeFruitBasket + ✓ should take two parameters (3 ms) + ✕ should not modify the original `fruitBasket` array + ✓ should return a new array that does not include the unwanted `lemon` (1 ms) + + ● sanitizeFruitBasket › should not modify the original `fruitBasket` array + + TypeError: arr.filter is not a function + + 28 | // ! Function under test + 29 | function sanitizeFruitBasket(arr, fruitName) { + > 30 | const unwantedFruit = arr.filter(fruit => fruit !== fruitName) + | ^ + 31 | return unwantedFruit; + 32 | + 33 | } + + at filter (1-JavaScript/Week3/assignment/ex3-lemonAllergy.test.js:30:29) + at Object.sanitizeFruitBasket (1-JavaScript/Week3/assignment/ex3-lemonAllergy.test.js:45:5) + +Test Suites: 1 failed, 1 total +Tests: 1 failed, 2 passed, 3 total +Snapshots: 0 total +Time: 0.397 s, estimated 1 s +Ran all test suites matching /ex3-lemonAllergy.test.js/i. +2024-07-14 05:43:40 info: ------------------------------------------------- +2024-07-14 05:43:40 info: >>> Running Unit Test `ex3-lemonAllergy.test` <<< +2024-07-14 05:43:40 info: ------------------------------------------------- +2024-07-14 05:43:41 error: *** Unit Test Error Report *** + +console.log + [ 'apple', 'grapefruit', 'banana', 'watermelon' ] + + at Object.log (1-JavaScript/Week3/assignment/ex3-lemonAllergy.test.js:34:9) + + + +Command failed: npx jest ex3-lemonAllergy.test.js --colors + FAIL 1-JavaScript/Week3/assignment/ex3-lemonAllergy.test.js + sanitizeFruitBasket + ✓ should take two parameters (2 ms) + ✕ should not modify the original `fruitBasket` array (1 ms) + ✓ should return a new array that does not include the unwanted `lemon` (2 ms) + + ● sanitizeFruitBasket › should not modify the original `fruitBasket` array + + TypeError: arr.filter is not a function + + 28 | // ! Function under test + 29 | function sanitizeFruitBasket(arr, fruitName) { + > 30 | const unwantedFruit = arr.filter(fruit => fruit !== fruitName) + | ^ + 31 | return unwantedFruit; + 32 | + 33 | } + + at filter (1-JavaScript/Week3/assignment/ex3-lemonAllergy.test.js:30:29) + at Object.sanitizeFruitBasket (1-JavaScript/Week3/assignment/ex3-lemonAllergy.test.js:45:5) + +Test Suites: 1 failed, 1 total +Tests: 1 failed, 2 passed, 3 total +Snapshots: 0 total +Time: 0.423 s, estimated 1 s +Ran all test suites matching /ex3-lemonAllergy.test.js/i. +2024-07-14 05:45:35 info: ------------------------------------------------- +2024-07-14 05:45:35 info: >>> Running Unit Test `ex3-lemonAllergy.test` <<< +2024-07-14 05:45:35 info: ------------------------------------------------- +2024-07-14 05:45:37 info: All unit tests passed. +2024-07-14 05:45:39 info: All steps were completed successfully +2024-07-14 11:25:36 info: ------------------------------------------ +2024-07-14 11:25:36 info: >>> Running Unit Test `ex4-observable` <<< +2024-07-14 11:25:36 info: ------------------------------------------ +2024-07-14 11:25:37 info: All unit tests passed. +2024-07-14 11:25:38 error: *** ESLint Report *** + +ex4-observable/ex4-observable.js + 27:7 error 'observable' is assigned a value but never used no-unused-vars + +✖ 1 problem (1 error, 0 warnings) + + +2024-07-14 11:25:59 info: ------------------------------------------ +2024-07-14 11:25:59 info: >>> Running Unit Test `ex4-observable` <<< +2024-07-14 11:25:59 info: ------------------------------------------ +2024-07-14 11:26:00 info: All unit tests passed. +2024-07-14 11:26:02 info: All steps were completed successfully +2024-07-14 11:47:29 info: -------------------------------------- +2024-07-14 11:47:29 info: >>> Running Unit Test `ex5-wallet` <<< +2024-07-14 11:47:29 info: -------------------------------------- +2024-07-14 11:47:30 error: *** Unit Test Error Report *** + +✕ wallet q1: At line 26, which variables are in the scope marked Closure? +✕ wallet q2: What is in the Call Stack, from top to bottom? +✕ wallet q5: The owner of the wallet with insufficient funds is? + + +Command failed: npx jest ex5-wallet.test.js --colors --reporters="/Users/hackyourfuture/Desktop/assignments-cohort49/test-runner/CustomReporter.js" +2024-07-14 11:50:52 info: -------------------------------------- +2024-07-14 11:50:52 info: >>> Running Unit Test `ex5-wallet` <<< +2024-07-14 11:50:52 info: -------------------------------------- +2024-07-14 11:50:53 error: *** Unit Test Error Report *** + +✕ wallet q1: At line 26, which variables are in the scope marked Closure? + + +Command failed: npx jest ex5-wallet.test.js --colors --reporters="/Users/hackyourfuture/Desktop/assignments-cohort49/test-runner/CustomReporter.js" +2024-07-14 11:51:17 info: -------------------------------------- +2024-07-14 11:51:17 info: >>> Running Unit Test `ex5-wallet` <<< +2024-07-14 11:51:17 info: -------------------------------------- +2024-07-14 11:51:18 info: All unit tests passed. +2024-07-14 11:51:20 info: All steps were completed successfully