diff options
Diffstat (limited to 'src/pages/SignUp.test.tsx')
| -rw-r--r-- | src/pages/SignUp.test.tsx | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/pages/SignUp.test.tsx b/src/pages/SignUp.test.tsx new file mode 100644 index 0000000..3029beb --- /dev/null +++ b/src/pages/SignUp.test.tsx @@ -0,0 +1,34 @@ +import { expect, test } from 'bun:test'; +import { render, fireEvent } from '@testing-library/preact'; +import { Pb } from '../context.ts'; +import { pb } from '../preload.ts'; +import SignUp from './SignUp.tsx'; + +test('has a link to log in', () => { + const { getAllByText, getByLabelText, getByText } = render( + <SignUp /> + ); + + expect(getAllByText(/log in/i)).not.toHaveLength(0); +}); + +test('can sign up', () => { + const username = 'foo'; + const email = 'foo@example.com'; + const password = '12345678'; + + const { getByText, getByLabelText } = render( + <Pb.Provider value={pb}> + <SignUp /> + </Pb.Provider> + ); + + fireEvent.change(getByLabelText(/username/i), {target: {value: username}}); + fireEvent.change(getByLabelText(/email/i), {target: {value: email}}); + fireEvent.change(getByLabelText(/password/i), {target: {value: password}}); + fireEvent.change(getByLabelText(/confirm password/i), {target: {value: password}}); + + fireEvent.click(getByText(/continue/i)); + + expect(pb.authStore.isValid()).toBeTrue(); +}); |
