import { passwordSchema } from '@lingxi/shared'; import { describe, expect, it } from 'vitest'; import { generateInitialPassword } from './user-new-password'; describe('初始密码生成', () => { it('生成的密码符合共享密码策略', () => { for (let index = 0; index < 200; index += 1) { const password = generateInitialPassword(); expect(passwordSchema.safeParse(password).success, password).toBe(true); } }); it('多次生成结果不同(随机性)', () => { const samples = new Set(Array.from({ length: 20 }, () => generateInitialPassword())); expect(samples.size).toBeGreaterThan(1); }); });