profile-helpers.tsx33 lines · main
| 1 | import type { Profile } from '@/data/profile/types' |
| 2 | import type { ProfileContextType } from '@/lib/profile' |
| 3 | |
| 4 | export const createMockProfile = (overrides: Partial<Profile> = {}): Profile => { |
| 5 | const baseProfile: Profile = { |
| 6 | id: 1, |
| 7 | primary_email: 'test@example.com', |
| 8 | username: 'test-user', |
| 9 | first_name: 'Test', |
| 10 | last_name: 'User', |
| 11 | auth0_id: 'github|test-user', |
| 12 | is_alpha_user: false, |
| 13 | disabled_features: [], |
| 14 | free_project_limit: 2, |
| 15 | gotrue_id: '00000000-0000-0000-0000-000000000000', |
| 16 | is_sso_user: false, |
| 17 | mobile: '000-000-0000', |
| 18 | } |
| 19 | |
| 20 | return Object.assign(baseProfile, overrides) |
| 21 | } |
| 22 | |
| 23 | export const createMockProfileContext = ( |
| 24 | overrides: Partial<ProfileContextType> = {} |
| 25 | ): ProfileContextType => { |
| 26 | return { |
| 27 | profile: overrides.profile ?? createMockProfile(), |
| 28 | error: overrides.error ?? null, |
| 29 | isLoading: overrides.isLoading ?? false, |
| 30 | isError: overrides.isError ?? false, |
| 31 | isSuccess: overrides.isSuccess ?? true, |
| 32 | } |
| 33 | } |