refactor: deduplicate formatters and improve test mocks (#81)
- Consolidate duplicate date formatting utilities - Use shared formatters across backend and frontend - Clean up test mocks to use consistent test data - Remove redundant formatting functions
This commit is contained in:
@@ -482,6 +482,17 @@ describe("DashboardPage with medications", () => {
|
||||
});
|
||||
|
||||
it("renders schedule timeline with future doses", () => {
|
||||
// Need showFutureDays: true for day-blocks to render
|
||||
mockContextValue = createMockAppContext({
|
||||
meds: mockMeds,
|
||||
coverage: mockCoverage,
|
||||
coverageByMed: {
|
||||
Aspirin: mockCoverage.all[0],
|
||||
},
|
||||
futureDays: mockFutureDays,
|
||||
showFutureDays: true,
|
||||
});
|
||||
|
||||
render(
|
||||
<MemoryRouter>
|
||||
<DashboardPage />
|
||||
@@ -548,6 +559,7 @@ describe("DashboardPage with email notifications", () => {
|
||||
settings: {
|
||||
...createMockAppContext().settings,
|
||||
emailEnabled: true,
|
||||
emailStockReminders: true,
|
||||
notificationEmail: "test@example.com",
|
||||
},
|
||||
});
|
||||
@@ -587,6 +599,7 @@ describe("DashboardPage with shoutrrr notifications", () => {
|
||||
settings: {
|
||||
...createMockAppContext().settings,
|
||||
shoutrrrEnabled: true,
|
||||
shoutrrrStockReminders: true,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@@ -110,11 +110,17 @@ let mockFormHookValue = createMockFormHook();
|
||||
// Mock the hooks
|
||||
vi.mock("../../hooks", () => ({
|
||||
useMedicationForm: () => mockFormHookValue,
|
||||
useUnsavedChangesWarning: () => ({}),
|
||||
}));
|
||||
|
||||
// Mock the context
|
||||
vi.mock("../../context", () => ({
|
||||
useAppContext: () => mockContextValue,
|
||||
useUnsavedChanges: () => ({
|
||||
setHasUnsavedChanges: vi.fn(),
|
||||
hasUnsavedChanges: false,
|
||||
confirmNavigation: vi.fn().mockReturnValue(true),
|
||||
}),
|
||||
}));
|
||||
|
||||
describe("MedicationsPage", () => {
|
||||
|
||||
Reference in New Issue
Block a user