-
Notifications
You must be signed in to change notification settings - Fork 0
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
support boolean facets #94
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.
Two requested changes:
- the extra tests
- the type change for
setParamValue
initial: "?department=6", | ||
expected: new URLSearchParams("?department=6&resource_type=program") | ||
} | ||
])("setSearchParams sets string params", ({ initial, expected }) => { |
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.
IMO it would be worth adding a few more tests, particularly array values:
test.each([
{
initial: "?resource_type=course&resource_type=program&department=6",
value: "program",
expected: new URLSearchParams("?department=6&resource_type=program")
},
{
initial: "?department=6",
value: "program",
expected: new URLSearchParams("?department=6&resource_type=program")
},
{
initial: "?department=6",
value: ["program", "video"],
expected: new URLSearchParams(
"?department=6&resource_type=program&resource_type=video"
)
},
{
initial: "?department=6&resource_type=program",
value: [],
expected: new URLSearchParams("?department=6")
}
])("setSearchParams sets string params", ({ initial, expected, value }) => {
const { result, searchParams } = setup({ initial })
act(() => {
result.current.setParamValue("resource_type", value)
})
expect(searchParams.current).toEqual(expected)
})
@@ -58,6 +58,9 @@ interface UseValidatedSearchParamsResult<ReqParams> { | |||
* - if `checked=false`, value is REMOVED from parameter list. | |||
*/ | |||
toggleParamValue: (name: string, rawValue: string, checked: boolean) => void | |||
|
|||
setParamValue: (name: string, rawValue: string) => void |
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 should be
setParamValue: (name: string, rawValue: string) => void | |
setParamValue: (name: string, rawValue: string | string[]) => void |
right? That allows setting department=6&department=8
, and also is consistent with the type below.
9511e6f
to
1ce3aa1
Compare
918b894
to
6d1cb40
Compare
What are the relevant tickets?
Description (What does it do?)
This updates course-search-utils to support boolean facets
How can this be tested?
Test with mitodl/mit-learn#802