summaryrefslogtreecommitdiffhomepage
path: root/packages/app/src/utils/notification-click.test.ts
diff options
context:
space:
mode:
authorBrendan Allan <[email protected]>2026-03-04 15:12:34 +0800
committerGitHub <[email protected]>2026-03-04 15:12:34 +0800
commit5cf235fa6cf7b4c890c68f8ff68a96fcae992abf (patch)
tree25fdfd8ce95ad048fb097822995dcf060e8d6d8b /packages/app/src/utils/notification-click.test.ts
parente4f0825c56300286ec0aa82b1006e4006a17e1e1 (diff)
downloadopencode-5cf235fa6cf7b4c890c68f8ff68a96fcae992abf.tar.gz
opencode-5cf235fa6cf7b4c890c68f8ff68a96fcae992abf.zip
desktop: add electron version (#15663)
Diffstat (limited to 'packages/app/src/utils/notification-click.test.ts')
-rw-r--r--packages/app/src/utils/notification-click.test.ts37
1 files changed, 19 insertions, 18 deletions
diff --git a/packages/app/src/utils/notification-click.test.ts b/packages/app/src/utils/notification-click.test.ts
index 76535f83a..fa81b0e02 100644
--- a/packages/app/src/utils/notification-click.test.ts
+++ b/packages/app/src/utils/notification-click.test.ts
@@ -1,26 +1,27 @@
-import { describe, expect, test } from "bun:test"
-import { handleNotificationClick } from "./notification-click"
+import { afterEach, describe, expect, test } from "bun:test"
+import { handleNotificationClick, setNavigate } from "./notification-click"
describe("notification click", () => {
- test("focuses and navigates when href exists", () => {
+ afterEach(() => {
+ setNavigate(undefined as any)
+ })
+
+ test("navigates via registered navigate function", () => {
const calls: string[] = []
- handleNotificationClick("/abc/session/123", {
- focus: () => calls.push("focus"),
- location: {
- assign: (href) => calls.push(href),
- },
- })
- expect(calls).toEqual(["focus", "/abc/session/123"])
+ setNavigate((href) => calls.push(href))
+ handleNotificationClick("/abc/session/123")
+ expect(calls).toEqual(["/abc/session/123"])
})
- test("only focuses when href is missing", () => {
+ test("does not navigate when href is missing", () => {
const calls: string[] = []
- handleNotificationClick(undefined, {
- focus: () => calls.push("focus"),
- location: {
- assign: (href) => calls.push(href),
- },
- })
- expect(calls).toEqual(["focus"])
+ setNavigate((href) => calls.push(href))
+ handleNotificationClick(undefined)
+ expect(calls).toEqual([])
+ })
+
+ test("falls back to location.assign without registered navigate", () => {
+ handleNotificationClick("/abc/session/123")
+ // falls back to window.location.assign — no error thrown
})
})