summaryrefslogtreecommitdiffhomepage
path: root/packages/app/src/utils/notification-click.test.ts
blob: 76535f83a8e6515977931833d9dbcbc334f89d93 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { describe, expect, test } from "bun:test"
import { handleNotificationClick } from "./notification-click"

describe("notification click", () => {
  test("focuses and navigates when href exists", () => {
    const calls: string[] = []
    handleNotificationClick("/abc/session/123", {
      focus: () => calls.push("focus"),
      location: {
        assign: (href) => calls.push(href),
      },
    })
    expect(calls).toEqual(["focus", "/abc/session/123"])
  })

  test("only focuses when href is missing", () => {
    const calls: string[] = []
    handleNotificationClick(undefined, {
      focus: () => calls.push("focus"),
      location: {
        assign: (href) => calls.push(href),
      },
    })
    expect(calls).toEqual(["focus"])
  })
})