London | 26-ITP-May | Anita Amirhaeri | Sprint 2 | Module-data-group - #1390
London | 26-ITP-May | Anita Amirhaeri | Sprint 2 | Module-data-group#1390anitahy73 wants to merge 19 commits into
Conversation
Updated recipe logging to display ingredients on separate lines.
Implemented the createLookup function to build a lookup object from country-currency pairs.
Refactor parseQueryString to handle empty pairs and decode keys/values.
Removed optional test for handling identical keys in query strings.
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
|
You might have accidently "saved" |
cjyuan
left a comment
There was a problem hiding this comment.
Changes look good.
Could you also update contains.test.js and lookup.test.js, and tally.test.js?
Added tests for the 'contains' function to validate behavior with various inputs, including empty objects, existing properties, non-existent properties, and invalid inputs.
Added input validation for countryCurrencyPairs and improved error handling.
Added tests for createLookup function to verify correct handling of valid pairs, empty input, and malformed pairs.
| expect(tally(["a"])).toEqual({ a: 1 }); | ||
| expect(tally(["a", "a", "a"]).a).toBe(3); |
There was a problem hiding this comment.
Could you research the trade-off between the first and the 2nd approaches to check if the function counts duplicates correctly?
| }); | ||
|
|
||
| test("invalid inputs (arrays, null, non-objects) return false", () => { | ||
| expect(contains([], "0")).toBe(false); |
There was a problem hiding this comment.
Array in JS is also an object, but "0" is not a key of [].
A function that fails to check if the first argument is an array could also return false simply because "0" is not a key of an empty array. To properly test if the function could return false when the first argument is an array, we should use a non-empty array, and then specify a key which the array has as the 2nd argument.
Learners, PR Template
Self checklist
Changelist
Sprint 2 | Module-data-group
Questions