@qinglian/case-tool
Version:
a tool used to validate name case & translate
42 lines (41 loc) • 1.59 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const _1 = require(".");
describe("Name case tool Test", () => {
it("snake-case", () => {
const notSnakeCaseResult = (0, _1.isSnakeCase)("a-b");
expect(notSnakeCaseResult).toBeFalsy();
const isSnakeCaseResult = (0, _1.isSnakeCase)("a_b");
expect(isSnakeCaseResult).toBeTruthy();
});
it("camel-case", () => {
const notCamelCase = (0, _1.isCamelCase)("ABC");
expect(notCamelCase).toBeFalsy();
const isCamelCaseResult = (0, _1.isCamelCase)("aBcD");
expect(isCamelCaseResult).toBeTruthy();
});
it("kebab-case", () => {
const notKebabCase = (0, _1.isKebabCase)("a_b");
expect(notKebabCase).toBeFalsy();
const isKebabCaseResult = (0, _1.isKebabCase)("a-b-c");
expect(isKebabCaseResult).toBeTruthy();
});
it("pascal-case", () => {
const notPascalCase = (0, _1.isPascalCase)("abc");
expect(notPascalCase).toBeFalsy();
const isPascalCaseResult = (0, _1.isPascalCase)("AbcDef");
expect(isPascalCaseResult).toBeTruthy();
});
it("snakeToPascal test", () => {
const result = (0, _1.snakeToPascal)("user_name");
expect(result).toBe("UserName");
});
it("kebabToPascal test", () => {
const result = (0, _1.kebabToPascal)("user-name");
expect(result).toBe("UserName");
});
it("camelToPascal test", () => {
const result = (0, _1.camelToPascal)("userName");
expect(result).toBe("UserName");
});
});