This repository has been archived by the owner on Feb 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
endpoints.test.js
59 lines (55 loc) · 2.05 KB
/
endpoints.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
const endpoints = require("./endpoints.js");
const camel = endpoints.fromNameToCamelized;
const pascal = endpoints.fromNameToPascal;
const stub = endpoints.fromNameToStub;
describe("fromNameToCamelized", () => {
it("single word example", () => {
expect(camel("EXAMPLE")).toEqual("example")
});
it("multi word example", () => {
expect(camel("Coordination Issue Recycle Bin")).toEqual("coordinationIssueRecycleBin");
});
it("remove underscores", () => {
expect(camel("Submittal_Logs")).toEqual("submittalLogs");
});
it("removes parentheses", () => {
expect(camel("Line Item Types (Cost Types)")).toEqual("lineItemTypesCostTypes");
});
it("removes hyphens", () => {
expect(camel("Managed Equipment - Company Level")).toEqual("managedEquipmentCompanyLevel");
});
});
describe("fromNameToPascal", () => {
it("single word example", () => {
expect(pascal("EXAMPLE")).toEqual("Example")
});
it("multi word example", () => {
expect(pascal("Coordination Issue Recycle Bin")).toEqual("CoordinationIssueRecycleBin");
});
it("remove underscores", () => {
expect(pascal("Submittal_Logs")).toEqual("SubmittalLogs");
});
it("removes parentheses", () => {
expect(pascal("Line Item Types (Cost Types)")).toEqual("LineItemTypesCostTypes");
});
it("removes hyphens", () => {
expect(pascal("Managed Equipment - Company Level")).toEqual("ManagedEquipmentCompanyLevel");
});
});
describe("fromNameToStub", () => {
it("lowercases names", () => {
expect(stub("EXAMPLE")).toEqual("example")
});
it("leaves snake case as snake case", () => {
expect(stub("Submittal_Logs")).toEqual("submittal_logs");
});
it("replaces spaces with hyphens", () => {
expect(stub("Coordination Issue Recycle Bin")).toEqual("coordination-issue-recycle-bin");
});
it("removes parentheses", () => {
expect(stub("Line Item Types (Cost Types)")).toEqual("line-item-types-cost-types");
});
it("keeps hyphen seperator", () => {
expect(stub("Managed Equipment - Company Level")).toEqual("managed-equipment---company-level");
});
});