Hey is a decentralized and permissionless social media app built with Lens Protocol 🌿

test: cover getFavicon helper (#5978)

authored by yoginth.com and committed by

GitHub a5c29efc efec45d6

+25
+25
apps/web/src/helpers/getFavicon.test.ts
··· 1 + import { describe, expect, it } from "vitest"; 2 + import getFavicon from "./getFavicon"; 3 + 4 + describe("getFavicon", () => { 5 + it("generates favicon URL for social media domain", () => { 6 + const result = getFavicon("https://twitter.com/lens"); 7 + expect(result).toBe( 8 + "https://external-content.duckduckgo.com/ip3/twitter.com.ico" 9 + ); 10 + }); 11 + 12 + it("handles subdomains correctly", () => { 13 + const result = getFavicon("https://m.facebook.com/user"); 14 + expect(result).toBe( 15 + "https://external-content.duckduckgo.com/ip3/m.facebook.com.ico" 16 + ); 17 + }); 18 + 19 + it("falls back to unknown domain on invalid URL", () => { 20 + const result = getFavicon("not a url"); 21 + expect(result).toBe( 22 + "https://external-content.duckduckgo.com/ip3/unknowndomain.ico" 23 + ); 24 + }); 25 + });