Skip to content

Commit

Permalink
test(components): update Form test
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuagraber committed Jun 18, 2024
1 parent 273ce06 commit 45418b9
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/components/Form/form.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});

0 comments on commit 45418b9

Please sign in to comment.