mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-06 12:30:59 +08:00
Remove duplicate password validation logic to ensure consistency. Changes: - Remove custom isStrongPassword function (RegisterPage.tsx:569-576) - Use PasswordChecklist validation result (passwordValid state) instead - Add comprehensive test suite with 28 test cases - Configure Vitest with jsdom environment and setup file Test Coverage: - Password validation rules (length, uppercase, lowercase, number, special chars) - Special character consistency (/[@#$%!&*?]/) - Edge cases and boundary conditions - Refactoring consistency verification All 78 tests passing (25 + 25 + 28). Co-authored-by: tinkle-community <tinklefund@gmail.com>
33 lines
708 B
TypeScript
33 lines
708 B
TypeScript
import '@testing-library/jest-dom'
|
|
import { beforeAll, afterEach } from 'vitest'
|
|
|
|
// Mock localStorage
|
|
const localStorageMock = {
|
|
getItem: (key: string) => {
|
|
return localStorageMock._store[key] || null
|
|
},
|
|
setItem: (key: string, value: string) => {
|
|
localStorageMock._store[key] = value
|
|
},
|
|
removeItem: (key: string) => {
|
|
delete localStorageMock._store[key]
|
|
},
|
|
clear: () => {
|
|
localStorageMock._store = {}
|
|
},
|
|
_store: {} as Record<string, string>,
|
|
}
|
|
|
|
// Setup before all tests
|
|
beforeAll(() => {
|
|
Object.defineProperty(window, 'localStorage', {
|
|
value: localStorageMock,
|
|
writable: true,
|
|
})
|
|
})
|
|
|
|
// Clean up after each test
|
|
afterEach(() => {
|
|
localStorageMock.clear()
|
|
})
|