added initial roadmap and implementation
This commit is contained in:
42
tests/integration/auth.test.ts
Normal file
42
tests/integration/auth.test.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { createAnonClient } from './setup.ts';
|
||||
|
||||
const client = createAnonClient();
|
||||
const email = `test-${Date.now()}@example.com`;
|
||||
const password = 'password123';
|
||||
|
||||
describe('Authentication', () => {
|
||||
it('should sign up a new user', async () => {
|
||||
const { data, error } = await client.auth.signUp({
|
||||
email,
|
||||
password,
|
||||
});
|
||||
|
||||
expect(error).toBeNull();
|
||||
expect(data.user).toBeDefined();
|
||||
expect(data.user?.email).toBe(email);
|
||||
expect(data.session).toBeDefined(); // Assuming auto-sign-in on signup
|
||||
});
|
||||
|
||||
it('should sign in an existing user', async () => {
|
||||
const { data, error } = await client.auth.signInWithPassword({
|
||||
email,
|
||||
password,
|
||||
});
|
||||
|
||||
expect(error).toBeNull();
|
||||
expect(data.session).toBeDefined();
|
||||
expect(data.user).toBeDefined();
|
||||
expect(data.user?.email).toBe(email);
|
||||
});
|
||||
|
||||
it('should fail with incorrect password', async () => {
|
||||
const { data, error } = await client.auth.signInWithPassword({
|
||||
email,
|
||||
password: 'wrongpassword',
|
||||
});
|
||||
|
||||
expect(error).toBeDefined();
|
||||
expect(data.session).toBeNull();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user