mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2025-11-17 10:11:31 +10:00
This commit is contained in:
@ -30,17 +30,6 @@ export const extractUrl = (string: string) => {
|
||||
return result ? result[0] : null;
|
||||
};
|
||||
|
||||
export const kebabCase = (string?: string | null) => {
|
||||
if (!string) return "";
|
||||
|
||||
return (
|
||||
string
|
||||
.match(/[A-Z]{2,}(?=[A-Z][a-z]+\d*|\b)|[A-Z]?[a-z]+\d*|[A-Z]|\d+/gu)
|
||||
?.join("-")
|
||||
.toLowerCase() ?? ""
|
||||
);
|
||||
};
|
||||
|
||||
export const generateRandomName = () => {
|
||||
return uniqueNamesGenerator({
|
||||
dictionaries: [adjectives, adjectives, animals],
|
||||
|
||||
@ -6,7 +6,6 @@ import {
|
||||
getInitials,
|
||||
isEmptyString,
|
||||
isUrl,
|
||||
kebabCase,
|
||||
processUsername,
|
||||
} from "../string";
|
||||
|
||||
@ -40,16 +39,6 @@ describe("extractUrl", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("kebabCase", () => {
|
||||
it("converts a string to kebab-case", () => {
|
||||
expect(kebabCase("fooBar")).toBe("foo-bar");
|
||||
expect(kebabCase("Foo Bar")).toBe("foo-bar");
|
||||
expect(kebabCase("foo_bar")).toBe("foo-bar");
|
||||
expect(kebabCase("")).toBe("");
|
||||
expect(kebabCase(null)).toBe("");
|
||||
});
|
||||
});
|
||||
|
||||
describe("generateRandomName", () => {
|
||||
it("generates a random name", () => {
|
||||
const name = generateRandomName();
|
||||
|
||||
Reference in New Issue
Block a user