11import React from "react" ;
2- import {
3- describe ,
4- expect ,
5- test ,
6- beforeEach ,
7- afterEach ,
8- vi ,
9- type MockInstance ,
10- } from "vitest" ;
2+ import { describe , expect , test , beforeEach , afterEach , vi } from "vitest" ;
113import { renderHook , act , waitFor } from "@testing-library/react" ;
124import { QueryClient , QueryClientProvider } from "@tanstack/react-query" ;
135import { useSignInWithEmailAndPasswordMutation } from "./useSignInWithEmailAndPasswordMutation" ;
@@ -41,11 +33,11 @@ describe("useSignInWithEmailAndPasswordMutation", () => {
4133 await createUserWithEmailAndPassword ( auth , email , password ) ;
4234
4335 const { result } = renderHook (
44- ( ) => useSignInWithEmailAndPasswordMutation ( auth , email , password ) ,
36+ ( ) => useSignInWithEmailAndPasswordMutation ( auth ) ,
4537 { wrapper }
4638 ) ;
4739
48- await act ( async ( ) => result . current . mutate ( ) ) ;
40+ await act ( async ( ) => result . current . mutate ( { email , password } ) ) ;
4941
5042 await waitFor ( async ( ) => expect ( result . current . isSuccess ) . toBe ( true ) ) ;
5143
@@ -60,12 +52,12 @@ describe("useSignInWithEmailAndPasswordMutation", () => {
6052 await createUserWithEmailAndPassword ( auth , email , password ) ;
6153
6254 const { result } = renderHook (
63- ( ) => useSignInWithEmailAndPasswordMutation ( auth , email , wrongPassword ) ,
55+ ( ) => useSignInWithEmailAndPasswordMutation ( auth ) ,
6456 { wrapper }
6557 ) ;
6658
6759 await act ( async ( ) => {
68- result . current . mutate ( ) ;
60+ result . current . mutate ( { email , password : wrongPassword } ) ;
6961 } ) ;
7062
7163 await waitFor ( ( ) => expect ( result . current . isError ) . toBe ( true ) ) ;
@@ -80,12 +72,12 @@ describe("useSignInWithEmailAndPasswordMutation", () => {
8072 const password = "tanstackQueryFirebase#123" ;
8173
8274 const { result } = renderHook (
83- ( ) => useSignInWithEmailAndPasswordMutation ( auth , email , password ) ,
75+ ( ) => useSignInWithEmailAndPasswordMutation ( auth ) ,
8476 { wrapper }
8577 ) ;
8678
8779 await act ( async ( ) => {
88- result . current . mutate ( ) ;
80+ result . current . mutate ( { email , password } ) ;
8981 } ) ;
9082
9183 await waitFor ( ( ) => expect ( result . current . isError ) . toBe ( true ) ) ;
@@ -100,12 +92,12 @@ describe("useSignInWithEmailAndPasswordMutation", () => {
10092 const password = "validPassword123" ;
10193
10294 const { result } = renderHook (
103- ( ) => useSignInWithEmailAndPasswordMutation ( auth , email , password ) ,
95+ ( ) => useSignInWithEmailAndPasswordMutation ( auth ) ,
10496 { wrapper }
10597 ) ;
10698
10799 await act ( async ( ) => {
108- result . current . mutate ( ) ;
100+ result . current . mutate ( { email , password } ) ;
109101 } ) ;
110102
111103 await waitFor ( ( ) => expect ( result . current . isError ) . toBe ( true ) ) ;
@@ -120,12 +112,12 @@ describe("useSignInWithEmailAndPasswordMutation", () => {
120112 const password = "" ;
121113
122114 const { result } = renderHook (
123- ( ) => useSignInWithEmailAndPasswordMutation ( auth , email , password ) ,
115+ ( ) => useSignInWithEmailAndPasswordMutation ( auth ) ,
124116 { wrapper }
125117 ) ;
126118
127119 await act ( async ( ) => {
128- result . current . mutate ( ) ;
120+ result . current . mutate ( { email , password } ) ;
129121 } ) ;
130122
131123 await waitFor ( ( ) => expect ( result . current . isError ) . toBe ( true ) ) ;
@@ -142,14 +134,14 @@ describe("useSignInWithEmailAndPasswordMutation", () => {
142134 await createUserWithEmailAndPassword ( auth , email , password ) ;
143135
144136 const { result } = renderHook (
145- ( ) => useSignInWithEmailAndPasswordMutation ( auth , email , password ) ,
137+ ( ) => useSignInWithEmailAndPasswordMutation ( auth ) ,
146138 { wrapper }
147139 ) ;
148140
149141 // Attempt multiple concurrent sign-ins
150142 await act ( async ( ) => {
151- result . current . mutate ( ) ;
152- result . current . mutate ( ) ;
143+ result . current . mutate ( { email , password } ) ;
144+ result . current . mutate ( { email , password } ) ;
153145 } ) ;
154146
155147 await waitFor ( ( ) => expect ( result . current . isSuccess ) . toBe ( true ) ) ;
@@ -167,14 +159,14 @@ describe("useSignInWithEmailAndPasswordMutation", () => {
167159
168160 const { result } = renderHook (
169161 ( ) =>
170- useSignInWithEmailAndPasswordMutation ( auth , email , password , {
162+ useSignInWithEmailAndPasswordMutation ( auth , {
171163 onSuccess : onSuccessMock ,
172164 } ) ,
173165 { wrapper }
174166 ) ;
175167
176168 await act ( async ( ) => {
177- result . current . mutate ( ) ;
169+ result . current . mutate ( { email , password } ) ;
178170 } ) ;
179171
180172 await waitFor ( ( ) => expect ( result . current . isSuccess ) . toBe ( true ) ) ;
0 commit comments