diff --git a/frontend/src/lib/auth/SignupForm.test.ts b/frontend/src/lib/auth/SignupForm.test.ts index 842200f..897579d 100644 --- a/frontend/src/lib/auth/SignupForm.test.ts +++ b/frontend/src/lib/auth/SignupForm.test.ts @@ -175,6 +175,25 @@ describe('SignupForm', () => { expect(screen.getByText('Mindestens 8 Zeichen')).toBeInTheDocument(); }); + it.each([ + { length: 7, shouldFail: true }, + { length: 8, shouldFail: false } + ])('password with $length chars $shouldFail ? fails : passes validation', async ({ length, shouldFail }) => { + const user = userEvent.setup(); + render(SignupForm); + + await user.type(screen.getByLabelText('Dein Name'), 'Sarah'); + await user.type(screen.getByLabelText('E-Mail'), 'test@example.com'); + await user.type(screen.getByLabelText('Passwort'), 'a'.repeat(length)); + await user.click(screen.getByRole('button', { name: /konto erstellen/i })); + + if (shouldFail) { + expect(screen.getByText('Mindestens 8 Zeichen')).toBeInTheDocument(); + } else { + expect(screen.queryByText('Mindestens 8 Zeichen')).not.toBeInTheDocument(); + } + }); + it('renders placeholders on inputs', () => { render(SignupForm); expect(screen.getByPlaceholderText('z.B. Sarah')).toBeInTheDocument();