mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-09-08 20:26:08 -05:00
Better meta tags (#2083)
* Initial * Work * lint * Lint * Remove twitter * Progress * Progress * Progress * Progress * Progress * Progress * Fix
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, test } from "vitest";
|
||||
import { pathnameFromPotentialURL } from "./strings";
|
||||
import { pathnameFromPotentialURL, truncateBySentence } from "./strings";
|
||||
|
||||
describe("pathnameFromPotentialURL()", () => {
|
||||
test("Resolves path name from valid URL", () => {
|
||||
@@ -12,3 +12,35 @@ describe("pathnameFromPotentialURL()", () => {
|
||||
expect(pathnameFromPotentialURL("sendouc")).toBe("sendouc");
|
||||
});
|
||||
});
|
||||
|
||||
describe("truncateBySentence()", () => {
|
||||
test("Truncates text by sentence within max length", () => {
|
||||
const text = "This is the first sentence. This is the second sentence.";
|
||||
expect(truncateBySentence(text, 30)).toBe("This is the first sentence.");
|
||||
});
|
||||
|
||||
test("Returns original text if no sentences fit within max length", () => {
|
||||
const text = "This is a very long sentence that exceeds the max length.";
|
||||
expect(truncateBySentence(text, 10)).toBe("This is a");
|
||||
});
|
||||
|
||||
test("Returns original text if it is shorter than max length", () => {
|
||||
const text = "Short text.";
|
||||
expect(truncateBySentence(text, 50)).toBe("Short text.");
|
||||
});
|
||||
|
||||
test("Handles no senteces", () => {
|
||||
const text = "One two three four five six seven eight nine ten";
|
||||
expect(truncateBySentence(text, 10)).toBe("One two th");
|
||||
});
|
||||
|
||||
test("Truncates text by sentence with newline characters", () => {
|
||||
const text = "This is the first sentence\nThis is the second sentence";
|
||||
expect(truncateBySentence(text, 30)).toBe("This is the first sentence");
|
||||
});
|
||||
|
||||
test("Handles text with multiple newline characters", () => {
|
||||
const text = "First line\nSecond line\nThird line";
|
||||
expect(truncateBySentence(text, 20)).toBe("First line");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user