Skip to content

Commit d955c72

Browse files
committed
add tests
1 parent e2ec5db commit d955c72

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { describe, expect, it, vi } from "vitest";
2+
import { render, screen } from "../../../../../test/src/react-render.js";
3+
import { getCountrySelector } from "./CountrySelector.js";
4+
import { InputSelectionUI } from "./InputSelectionUI.js";
5+
6+
vi.mock("./CountrySelector.js", async (importOriginal) => ({
7+
...(await importOriginal()),
8+
getCountrySelector: vi.fn(),
9+
}));
10+
11+
describe("InputSelectionUI", () => {
12+
it("should initialize countryCodeInfo with defaultSmsCountryCode", () => {
13+
const mockGetCountrySelector = vi.mocked(getCountrySelector);
14+
mockGetCountrySelector.mockReturnValue("CA +1");
15+
16+
render(
17+
<InputSelectionUI
18+
defaultSmsCountryCode="CA"
19+
onSelect={vi.fn()}
20+
placeholder=""
21+
name=""
22+
type=""
23+
submitButtonText=""
24+
format="phone"
25+
/>,
26+
);
27+
28+
expect(screen.getByRole("combobox")).toHaveValue("CA +1");
29+
});
30+
31+
it('should initialize countryCodeInfo with "US +1" if defaultSmsCountryCode is not provided', () => {
32+
render(
33+
<InputSelectionUI
34+
onSelect={vi.fn()}
35+
placeholder=""
36+
name=""
37+
type=""
38+
submitButtonText=""
39+
format="phone"
40+
/>,
41+
);
42+
43+
expect(screen.getByRole("combobox")).toHaveValue("US +1");
44+
});
45+
});

0 commit comments

Comments
 (0)