-
-
Notifications
You must be signed in to change notification settings - Fork 735
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: today day is auto focused when available (#2174)
- Loading branch information
Showing
4 changed files
with
89 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { gridcell } from "@/test/elements"; | ||
import { renderHook } from "@/test/renderHook"; | ||
import { user } from "@/test/user"; | ||
|
||
import { useFocus } from "./focus"; | ||
|
||
const month = new Date(2020, 0, 1); | ||
const today = new Date(2020, 0, 14); | ||
|
||
describe("autoFocusTarget", () => { | ||
describe("when not in interactive", () => { | ||
test("the auto focus target is undefined", () => { | ||
const { result } = renderHook(useFocus, { month, today }); | ||
expect(result.current.autoFocusTarget).toBeUndefined(); | ||
}); | ||
}); | ||
describe("when in selection mode", () => { | ||
test("the autofocus target should be today", () => { | ||
const { result } = renderHook(useFocus, { | ||
month, | ||
today, | ||
mode: "single" | ||
}); | ||
expect(result.current.autoFocusTarget?.date).toEqual( | ||
new Date(2020, 0, 14) | ||
); | ||
}); | ||
describe("if today is disabled", () => { | ||
test("the autofocus target should be the first focusable day (the 1st of month)", () => { | ||
const { result } = renderHook(useFocus, { | ||
month, | ||
today, | ||
mode: "multiple", | ||
disabled: [today] | ||
}); | ||
expect(result.current.autoFocusTarget?.date).toEqual(month); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters