-
Notifications
You must be signed in to change notification settings - Fork 896
add debounced search on type to the search bar #2703
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
Changes from all commits
702a654
db3c5fe
4f3202d
766f03e
0b66269
5637ca5
610b3f2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,9 +42,10 @@ | |
"formik": "2.2.9", | ||
"front-matter": "4.0.2", | ||
"history": "5.3.0", | ||
"just-debounce-it": "3.0.1", | ||
"react": "17.0.2", | ||
"react-dom": "17.0.2", | ||
"react-helmet": "^6.1.0", | ||
"react-helmet": "6.1.0", | ||
Comment on lines
-47
to
+48
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❓ Was this intentional? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jsjoeio Yeah, Grey requested that I always pin dependencies. I'm down to revisit this rule in the future, but figured I'd clean up while I was in there. |
||
"react-markdown": "8.0.3", | ||
"react-router-dom": "6.3.0", | ||
"sourcemapped-stacktrace": "1.1.11", | ||
|
@@ -74,7 +75,7 @@ | |
"@types/node": "14.18.16", | ||
"@types/react": "17.0.44", | ||
"@types/react-dom": "17.0.16", | ||
"@types/react-helmet": "^6.1.5", | ||
"@types/react-helmet": "6.1.5", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❓ Was this intentional? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
"@types/superagent": "4.1.15", | ||
"@types/uuid": "8.3.4", | ||
"@typescript-eslint/eslint-plugin": "5.27.0", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { fireEvent, screen } from "@testing-library/react" | ||
import userEvent from "@testing-library/user-event" | ||
import { render } from "../../testHelpers/renderHelpers" | ||
import { SearchBarWithFilter } from "./SearchBarWithFilter" | ||
|
||
// mock the debounce utility | ||
jest.mock("just-debounce-it", () => | ||
jest.fn((fn) => { | ||
fn.cancel = jest.fn() | ||
return fn | ||
}), | ||
) | ||
|
||
describe("SearchBarWithFilter", () => { | ||
it("calls the onFilter handler on keystroke", async () => { | ||
// When | ||
const onFilter = jest.fn() | ||
render(<SearchBarWithFilter onFilter={onFilter} />) | ||
|
||
const searchInput = screen.getByRole("textbox") | ||
await userEvent.type(searchInput, "workspace") // 9 characters | ||
|
||
// Then | ||
expect(onFilter).toBeCalledTimes(10) // 9 characters + 1 on component mount | ||
}) | ||
|
||
it("calls the onFilter handler on submit", async () => { | ||
// When | ||
const onFilter = jest.fn() | ||
render(<SearchBarWithFilter onFilter={onFilter} />) | ||
|
||
const searchInput = screen.getByRole("textbox") | ||
await fireEvent.keyDown(searchInput, { key: "Enter", code: "Enter", charCode: 13 }) | ||
|
||
// Then | ||
expect(onFilter).toBeCalledTimes(1) | ||
}) | ||
}) |
Uh oh!
There was an error while loading. Please reload this page.