2022-09-25 22:33:13 +00:00
|
|
|
import { describe, test, expect } from "vitest";
|
2022-09-24 19:33:38 +00:00
|
|
|
import { titlecase, capitalize, truncate } from ".";
|
|
|
|
|
|
|
|
describe("title case tests", () => {
|
2022-09-25 22:33:13 +00:00
|
|
|
test("should return the same string if it's already title case", () => {
|
2022-09-24 19:33:38 +00:00
|
|
|
expect(titlecase("Hello World")).toBe("Hello World");
|
|
|
|
});
|
|
|
|
|
2022-09-25 22:33:13 +00:00
|
|
|
test("should title case a lower case word", () => {
|
2022-09-24 19:33:38 +00:00
|
|
|
expect(titlecase("hello")).toBe("Hello");
|
|
|
|
});
|
|
|
|
|
2022-09-25 22:33:13 +00:00
|
|
|
test("should title case a sentence", () => {
|
2022-09-24 19:33:38 +00:00
|
|
|
expect(titlecase("hello world")).toBe("Hello World");
|
|
|
|
});
|
|
|
|
|
2022-09-25 22:33:13 +00:00
|
|
|
test("should title case a sentence with multiple words", () => {
|
2022-09-24 19:33:38 +00:00
|
|
|
expect(titlecase("hello world this is a test")).toBe("Hello World This Is A Test");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe("capitilize tests", () => {
|
2022-09-25 22:33:13 +00:00
|
|
|
test("should return the same string if it's already capitalized", () => {
|
2022-09-24 19:33:38 +00:00
|
|
|
expect(capitalize("Hello")).toBe("Hello");
|
|
|
|
});
|
|
|
|
|
2022-09-25 22:33:13 +00:00
|
|
|
test("should capitalize a lower case word", () => {
|
2022-09-24 19:33:38 +00:00
|
|
|
expect(capitalize("hello")).toBe("Hello");
|
|
|
|
});
|
|
|
|
|
2022-09-25 22:33:13 +00:00
|
|
|
test("should capitalize a sentence", () => {
|
2022-09-24 19:33:38 +00:00
|
|
|
expect(capitalize("hello world")).toBe("Hello world");
|
|
|
|
});
|
|
|
|
|
2022-09-25 22:33:13 +00:00
|
|
|
test("should capitalize a sentence with multiple words", () => {
|
2022-09-24 19:33:38 +00:00
|
|
|
expect(capitalize("hello world this is a test")).toBe("Hello world this is a test");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe("truncase tests", () => {
|
2022-09-25 22:33:13 +00:00
|
|
|
test("should return the same string if it's already truncated", () => {
|
2022-09-24 19:33:38 +00:00
|
|
|
expect(truncate("Hello", 5)).toBe("Hello");
|
|
|
|
});
|
|
|
|
|
2022-09-25 22:33:13 +00:00
|
|
|
test("should truncate a lower case word", () => {
|
2022-09-24 19:33:38 +00:00
|
|
|
expect(truncate("hello", 3)).toBe("hel...");
|
|
|
|
});
|
|
|
|
|
2022-09-25 22:33:13 +00:00
|
|
|
test("should truncate a sentence", () => {
|
2022-09-24 19:33:38 +00:00
|
|
|
expect(truncate("hello world", 5)).toBe("hello...");
|
|
|
|
});
|
|
|
|
|
2022-09-25 22:33:13 +00:00
|
|
|
test("should truncate a sentence with multiple words", () => {
|
2022-09-24 19:33:38 +00:00
|
|
|
expect(truncate("hello world this is a test", 10)).toBe("hello worl...");
|
|
|
|
});
|
|
|
|
});
|