-
-
Notifications
You must be signed in to change notification settings - Fork 201
London | May-2025 | KhilolaRustamova | Sprint 2 | Sprint 2 coursework #589
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great explanations and solutions for the debug section - well done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps it would be better to add different edge cases to these tests such as what happens when:
- Empty input
- When there are duplicate keys
- When a pair has extra values, such as createLookup([["UK", "GBP", "Extra"]])).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i added some more test cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests are really interesting - it feels like there are three things we could do with ["UK", "GBP", "Extra"]:
- Ignore the
"Extra" - Ignore the whole entry because it's not in the expected format
- Throw an error because the caller probably didn't something wrong and we want to tell them there's a problem
Why did you pick 1? How do you feel about 2 and 3?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought 1 is flexible and tolerant of inputs with extra data.
2 would not be so helpful as it would ignore the data and not alert the data issue.
And 3 would be the choice if this function was part of a stricter API where input validation is important to make sure data issues are caught early.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, 1 vs 3 both sound pretty reasonable. There are trade-offs between ignoring potentially bad data vs erroring. e.g. imagine if someone had intentionally passed three values because a country had two currencies:
["ZW", "ZiG", "USD"]
If we proactively error, we tell them "Our system only supports two currencies, we're ignoring one of the ones you passed, you probably don't want to pass two, pick one". By not erroring, developers may assume their code is working with multiple currencies, when really some is being ignored.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A great set of test cases. Just had one question.
What do you expect to happen when you run parseQueryString("a=1&&b=2").
Can you add a test case for it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test is going to look like this.
test("parses multiple key-value pairs", () => {
expect(parseQueryString("a=1&&b=2")).toEqual({ a: "1", "", b: "2" });
});
AdnanGondal
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A great submission - but I have added some comments regarding additional test cases. Once done, let me know and I will mark as Complete.
illicitonion
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking really good - just a couple of small comments :)
| queryParams[key] = value; | ||
| } | ||
| const [key, ...rest] = pair.split("="); // Grab everything after first '=' | ||
| const value = rest.join("="); // Safely join back if value had '=' signs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This joining logic is really useful, but if you removed it none of your tests would start failing. Could you add a test that shows why this logic is here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i did, thank you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests are really interesting - it feels like there are three things we could do with ["UK", "GBP", "Extra"]:
- Ignore the
"Extra" - Ignore the whole entry because it's not in the expected format
- Throw an error because the caller probably didn't something wrong and we want to tell them there's a problem
Why did you pick 1? How do you feel about 2 and 3?
Learners, PR Template
Self checklist
Changelist
Briefly explain your PR.
Questions
Ask any questions you have for your reviewer.