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

test: add getURLs cases (#5974)

authored by yoginth.com and committed by

GitHub efec45d6 1634b487

+32
+32
apps/web/src/helpers/getURLs.test.ts
··· 1 + import { describe, expect, it } from "vitest"; 2 + import getURLs from "./getURLs"; 3 + 4 + describe("getURLs", () => { 5 + it("extracts all URLs from a social media post", () => { 6 + const post = 7 + "Check out https://example.com/blog and http://social.com/profile/hey #fun"; 8 + const result = getURLs(post); 9 + expect(result).toEqual([ 10 + "https://example.com/blog", 11 + "http://social.com/profile/hey" 12 + ]); 13 + }); 14 + 15 + it("returns an empty array when no URLs are present", () => { 16 + const post = "Enjoying the sunshine #weekend @friend"; 17 + const result = getURLs(post); 18 + expect(result).toEqual([]); 19 + }); 20 + 21 + it("ignores invalid URL formats", () => { 22 + const post = "Visit htps://broken.com and http://good.com"; 23 + const result = getURLs(post); 24 + expect(result).toEqual(["http://good.com"]); 25 + }); 26 + 27 + it("handles punctuation after URLs", () => { 28 + const post = "Latest news: https://news.com/update! Stay tuned."; 29 + const result = getURLs(post); 30 + expect(result).toEqual(["https://news.com/update"]); 31 + }); 32 + });