|
1 | 1 | import { describe, expect, it } from "@effect/vitest"; |
2 | 2 |
|
3 | | -import { |
4 | | - explicitFaviconUrl, |
5 | | - faviconUrlForOrigin, |
6 | | - faviconUrlForPage, |
7 | | - toolActivityFaviconUrl, |
8 | | -} from "./favicon.ts"; |
| 3 | +import { faviconUrlForOrigin, toolActivityFaviconUrl } from "./favicon.ts"; |
9 | 4 |
|
10 | 5 | describe("faviconUrlForOrigin", () => { |
11 | 6 | it.each([ |
@@ -46,12 +41,12 @@ describe("faviconUrlForOrigin", () => { |
46 | 41 | ); |
47 | 42 | }); |
48 | 43 |
|
49 | | -describe("faviconUrlForPage", () => { |
| 44 | +describe("toolActivityFaviconUrl", () => { |
50 | 45 | it("uses the page origin instead of a third-party favicon service", () => { |
51 | | - expect(faviconUrlForPage("https://example.com/docs/page?q=1")).toBe( |
| 46 | + expect(toolActivityFaviconUrl({ pageUrl: "https://example.com/docs/page?q=1" }, "light")).toBe( |
52 | 47 | "https://example.com/favicon.ico", |
53 | 48 | ); |
54 | | - expect(faviconUrlForPage("http://localhost:5173/app")).toBe( |
| 49 | + expect(toolActivityFaviconUrl({ pageUrl: "http://localhost:5173/app" }, "light")).toBe( |
55 | 50 | "http://localhost:5173/favicon.ico", |
56 | 51 | ); |
57 | 52 | }); |
@@ -86,7 +81,17 @@ describe("faviconUrlForPage", () => { |
86 | 81 | }); |
87 | 82 |
|
88 | 83 | it("accepts provider-supplied image URLs but rejects extension URLs", () => { |
89 | | - expect(explicitFaviconUrl("https://example.com/icon.png")).toBe("https://example.com/icon.png"); |
90 | | - expect(explicitFaviconUrl("chrome-extension://example/_favicon/")).toBeNull(); |
| 84 | + expect( |
| 85 | + toolActivityFaviconUrl( |
| 86 | + { pageUrl: "https://example.com/docs", faviconUrl: "https://example.com/icon.png" }, |
| 87 | + "light", |
| 88 | + ), |
| 89 | + ).toBe("https://example.com/icon.png"); |
| 90 | + expect( |
| 91 | + toolActivityFaviconUrl( |
| 92 | + { pageUrl: "https://example.com/docs", faviconUrl: "chrome-extension://example/_favicon/" }, |
| 93 | + "light", |
| 94 | + ), |
| 95 | + ).toBe("https://example.com/favicon.ico"); |
91 | 96 | }); |
92 | 97 | }); |
0 commit comments