fix(test): 修复useAuth测试中mock setAuth不写localStorage的问题 (#677)
CI/CD Pipeline / Frontend Unit Tests (push) Failing after 5m29s
CI/CD Pipeline / Staging E2E Tests (push) Has been cancelled
CI/CD Pipeline / Staging API Integration Tests (push) Has been cancelled
CI/CD Pipeline / Production Browser E2E (push) Failing after 1370h9m12s
CI/CD Pipeline / Check if frontend-only change (push) Failing after 1370h9m17s
CI/CD Pipeline / Deploy Production (push) Failing after 1370h9m13s
CI/CD Pipeline / Build Production Worker Image (push) Failing after 1370h9m15s
CI/CD Pipeline / Build Production Web Image (push) Failing after 1370h9m16s
CI/CD Pipeline / Validate Code Quality And Tests (push) Has been skipped
CI/CD Pipeline / Unit Tests (push) Has been skipped
CI/CD Pipeline / Integration Tests (push) Has been skipped
CI/CD Pipeline / Frontend Lint (push) Has been skipped
CI/CD Pipeline / Build Staging API Image (push) Has been skipped
CI/CD Pipeline / Build Staging Web Image (push) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (push) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Has been skipped
CI/CD Pipeline / Build Production API Image (push) Failing after 1370h41m28s
CI/CD Pipeline / ACR Image Cleanup (push) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (push) Failing after 5m29s
CI/CD Pipeline / Staging E2E Tests (push) Has been cancelled
CI/CD Pipeline / Staging API Integration Tests (push) Has been cancelled
CI/CD Pipeline / Production Browser E2E (push) Failing after 1370h9m12s
CI/CD Pipeline / Check if frontend-only change (push) Failing after 1370h9m17s
CI/CD Pipeline / Deploy Production (push) Failing after 1370h9m13s
CI/CD Pipeline / Build Production Worker Image (push) Failing after 1370h9m15s
CI/CD Pipeline / Build Production Web Image (push) Failing after 1370h9m16s
CI/CD Pipeline / Validate Code Quality And Tests (push) Has been skipped
CI/CD Pipeline / Unit Tests (push) Has been skipped
CI/CD Pipeline / Integration Tests (push) Has been skipped
CI/CD Pipeline / Frontend Lint (push) Has been skipped
CI/CD Pipeline / Build Staging API Image (push) Has been skipped
CI/CD Pipeline / Build Staging Web Image (push) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (push) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Has been skipped
CI/CD Pipeline / Build Production API Image (push) Failing after 1370h41m28s
CI/CD Pipeline / ACR Image Cleanup (push) Has been skipped
Co-authored-by: xiaoxia <dev@xiaoxiajianji.com> Co-committed-by: xiaoxia <dev@xiaoxiajianji.com>
This commit was merged in pull request #677.
This commit is contained in:
@@ -7,8 +7,18 @@ import { renderHook, act } from "@testing-library/react"
|
||||
import { MemoryRouter } from "react-router-dom"
|
||||
|
||||
const mockNavigate = vi.fn()
|
||||
const mockSetAuth = vi.fn()
|
||||
const mockClearAuth = vi.fn()
|
||||
const mockSetAuth = vi.fn((_user: any, accessToken: string, refreshToken?: string | null) => {
|
||||
localStorage.setItem("access_token", accessToken)
|
||||
if (refreshToken) {
|
||||
localStorage.setItem("refresh_token", refreshToken)
|
||||
} else {
|
||||
localStorage.removeItem("refresh_token")
|
||||
}
|
||||
})
|
||||
const mockClearAuth = vi.fn(() => {
|
||||
localStorage.removeItem("access_token")
|
||||
localStorage.removeItem("refresh_token")
|
||||
})
|
||||
const mockMutateAsync = vi.fn()
|
||||
const mockQueryClear = vi.fn()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user