Skip to content

Commit

Permalink
fix(phone-number): improves tests for countries order
Browse files Browse the repository at this point in the history
  • Loading branch information
var-poro authored and dpellier committed Feb 17, 2025
1 parent 8583f62 commit 0557735
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ async function updateInternals(internals: ElementInternals, value: string | null
}
}


export {
type TranslatedCountryMap,
formatPhoneNumber,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ describe('ods-phone-number rendering', () => {
return page.evaluate(() => {
const options = document.querySelector('ods-phone-number')
?.shadowRoot?.querySelector('ods-select')
?.shadowRoot?.querySelectorAll<HTMLElement>('option');

return Array.from(options || []).map((option) => option.getAttribute('data-name')!);
?.shadowRoot?.querySelectorAll<HTMLElement>('.option');
return Array.from(options || []).map((option) => {
return option.children[1].innerHTML!;
});
});
}

Expand Down Expand Up @@ -79,14 +80,21 @@ describe('ods-phone-number rendering', () => {
});

it('should render the web component with countries in the right order', async() => {
await setup('<ods-phone-number locale="en" countries=\'["fr", "be"]\'></ods-phone-number>');
await setup('<ods-phone-number countries=\'[ "fr","gq", "gb"]\'></ods-phone-number>');
const selectElement = await page.find('ods-phone-number >>> ods-select');
await selectElement.click();
await page.waitForChanges();
const countriesNames = await getCountriesNames();

expect(countriesNames.sort()).toEqual(['Belgium', 'France', null]);
expect(countriesNames).toEqual(['Equatorial Guinea (+240)', 'France (+33)', 'United Kingdom of Great Britain and Northern Ireland (+44)']);

await el.setAttribute('locale', 'fr');
await page.waitForChanges();
await selectElement.click();
await selectElement.click();
await page.waitForChanges();
const countriesNamesLocaleChanged = await getCountriesNames();
expect(countriesNamesLocaleChanged.sort()).toEqual(['Belgique', 'France', null]);
expect(countriesNamesLocaleChanged).toEqual(['France (+33)', 'Guinée équatoriale (+240)', 'Royaume-Uni (+44)']);

});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ export class OdsSelect implements OdsFormElement {
this.select?.sync(); // get updated options
this.select?.setValue(currentValue); // set the value back
}

for (const mutation of mutations) {
// When observing is-required, the inner element validity is not yet up-to-date
// so we observe the element required attribute instead
Expand Down Expand Up @@ -338,7 +338,7 @@ export class OdsSelect implements OdsFormElement {
plugins: plugin,
render: template,
selectOnTab: true,
sortField: this.sortBy && [{field: this.sortBy}],
sortField: this.sortBy && [{ field: this.sortBy }],
});

this.bindSelectControl();
Expand Down

0 comments on commit 0557735

Please sign in to comment.
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy