1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-07-31 13:44:28 +03:00

Get country names from the browser instead of manual i18n (#11428)

* Get country names from the browser instead of manual i18n

* Make getUserLanguage more resilient to bad inputs

* Improve coverage
This commit is contained in:
Michael Telatynski
2023-08-22 17:15:16 +01:00
committed by GitHub
parent ac70f7ac9b
commit 0d8b58cdd7
4 changed files with 48 additions and 523 deletions

View File

@ -15,7 +15,8 @@ limitations under the License.
*/
import React from "react";
import { render } from "@testing-library/react";
import { fireEvent, render } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import CountryDropdown from "../../../../src/components/views/auth/CountryDropdown";
import SdkConfig from "../../../../src/SdkConfig";
@ -65,4 +66,18 @@ describe("CountryDropdown", () => {
expect(fn).toHaveBeenCalledWith(expect.objectContaining({ prefix: defaultCountryCode.toString() }));
});
});
it("should allow filtering", async () => {
const fn = jest.fn();
const { getByRole, findByText } = render(
<CountryDropdown onOptionChange={fn} isSmall={false} showPrefix={false} />,
);
const dropdown = getByRole("button");
fireEvent.click(dropdown);
await userEvent.keyboard("Al");
await expect(findByText("Albania (+355)")).resolves.toBeInTheDocument();
});
});