Skip to content

Commit 17c8d1b

Browse files
committed
Add test-cases for value-based country detection
1 parent 139ad88 commit 17c8d1b

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/hooks.test.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,22 @@ describe("Verifying the functionality of hooks", () => {
114114

115115
expect((result.current.metadata as any)[0]).toBe("am");
116116
})
117+
118+
it("Check usePhone for country detection", () => {
119+
const {result} = renderHook(usePhoneTester, {
120+
initialProps: {}
121+
});
122+
123+
act(() => result.current.update("1"));
124+
125+
expect((result.current.metadata as any)[0]).toBe("us");
126+
127+
act(() => result.current.update("1204"));
128+
129+
expect((result.current.metadata as any)[0]).toBe("ca");
130+
131+
act(() => result.current.backspace());
132+
133+
expect((result.current.metadata as any)[0]).toBe("us");
134+
})
117135
})

0 commit comments

Comments
 (0)