Skip to content

Commit 07acf3f

Browse files
test: Fix coverage for parseDateForNavigation month fallback branch
Use year "2000" which doesn't match month regex, ensuring the refDate.getMonth() fallback on line 181 is covered. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 0b081c6 commit 07acf3f

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/test/datepicker_test.test.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2482,18 +2482,20 @@ describe("DatePicker", () => {
24822482
);
24832483
expect(instance).toBeTruthy();
24842484

2485-
// Verify initial calendar shows 2024
2485+
// Verify initial calendar shows June 2024
24862486
expect(instance!.state.preSelection?.getFullYear()).toBe(2024);
2487+
expect(instance!.state.preSelection?.getMonth()).toBe(5); // June
24872488

2488-
// Type a partial date - just a year
2489+
// Type a partial date - just a year (use 2000 which won't match as a month)
24892490
fireEvent.change(instance!.input!, {
24902491
target: {
2491-
value: "2014",
2492+
value: "2000",
24922493
},
24932494
});
24942495

2495-
// Calendar should navigate to 2014 even though it's not a complete date
2496-
expect(instance!.state.preSelection?.getFullYear()).toBe(2014);
2496+
// Calendar should navigate to 2000 with the same month (June) from the selected date
2497+
expect(instance!.state.preSelection?.getFullYear()).toBe(2000);
2498+
expect(instance!.state.preSelection?.getMonth()).toBe(5); // June preserved from refDate
24972499
});
24982500
it("should update calendar view when typing a partial date (month and year)", () => {
24992501
let instance: DatePicker | null = null;

0 commit comments

Comments
 (0)