|
16 | 16 |
|
17 | 17 | import { describe, it, expect, vi, beforeEach } from "vitest"; |
18 | 18 | import { renderHook, act, cleanup, waitFor } from "@testing-library/react"; |
19 | | -import React from "react"; |
20 | 19 | import { |
21 | 20 | useUI, |
22 | 21 | useRedirectError, |
23 | 22 | useSignInAuthFormSchema, |
24 | 23 | useSignUpAuthFormSchema, |
25 | 24 | useForgotPasswordAuthFormSchema, |
26 | 25 | useEmailLinkAuthFormSchema, |
27 | | - useMultiFactorPhoneAuthAssertionFormSchema, |
28 | 26 | usePhoneAuthNumberFormSchema, |
29 | 27 | usePhoneAuthVerifyFormSchema, |
30 | 28 | useRecaptchaVerifier, |
@@ -712,116 +710,6 @@ describe("usePhoneAuthVerifyFormSchema", () => { |
712 | 710 | }); |
713 | 711 | }); |
714 | 712 |
|
715 | | -describe("useMultiFactorPhoneAuthAssertionFormSchema", () => { |
716 | | - beforeEach(() => { |
717 | | - vi.clearAllMocks(); |
718 | | - cleanup(); |
719 | | - }); |
720 | | - |
721 | | - it("returns schema with default English error messages", () => { |
722 | | - const mockUI = createMockUI(); |
723 | | - |
724 | | - const { result } = renderHook(() => useMultiFactorPhoneAuthAssertionFormSchema(), { |
725 | | - wrapper: ({ children }) => createFirebaseUIProvider({ children, ui: mockUI }), |
726 | | - }); |
727 | | - |
728 | | - const schema = result.current; |
729 | | - |
730 | | - const phoneResult = schema.safeParse({ phoneNumber: "invalid-phone" }); |
731 | | - expect(phoneResult.success).toBe(false); |
732 | | - if (!phoneResult.success) { |
733 | | - expect(phoneResult.error.issues[0]!.message).toBe(enUs.translations.errors!.invalidPhoneNumber); |
734 | | - } |
735 | | - }); |
736 | | - |
737 | | - it("returns schema with custom error messages when locale changes", () => { |
738 | | - const customTranslations = { |
739 | | - errors: { |
740 | | - invalidPhoneNumber: "Por favor ingresa un número de teléfono válido", |
741 | | - }, |
742 | | - }; |
743 | | - |
744 | | - const customLocale = registerLocale("es-ES", customTranslations); |
745 | | - const mockUI = createMockUI({ locale: customLocale }); |
746 | | - |
747 | | - const { result } = renderHook(() => useMultiFactorPhoneAuthAssertionFormSchema(), { |
748 | | - wrapper: ({ children }) => createFirebaseUIProvider({ children, ui: mockUI }), |
749 | | - }); |
750 | | - |
751 | | - const schema = result.current; |
752 | | - |
753 | | - const phoneResult = schema.safeParse({ phoneNumber: "invalid-phone" }); |
754 | | - expect(phoneResult.success).toBe(false); |
755 | | - if (!phoneResult.success) { |
756 | | - expect(phoneResult.error.issues[0]!.message).toBe("Por favor ingresa un número de teléfono válido"); |
757 | | - } |
758 | | - }); |
759 | | - |
760 | | - it("returns stable reference when UI hasn't changed", () => { |
761 | | - const mockUI = createMockUI(); |
762 | | - |
763 | | - const { result, rerender } = renderHook(() => useMultiFactorPhoneAuthAssertionFormSchema(), { |
764 | | - wrapper: ({ children }) => createFirebaseUIProvider({ children, ui: mockUI }), |
765 | | - }); |
766 | | - |
767 | | - const initialSchema = result.current; |
768 | | - |
769 | | - rerender(); |
770 | | - |
771 | | - expect(result.current).toBe(initialSchema); |
772 | | - }); |
773 | | - |
774 | | - it("returns new schema when locale changes", () => { |
775 | | - const mockUI = createMockUI(); |
776 | | - |
777 | | - const { result, rerender } = renderHook(() => useMultiFactorPhoneAuthAssertionFormSchema(), { |
778 | | - wrapper: ({ children }) => createFirebaseUIProvider({ children, ui: mockUI }), |
779 | | - }); |
780 | | - |
781 | | - const initialSchema = result.current; |
782 | | - |
783 | | - const customTranslations = { |
784 | | - errors: { |
785 | | - invalidPhoneNumber: "Custom phone error", |
786 | | - }, |
787 | | - }; |
788 | | - const customLocale = registerLocale("fr-FR", customTranslations); |
789 | | - |
790 | | - act(() => { |
791 | | - mockUI.get().setLocale(customLocale); |
792 | | - }); |
793 | | - |
794 | | - rerender(); |
795 | | - |
796 | | - expect(result.current).not.toBe(initialSchema); |
797 | | - |
798 | | - const phoneResult = result.current.safeParse({ phoneNumber: "invalid-phone" }); |
799 | | - expect(phoneResult.success).toBe(false); |
800 | | - |
801 | | - if (!phoneResult.success) { |
802 | | - expect(phoneResult.error.issues[0]!.message).toBe("Custom phone error"); |
803 | | - } |
804 | | - }); |
805 | | - |
806 | | - it("accepts valid phone number without requiring displayName", () => { |
807 | | - const mockUI = createMockUI(); |
808 | | - |
809 | | - const { result } = renderHook(() => useMultiFactorPhoneAuthAssertionFormSchema(), { |
810 | | - wrapper: ({ children }) => createFirebaseUIProvider({ children, ui: mockUI }), |
811 | | - }); |
812 | | - |
813 | | - const schema = result.current; |
814 | | - |
815 | | - const phoneResult = schema.safeParse({ phoneNumber: "1234567890" }); |
816 | | - expect(phoneResult.success).toBe(true); |
817 | | - if (phoneResult.success) { |
818 | | - expect(phoneResult.data).toEqual({ phoneNumber: "1234567890" }); |
819 | | - // Should not have displayName field |
820 | | - expect(phoneResult.data).not.toHaveProperty("displayName"); |
821 | | - } |
822 | | - }); |
823 | | -}); |
824 | | - |
825 | 713 | describe("useRedirectError", () => { |
826 | 714 | beforeEach(() => { |
827 | 715 | vi.clearAllMocks(); |
|
0 commit comments