notification-click.test.ts 759 B

1234567891011121314151617181920212223242526
  1. import { describe, expect, test } from "bun:test"
  2. import { handleNotificationClick } from "./notification-click"
  3. describe("notification click", () => {
  4. test("focuses and navigates when href exists", () => {
  5. const calls: string[] = []
  6. handleNotificationClick("/abc/session/123", {
  7. focus: () => calls.push("focus"),
  8. location: {
  9. assign: (href) => calls.push(href),
  10. },
  11. })
  12. expect(calls).toEqual(["focus", "/abc/session/123"])
  13. })
  14. test("only focuses when href is missing", () => {
  15. const calls: string[] = []
  16. handleNotificationClick(undefined, {
  17. focus: () => calls.push("focus"),
  18. location: {
  19. assign: (href) => calls.push(href),
  20. },
  21. })
  22. expect(calls).toEqual(["focus"])
  23. })
  24. })