/** * Overridable staff-auth mock with spies. * * tests/setup.ts stubs @/components/context/staff-auth-context with this * factory so screens that read the staff session mount. Tests can flip the * state in a beforeEach; reset with resetStaffAuthMock(). */ import type { ReactNode } from 'react' export interface StaffAuthMockState { isLoggedIn: boolean isLoading: boolean staff: unknown isLoggingIn: boolean loginError: string | null login: jest.Mock logout: jest.Mock } export const staffAuthMock: StaffAuthMockState = { isLoggedIn: true, isLoading: false, staff: { id: 1, name: 'shafi' }, isLoggingIn: false, loginError: null, login: jest.fn(async () => {}), logout: jest.fn(), } export function resetStaffAuthMock() { staffAuthMock.isLoggedIn = true staffAuthMock.isLoading = false staffAuthMock.staff = { id: 1, name: 'shafi' } staffAuthMock.isLoggingIn = false staffAuthMock.loginError = null } export function staffAuthContextMock() { return { StaffAuthProvider: ({ children }: { children?: ReactNode }) => children ?? null, useStaffAuth: () => ({ isLoggedIn: staffAuthMock.isLoggedIn, isLoading: staffAuthMock.isLoading, staff: staffAuthMock.staff, isLoggingIn: staffAuthMock.isLoggingIn, loginError: staffAuthMock.loginError, login: staffAuthMock.login, logout: staffAuthMock.logout, }), } }