Skip to content

Commit

Permalink
hotfix: quick search form not receiving values in handler (#26)
Browse files Browse the repository at this point in the history
* hotfix: QuickSearchForm not handling values

* test: update misc tests and snapshots

* chore(cleanup): remove logs

* chore(version): bump lib version
  • Loading branch information
joshuagraber authored Dec 7, 2023
1 parent 8193325 commit cdf1e11
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pdap-design-system",
"version": "2.0.3",
"version": "2.0.4",
"description": "Global styles for PDAP apps",
"author": "Police Data Accessibility Project, Inc.",
"license": "ISC",
Expand Down
2 changes: 1 addition & 1 deletion src/components/Footer/__snapshots__/footer.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ exports[`Footer component > Renders a footer 1`] = `
<!--v-if-->
</li>
<li class="pdap-footer-link-container">
<a class="pdap-footer-social-link" href="ttps://discord.gg/wMqex8nKZJ" referrerpolicy="no-referrer" target="_blank">Discord</a>
<a class="pdap-footer-social-link" href="https://discord.gg/wMqex8nKZJ" referrerpolicy="no-referrer" target="_blank">Discord</a>
<!--v-if-->
</li>
<li class="pdap-footer-link-container">
Expand Down
2 changes: 1 addition & 1 deletion src/components/Form/PdapForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ async function submit(event: Event) {
const isValidSubmission = await v$.value.$validate();
if (isValidSubmission) {
// Emit submit event (spread to new object to create new object, this allows us to reset `values` without messing with the data returned)
emit('submit', { ...values });
emit('submit', { ...values.value });
// Reset vuelidate and form
v$.value.$reset();
const form = <HTMLFormElement>event.target;
Expand Down
9 changes: 2 additions & 7 deletions src/components/QuickSearchForm/QuickSearchForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,8 @@ const formSchema = [
},
];
function handleSubmit({
location,
searchTerm,
}: {
location: string;
searchTerm: string;
}) {
function handleSubmit(values: { location: string; searchTerm: string }) {
let { location, searchTerm } = values;
location = location && location.length > 0 ? location : 'all';
searchTerm = searchTerm && searchTerm.length > 0 ? searchTerm : 'all';
// If search route exists, route to it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

exports[`QuickSearchForm component > Renders a QuickSearchForm 1`] = `
<div class="pdap-flex-container pdap-flex-container-center pdap-quick-search-form">
<p class="quick-search-description"> We maintain a catalog of public records about police, court, and jail systems across the United States. </p>
<form class="pdap-form small">
<!--v-if-->
<div class="pdap-grid-container pdap-input">
Expand Down
4 changes: 2 additions & 2 deletions src/components/QuickSearchForm/quick-search-form.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ describe('QuickSearchForm component', () => {
expect((locationInput.element as HTMLInputElement).value).toBe('bar');

// Submit
await wrapper.find('form').trigger('submit');
await wrapper.find('form').trigger('submit.prevent');
await nextTick();

// Assert submit event
expect(wrapper.emitted()).toHaveProperty('submit');

expect(wrapper.emitted('submit')?.length).toBe(1);
// TODO: how to test router push called via form submit event. Not working anywhere.
// expect(push).toHaveBeenCalledWith('/search/foo/bar');
});
Expand Down

0 comments on commit cdf1e11

Please sign in to comment.