-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: preserve form input values on custom form validation (#91)
resolves #58
- Loading branch information
1 parent
f701e72
commit aeaefc3
Showing
11 changed files
with
190 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -200,8 +200,8 @@ describe('Form component', () => { | |
await inputTextTwo.setValue('bar'); | ||
await inputEmail.setValue('[email protected]'); | ||
await inputPassword.setValue('P@ssword1!'); | ||
await inputCheckboxDefaultChecked.trigger('change'); | ||
await inputCheckboxDefaultUnchecked.trigger('change'); | ||
await inputCheckboxDefaultChecked.trigger('input'); | ||
await inputCheckboxDefaultUnchecked.trigger('input'); | ||
await nextTick(); | ||
|
||
// Assert new values | ||
|
@@ -288,4 +288,22 @@ describe('Form component', () => { | |
// Assert error message no longer present | ||
expect(wrapper.find('.pdap-form-error-message').exists()).toBe(false); | ||
}); | ||
|
||
test('Form waits to reset until resetOn prop switches to `true` and error is falsy', async () => { | ||
const wrapper = mount(PdapForm, { | ||
...base, | ||
props: { ...base.props, error: 'foo', resetOn: false }, | ||
}); | ||
|
||
// Assert error state | ||
expect(wrapper.find('.pdap-form-error-message').exists()).toBe(true); | ||
// Assert error message | ||
expect(wrapper.find('.pdap-form-error-message').text()).toBe('foo'); | ||
|
||
// Set values to correct values | ||
await wrapper.setProps({ error: '', resetOn: true }); | ||
|
||
// Assert error message no longer present | ||
expect(wrapper.find('.pdap-form-error-message').exists()).toBe(false); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.