Skip to content

Commit 68dd840

Browse files
fix the failing test
Signed-off-by: Rakshit Yadav <yadavrakshit60@gmail.com>
1 parent a14a6af commit 68dd840

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

tests/unit/AuthController.spec.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import {
55
setPersistence,
66
signInWithEmailAndPassword,
77
signInWithPopup,
8-
signOut
8+
signOut,
9+
sendEmailVerification
910
} from 'firebase/auth'
1011

1112
jest.mock('firebase/auth', () => ({
@@ -16,6 +17,7 @@ jest.mock('firebase/auth', () => ({
1617
signInWithPopup: jest.fn(),
1718
GoogleAuthProvider: jest.fn(),
1819
sendPasswordResetEmail: jest.fn(),
20+
sendEmailVerification: jest.fn(),
1921
setPersistence: jest.fn(),
2022
browserLocalPersistence: 'local',
2123
browserSessionPersistence: 'session'
@@ -40,6 +42,7 @@ describe('AuthController', () => {
4042

4143
beforeEach(() => {
4244
jest.clearAllMocks()
45+
sendEmailVerification.mockResolvedValue(undefined)
4346
authController = new AuthController()
4447
})
4548

@@ -69,7 +72,7 @@ describe('AuthController', () => {
6972

7073
describe('signIn', () => {
7174
it('should set local persistence when rememberMe is true', async () => {
72-
const mockCredential = { user: { uid: 'user-id' } }
75+
const mockCredential = { user: { uid: 'user-id', emailVerified: true } }
7376
setPersistence.mockResolvedValue()
7477
signInWithEmailAndPassword.mockResolvedValue(mockCredential)
7578

@@ -85,7 +88,7 @@ describe('AuthController', () => {
8588

8689
it('should set session persistence when rememberMe is false', async () => {
8790
setPersistence.mockResolvedValue()
88-
signInWithEmailAndPassword.mockResolvedValue({ user: {} })
91+
signInWithEmailAndPassword.mockResolvedValue({ user: { emailVerified: true } })
8992

9093
await authController.signIn('test@example.com', 'password123', false)
9194

0 commit comments

Comments
 (0)