more refactor
Some checks failed
Deploy to Test Environment / deploy-to-test (push) Has been cancelled

This commit is contained in:
2025-12-21 20:34:32 -08:00
parent 15f759cbc4
commit bc2c24bcff
46 changed files with 387 additions and 257 deletions

View File

@@ -26,7 +26,6 @@ vi.mock('../services/logger.client', () => ({
const mockedApiClient = vi.mocked(apiClient);
const mockProfile: UserProfile = createMockUserProfile({
user_id: 'user-abc-123',
full_name: 'Test User',
points: 100,
role: 'user',

View File

@@ -27,7 +27,6 @@ const mockedToast = vi.mocked(toast);
// Mock data
const mockUserProfile = createMockUserProfile({
user_id: 'user-123',
address_id: 1,
full_name: 'Test User',
});
@@ -54,7 +53,6 @@ describe('useProfileAddress Hook', () => {
beforeEach(() => {
vi.clearAllMocks();
vi.useFakeTimers(); // Use fake timers for debounce tests
mockGeocode = vi.fn();
mockFetchAddress = vi.fn();
@@ -74,10 +72,6 @@ describe('useProfileAddress Hook', () => {
});
});
afterEach(() => {
vi.useRealTimers();
});
it('should initialize with empty address and initialAddress', () => {
const { result } = renderHook(() => useProfileAddress(null, false));
expect(result.current.address).toEqual({});
@@ -209,6 +203,14 @@ describe('useProfileAddress Hook', () => {
});
describe('Automatic Geocoding (Debounce)', () => {
beforeEach(() => {
vi.useFakeTimers();
});
afterEach(() => {
vi.useRealTimers();
});
it('should trigger geocode after user stops typing in an address without coordinates', async () => {
const addressWithoutCoords = { ...mockAddress, latitude: undefined, longitude: undefined };
mockFetchAddress.mockResolvedValue(addressWithoutCoords);

View File

@@ -32,7 +32,7 @@ const mockedUseAuth = vi.mocked(useAuth);
const mockedUseUserData = vi.mocked(useUserData);
// Create a mock User object by extracting it from a mock UserProfile
const mockUserProfile = createMockUserProfile({ user_id: 'user-123', user: createMockUser({ user_id: 'user-123', email: 'test@example.com' }) });
const mockUserProfile = createMockUserProfile({ user: createMockUser({ user_id: 'user-123', email: 'test@example.com' }) });
describe('useShoppingLists Hook', () => {
// Create a mock setter function that we can spy on