41 lines
1.9 KiB
TypeScript
41 lines
1.9 KiB
TypeScript
import { splitByUrl } from "./Util";
|
|
|
|
describe("splitByUrl", () => {
|
|
it("should split a string by URLs", () => {
|
|
const inputStr =
|
|
"@npub1q6mcr8t not https://example.com- sure what your stack is, https://example.com but I made a https://example.com! simple example (https://example.com) of how https://example.com/yo-yo https://example.example.com to do this https://example.com, https://example.com?q=asdf for Next.js apps hosted on Vercel https://example.com. Scarcity in money provides the incentive to create abundance in other things as there is a mechanism to reliably store value. https://i.imgur.com/rkqhjeq.png Every form of money that could be inflated by way of force or technological advancement has been.";
|
|
const expectedOutput = [
|
|
"@npub1q6mcr8t not ",
|
|
"https://example.com-",
|
|
" sure what your stack is, ",
|
|
"https://example.com",
|
|
" but I made a ",
|
|
"https://example.com",
|
|
"! simple example (",
|
|
"https://example.com",
|
|
") of how ",
|
|
"https://example.com/yo-yo",
|
|
" ",
|
|
"https://example.example.com",
|
|
" to do this ",
|
|
"https://example.com",
|
|
", ",
|
|
"https://example.com?q=asdf",
|
|
" for Next.js apps hosted on Vercel ",
|
|
"https://example.com",
|
|
". Scarcity in money provides the incentive to create abundance in other things as there is a mechanism to reliably store value. ",
|
|
"https://i.imgur.com/rkqhjeq.png",
|
|
" Every form of money that could be inflated by way of force or technological advancement has been.",
|
|
];
|
|
|
|
expect(splitByUrl(inputStr)).toEqual(expectedOutput);
|
|
});
|
|
|
|
it("should return an array with a single string if no URLs are found", () => {
|
|
const inputStr = "This is a regular string with no URLs";
|
|
const expectedOutput = ["This is a regular string with no URLs"];
|
|
|
|
expect(splitByUrl(inputStr)).toEqual(expectedOutput);
|
|
});
|
|
});
|