Skip to content

Commit

Permalink
✅ [#607] Additional tests for valid phone number input
Browse files Browse the repository at this point in the history
  • Loading branch information
sergei-maertens committed Dec 8, 2023
1 parent 51eea3a commit d1ca1f4
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/formio/components/PhoneNumberField.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,22 @@ describe('The phone number component', () => {
expect(await screen.findByText('Invalid Phone Number')).toBeVisible();
}
);

it.each([
['+316 123 456 78'],
['06-12 34 56 78'],
['06-12-34-56 78'], // weird but ok
])('allows dashes and spaces for formatting (value: %i)', async value => {
const user = userEvent.setup({delay: 50});
const {form} = await renderForm();

const input = screen.getByLabelText('Phone number');
expect(input).toBeVisible();
await user.type(input, value);
expect(input).toHaveDisplayValue(value);

const component = form.getComponent('phoneNumber');
expect(component.getValue()).toBe(value);
expect(form.isValid()).toBe(true);
});
});

0 comments on commit d1ca1f4

Please sign in to comment.