Update vitest.setup.ts

This commit is contained in:
Nate Kelley 2025-08-11 15:52:45 -06:00
parent d64f911442
commit d8451325cc
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
1 changed files with 22 additions and 5 deletions

View File

@ -61,14 +61,14 @@ vi.mock('remark-gfm', () => ({
})); }));
// Mock Supabase client to prevent environment variable errors in tests // Mock Supabase client to prevent environment variable errors in tests
vi.mock('@/lib/supabase/client', () => ({ vi.mock('@/lib/supabase/client', () => {
createBrowserClient: vi.fn(() => ({ const mockClient = {
auth: { auth: {
refreshSession: vi.fn().mockResolvedValue({ refreshSession: vi.fn().mockResolvedValue({
data: { data: {
session: { session: {
access_token: 'mock-token', access_token: 'mock-token',
expires_at: Date.now() / 1000 + 3600 // 1 hour from now expires_at: Math.floor(Date.now() / 1000) + 3600 // 1 hour from now
} }
}, },
error: null error: null
@ -76,7 +76,24 @@ vi.mock('@/lib/supabase/client', () => ({
getUser: vi.fn().mockResolvedValue({ getUser: vi.fn().mockResolvedValue({
data: { user: null }, data: { user: null },
error: null error: null
}),
getSession: vi.fn().mockResolvedValue({
data: {
session: {
access_token: 'mock-token',
expires_at: Math.floor(Date.now() / 1000) + 3600
}
},
error: null
}),
onAuthStateChange: vi.fn().mockReturnValue({
data: { subscription: { unsubscribe: vi.fn() } }
}) })
} }
})) };
}));
return {
createBrowserClient: vi.fn(() => mockClient),
getBrowserClient: vi.fn(() => mockClient)
};
});