diff --git a/.test-summary/TEST_SUMMARY.md b/.test-summary/TEST_SUMMARY.md new file mode 100644 index 000000000..94e38b02d --- /dev/null +++ b/.test-summary/TEST_SUMMARY.md @@ -0,0 +1,13 @@ +## Test Summary + +**Mentors**: For more information on how to review homework assignments, please refer to the [Review Guide](https://github.com/HackYourFuture/mentors/blob/main/assignment-support/review-guide.md). + +### 1-JavaScript - Week3 + +| Exercise | Passed | Failed | ESLint | +|----------------------------|--------|--------|--------| +| ex1-doubleEvenNumbers.test | 1 | - | ✓ | +| ex2-mondaysWorth.test | 2 | - | ✓ | +| ex3-lemonAllergy.test | 3 | - | ✓ | +| ex4-observable | 3 | - | ✓ | +| ex5-wallet | 5 | - | ✓ | diff --git a/1-JavaScript/Week3/assignment/ex1-doubleEvenNumbers.test.js b/1-JavaScript/Week3/assignment/ex1-doubleEvenNumbers.test.js index ff706f8db..36659210b 100644 --- a/1-JavaScript/Week3/assignment/ex1-doubleEvenNumbers.test.js +++ b/1-JavaScript/Week3/assignment/ex1-doubleEvenNumbers.test.js @@ -11,14 +11,9 @@ Let's rewrite it (or _refactor_ it, as experienced developers would call it): ------------------------------------------------------------------------------*/ // ! Function to be tested function doubleEvenNumbers(numbers) { - // TODO rewrite the function body using `map` and `filter`. - const newNumbers = []; - for (let i = 0; i < numbers.length; i++) { - if (numbers[i] % 2 === 0) { - newNumbers.push(numbers[i] * 2); - } - } - return newNumbers; + return numbers + .filter(number => number % 2 === 0) + .map(number => number * 2) } // ! Unit test (using Jest) diff --git a/1-JavaScript/Week3/assignment/ex2-mondaysWorth.test.js b/1-JavaScript/Week3/assignment/ex2-mondaysWorth.test.js index d4ce4b45e..f8fc6d6e6 100644 --- a/1-JavaScript/Week3/assignment/ex2-mondaysWorth.test.js +++ b/1-JavaScript/Week3/assignment/ex2-mondaysWorth.test.js @@ -30,8 +30,15 @@ const mondayTasks = [ const hourlyRate = 25; -function computeEarnings(/* TODO parameter(s) go here */) { - // TODO complete this function +function computeEarnings(mondayTasks, hourlyRate) { + const totalDuration = mondayTasks.reduce((acc, current) => { + return acc + current.duration + }, 0) + + const totalHours = totalDuration / 60 + const totalAmount = (totalHours * hourlyRate).toFixed(2) + + return `€${totalAmount}` } // ! 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 8a11a5fad..fa1f0bc68 100644 --- a/1-JavaScript/Week3/assignment/ex3-lemonAllergy.test.js +++ b/1-JavaScript/Week3/assignment/ex3-lemonAllergy.test.js @@ -25,26 +25,31 @@ const fruitBasket = [ ]; // ! Function under test -function sanitizeFruitBasket(/* TODO parameter(s) go here */) { - // TODO complete this function +function sanitizeFruitBasket(fruitBasket, sanitizeFruit) { + return fruitBasket.filter(fruit => fruit !== sanitizeFruit) } // ! Unit tests (using Jest) describe('js-wk3-ex3-lemonAllergy', () => { test('sanitizeFruitBasket should take two parameters', () => { - // TODO replace next line with your code - expect(false).toBe(true); + expect(sanitizeFruitBasket).toHaveLength(2) }); test('sanitizeFruitBasket 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); + const originalFruitBasketContents = [...fruitBasket] + sanitizeFruitBasket(fruitBasket, 'lemon') + expect(fruitBasket).toEqual(originalFruitBasketContents) }); test('sanitizeFruitBasket should return a new array that does not include the unwanted `lemon`', () => { - // TODO replace next line with your code - expect(false).toBe(true); + const sanitizeArray = [ + 'apple', + 'grapefruit', + 'banana', + 'watermelon', + ] + const newArray = sanitizeFruitBasket(fruitBasket, 'lemon') + expect(newArray).toEqual(sanitizeArray); }); }); diff --git a/1-JavaScript/Week3/assignment/ex4-observable/ex4-observable.js b/1-JavaScript/Week3/assignment/ex4-observable/ex4-observable.js index a729822bc..dc1c56c24 100644 --- a/1-JavaScript/Week3/assignment/ex4-observable/ex4-observable.js +++ b/1-JavaScript/Week3/assignment/ex4-observable/ex4-observable.js @@ -16,10 +16,12 @@ export function createObservable() { const subscribers = []; return { subscribe(subscriber) { - // TODO complete this function + subscribers.push(subscriber) }, notify(message) { - // TODO complete this function + subscribers.forEach(subscriber => { + subscriber(message) + }) }, }; } diff --git a/1-JavaScript/Week3/assignment/ex5-wallet/index.js b/1-JavaScript/Week3/assignment/ex5-wallet/index.js index 215446ca8..d9a7d0e9e 100644 --- a/1-JavaScript/Week3/assignment/ex5-wallet/index.js +++ b/1-JavaScript/Week3/assignment/ex5-wallet/index.js @@ -23,7 +23,7 @@ function createWallet(name, cash = 0) { function transferInto(wallet, amount) { console.log( `Transferring ${eurosFormatter.format(amount)} from ${name} to ${ - wallet.name + wallet.getName() }` ); const withdrawnAmount = withdraw(amount); @@ -75,7 +75,7 @@ const quiz = { b: 'cash, name', c: 'amount, this, wallet' }, - answer: '?', + answer: 'b', }, q2: { question: 'What is in the Call Stack, from top to bottom?', @@ -84,7 +84,7 @@ const quiz = { b: 'anonymous, transferInto', c: 'transferInto, anonymous' }, - answer: '?', + answer: 'c', }, q3: { question: 'What tooltip appears when hovering over the third debug button?', @@ -93,7 +93,7 @@ const quiz = { b: 'Step out of current function', c: 'Step' }, - answer: '?', + answer: 'a', }, q4: { question: 'What is displayed in the console?', @@ -102,7 +102,7 @@ const quiz = { b: 'Transferring € 50,00 from Jack to undefined', c: 'Transferring € 50,00 from Jack to Jane' }, - answer: '?', + answer: 'a', }, q5: { question: 'The owner of the wallet with insufficient funds is:', @@ -111,6 +111,6 @@ const quiz = { b: 'Joe', c: 'Jane' }, - answer: '?', + answer: 'c', }, }; diff --git a/1-JavaScript/Week3/test-reports/ex1-doubleEvenNumbers.test.report.txt b/1-JavaScript/Week3/test-reports/ex1-doubleEvenNumbers.test.report.txt new file mode 100644 index 000000000..6028bc969 --- /dev/null +++ b/1-JavaScript/Week3/test-reports/ex1-doubleEvenNumbers.test.report.txt @@ -0,0 +1,13 @@ +*** Unit Test Error Report *** + + PASS 1-JavaScript/Week3/assignment/ex1-doubleEvenNumbers.test.js + js-wk3-ex1-doubleEvenNumbers + ✅ doubleEvenNumbers should take the even numbers and double them (1 ms) + +Test Suites: 1 passed, 1 total +Tests: 1 passed, 1 total +Snapshots: 0 total +Time: 0.251 s, estimated 1 s +Ran all test suites matching /\/Users\/dimadoronin\/Documents\/Programming\/HackYourFuture\/Assignments-Cohort54\/1-JavaScript\/Week3\/assignment\/ex1-doubleEvenNumbers.test.js/i. +No linting errors detected. +No spelling errors detected. diff --git a/1-JavaScript/Week3/test-reports/ex2-mondaysWorth.test.report.txt b/1-JavaScript/Week3/test-reports/ex2-mondaysWorth.test.report.txt new file mode 100644 index 000000000..b07d6d09e --- /dev/null +++ b/1-JavaScript/Week3/test-reports/ex2-mondaysWorth.test.report.txt @@ -0,0 +1,14 @@ +*** Unit Test Error Report *** + + PASS 1-JavaScript/Week3/assignment/ex2-mondaysWorth.test.js + js-wk3-mondaysWorth + ✅ computeEarnings should take two parameters (1 ms) + ✅ computeEarnings should compute the earnings as a formatted Euro amount + +Test Suites: 1 passed, 1 total +Tests: 2 passed, 2 total +Snapshots: 0 total +Time: 0.209 s, estimated 1 s +Ran all test suites matching /\/Users\/dimadoronin\/Documents\/Programming\/HackYourFuture\/Assignments-Cohort54\/1-JavaScript\/Week3\/assignment\/ex2-mondaysWorth.test.js/i. +No linting errors detected. +No spelling errors detected. diff --git a/1-JavaScript/Week3/test-reports/ex3-lemonAllergy.test.report.txt b/1-JavaScript/Week3/test-reports/ex3-lemonAllergy.test.report.txt new file mode 100644 index 000000000..adc76a57a --- /dev/null +++ b/1-JavaScript/Week3/test-reports/ex3-lemonAllergy.test.report.txt @@ -0,0 +1,15 @@ +*** Unit Test Error Report *** + + PASS 1-JavaScript/Week3/assignment/ex3-lemonAllergy.test.js + js-wk3-ex3-lemonAllergy + ✅ sanitizeFruitBasket should take two parameters (1 ms) + ✅ sanitizeFruitBasket should not modify the original `fruitBasket` array (1 ms) + ✅ sanitizeFruitBasket should return a new array that does not include the unwanted `lemon` + +Test Suites: 1 passed, 1 total +Tests: 3 passed, 3 total +Snapshots: 0 total +Time: 0.246 s, estimated 1 s +Ran all test suites matching /\/Users\/dimadoronin\/Documents\/Programming\/HackYourFuture\/Assignments-Cohort54\/1-JavaScript\/Week3\/assignment\/ex3-lemonAllergy.test.js/i. +No linting errors detected. +No spelling errors detected. diff --git a/1-JavaScript/Week3/test-reports/ex4-observable.report.txt b/1-JavaScript/Week3/test-reports/ex4-observable.report.txt new file mode 100644 index 000000000..a15e4632f --- /dev/null +++ b/1-JavaScript/Week3/test-reports/ex4-observable.report.txt @@ -0,0 +1,15 @@ +*** Unit Test Error Report *** + + PASS 1-JavaScript/Week3/assignment/ex4-observable/ex4-observable.test.js + js-wk3-ex4-observable + ✅ createObservable should exist and be a function (1 ms) + ✅ createObservable should return an object with `subscribe` and a `notify` function properties + ✅ observable should notify all subscribers of any notification (1 ms) + +Test Suites: 1 passed, 1 total +Tests: 3 passed, 3 total +Snapshots: 0 total +Time: 0.216 s, estimated 1 s +Ran all test suites matching /\/Users\/dimadoronin\/Documents\/Programming\/HackYourFuture\/Assignments-Cohort54\/1-JavaScript\/Week3\/assignment\/ex4-observable\/ex4-observable.test.js/i. +No linting errors detected. +No spelling errors detected. diff --git a/1-JavaScript/Week3/test-reports/ex5-wallet.report.txt b/1-JavaScript/Week3/test-reports/ex5-wallet.report.txt new file mode 100644 index 000000000..9cd0069d6 --- /dev/null +++ b/1-JavaScript/Week3/test-reports/ex5-wallet.report.txt @@ -0,0 +1,17 @@ +*** Unit Test Error Report *** + + PASS .dist/1-JavaScript/Week3/unit-tests/ex5-wallet.test.js + js-wk3-ex5-wallet + ✅ q1: At line 24, which variables are in the scope marked Closure? (1 ms) + ✅ q2: What is in the Call Stack, from top to bottom? + ✅ q3: What tooltip appears when hovering over the third debug button? + ✅ q4: What is displayed in the console? + ✅ q5: The owner of the wallet with insufficient funds is? + +Test Suites: 1 passed, 1 total +Tests: 5 passed, 5 total +Snapshots: 0 total +Time: 0.3 s +Ran all test suites matching /\/Users\/dimadoronin\/Documents\/Programming\/HackYourFuture\/Assignments-Cohort54\/.dist\/1-JavaScript\/Week3\/unit-tests\/ex5-wallet.test.js/i. +No linting errors detected. +No spelling errors detected.