Skip to content

Commit

Permalink
test: fix failing tests after Dominican Republic country data updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ybrusentsov committed May 18, 2024
1 parent 4b8721a commit cd4ba23
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 20 deletions.
8 changes: 4 additions & 4 deletions src/components/PhoneInput/PhoneInput.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1122,10 +1122,10 @@ describe('PhoneInput', () => {

test('should use default mask if country data does not have mask', () => {
// mask is undefined
const { rerender } = render(<PhoneInput defaultCountry="do" />);
fireChangeEvent('+1114567');
expect(getInput().value).toBe('+1 114567');
expect(getCountrySelector()).toHaveAttribute('data-country', 'do');
const { rerender } = render(<PhoneInput defaultCountry="af" />);
fireChangeEvent('+93114567');
expect(getInput().value).toBe('+93 114567');
expect(getCountrySelector()).toHaveAttribute('data-country', 'af');

// mask is empty string
rerender(<PhoneInput defaultCountry="gr" />);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,32 +153,22 @@ describe('guessCountryByPartialNumber', () => {
test('should return the current country if the dial code matches', () => {
expect(
guessCountryByPartialNumber({
phone: '+1 234567890',
phone: '+39 1234567890',
countries: defaultCountries,
currentCountryIso2: 'us',
currentCountryIso2: 'it',
}),
).toMatchObject({
country: { dialCode: '1', iso2: 'us' },
country: { dialCode: '39', iso2: 'it' },
});

expect(
guessCountryByPartialNumber({
phone: '+1 204567890', // Canada area code
phone: '+39 1234567890',
countries: defaultCountries,
currentCountryIso2: 'do',
currentCountryIso2: 'va',
}),
).toMatchObject({
country: { dialCode: '1', iso2: 'ca' },
});

expect(
guessCountryByPartialNumber({
phone: '+1 111567890',
countries: defaultCountries,
currentCountryIso2: 'do',
}),
).toMatchObject({
country: { dialCode: '1', iso2: 'do' },
country: { dialCode: '39', iso2: 'va' },
});
});
});

0 comments on commit cd4ba23

Please sign in to comment.