Skip to content
Merged
Show file tree
Hide file tree
Changes from 131 commits
Commits
Show all changes
141 commits
Select commit Hold shift + click to select a range
40a6714
Normalize enum key name
MaryGao Sep 25, 2024
3bd2ec2
Update the enum name
MaryGao Sep 25, 2024
740f6ee
Merge to the latest main
MaryGao Oct 23, 2024
30ec2bc
Merge remote-tracking branch 'origin/main' into pr/MaryGao/2839
MaryGao Oct 23, 2024
8b92d22
Update the enum key after merging to main
MaryGao Oct 23, 2024
e5b97f3
Update the api view
MaryGao Oct 23, 2024
849eec1
Update the UT cases
MaryGao Oct 24, 2024
aed78af
Merge branch 'main' into enum-key-name-norm
MaryGao Oct 30, 2024
025ec54
Revert un-necessary autorest changes
MaryGao Oct 30, 2024
96ce453
Refresh the integration testing for cadl-ranch
MaryGao Oct 30, 2024
898dd1c
Update smoke testings
MaryGao Oct 30, 2024
73ed758
Update smoke testings
MaryGao Oct 31, 2024
434d615
Remove useless codes
MaryGao Oct 31, 2024
994156c
Push un-necessary changes
MaryGao Oct 31, 2024
ce76162
Refactor useless codes
MaryGao Oct 31, 2024
30aa597
fix ci RLC generation
v-jiaodi Oct 31, 2024
5489ed9
Fix the failure cases
MaryGao Oct 31, 2024
e650058
regen smoke
v-jiaodi Oct 31, 2024
3594c8c
update unit test
v-jiaodi Oct 31, 2024
1f3f77a
Fix the autorest issue
MaryGao Oct 31, 2024
dc36cfd
fix rlc generation
v-jiaodi Oct 31, 2024
5fcfe91
Merge branch 'main' into enum-key-name-norm
MaryGao Nov 5, 2024
6dbe044
Add test cases
MaryGao Nov 6, 2024
05d60c6
Fix the ci issues
MaryGao Nov 6, 2024
e576e32
Update the main branch
MaryGao Nov 12, 2024
5a08286
Merge branch 'main' into pr/MaryGao/2839
MaryGao Nov 12, 2024
4938ea5
Fix the host name issue
MaryGao Nov 12, 2024
18d1ba3
Update the ignoreEnumMemberNameNormalize feature
MaryGao Nov 12, 2024
57bad0f
Update the package.json library name
MaryGao Nov 12, 2024
2e2f76d
Update the smoke test
MaryGao Nov 12, 2024
f6d8149
Format rlc-common types
MaryGao Nov 12, 2024
177b942
Fix lint issue
MaryGao Nov 12, 2024
65a55ae
Update the test cases
MaryGao Nov 12, 2024
bedc279
Fix the issue in autorest typescript repo
MaryGao Nov 12, 2024
ba3fbed
Update the load test smoke
MaryGao Nov 12, 2024
7d82484
Update the spec
MaryGao Nov 12, 2024
d9005b0
Fix the name issue in restore poller
MaryGao Nov 12, 2024
4b27213
regen smoke test
v-jiaodi Nov 12, 2024
1e750cd
Update the modular integration
MaryGao Nov 12, 2024
4d8cdf1
Merge branch 'enum-key-name-norm' of https://github.com/marygao/autor…
MaryGao Nov 12, 2024
322d1bd
Update the integration test
MaryGao Nov 12, 2024
7f1cbfa
Fix the modular UTs
MaryGao Nov 12, 2024
99c0a70
Update the test cases
MaryGao Nov 13, 2024
c6def9f
Update the UTs
MaryGao Nov 13, 2024
81d3d75
Update the test cases
MaryGao Nov 13, 2024
56f0598
Merge remote-tracking branch 'origin/main' into enum-key-name-norm
MaryGao Nov 14, 2024
d2353bc
Resolve conflicts
MaryGao Nov 14, 2024
64495b7
Update UTs
MaryGao Nov 14, 2024
5d49852
fix ci
v-jiaodi Nov 15, 2024
eb90494
Merge branch 'main' into enum-key-name-norm
MaryGao Nov 19, 2024
c064ec5
Improve the normalization algo for number and upper cases
MaryGao Nov 19, 2024
0d50e1e
Revert the change and update the codegen
MaryGao Nov 19, 2024
b9874d3
Update the format
MaryGao Nov 19, 2024
6029c41
Revert the breaking changes
MaryGao Nov 19, 2024
406ce02
Revert un-necessary changes
MaryGao Nov 19, 2024
4a5481b
Update the integration for rlc and modular
MaryGao Nov 19, 2024
dc7c870
Update the lint issues
MaryGao Nov 20, 2024
68bbb1c
Update the autorest smoke testing
MaryGao Nov 20, 2024
24527c6
Push rename file changes
MaryGao Nov 20, 2024
f4f07ad
Update the file name changes
MaryGao Nov 20, 2024
815b7dc
Update the normalize style
MaryGao Nov 20, 2024
690b921
Update the smoek test
MaryGao Nov 20, 2024
8a92de3
fix ci
v-jiaodi Nov 20, 2024
d7c1d61
update
v-jiaodi Nov 20, 2024
6139fe6
update
v-jiaodi Nov 20, 2024
4ab4e88
update
v-jiaodi Nov 20, 2024
7a01172
update dpgName
v-jiaodi Nov 20, 2024
cfd75a0
update dpgName
v-jiaodi Nov 20, 2024
75b3b63
Update the autorest cases in HLC
MaryGao Nov 20, 2024
4d4ae20
Merge remote-tracking branch 'mary/enum-key-name-norm' into pr/MaryGa…
MaryGao Nov 20, 2024
64afca5
Update the int test
MaryGao Nov 20, 2024
e2bedaa
Merge branch 'main' into enum-key-name-norm
MaryGao Nov 20, 2024
ec92f0b
fix ci
v-jiaodi Nov 20, 2024
1e7a7b6
Improve with number for prefix and suffix
MaryGao Nov 21, 2024
4379f99
fix ci
v-jiaodi Nov 21, 2024
541ab72
fix modular ut test
v-jiaodi Nov 21, 2024
5f8efcb
update modular ut case
v-jiaodi Nov 21, 2024
d7b302c
fix ci
v-jiaodi Nov 21, 2024
b7c2a83
Merge pull request #50 from v-jiaodi/test1121
MaryGao Nov 21, 2024
ce65b44
Update the logic only working for non interface like type
MaryGao Nov 21, 2024
cc8227d
Update the enum list
MaryGao Nov 21, 2024
1d31df2
Update the enum list
MaryGao Nov 21, 2024
c0abf84
Update the test cases
MaryGao Nov 21, 2024
ae5d155
Merge branch 'main' into enum-key-name-norm
MaryGao Nov 21, 2024
b2ac3d2
fix ci
v-jiaodi Nov 22, 2024
335dbea
Merge branch 'enum-key-name-norm' of https://github.com/MaryGao/autor…
v-jiaodi Nov 22, 2024
9580d6e
fix ci
v-jiaodi Nov 22, 2024
ea07e67
Merge branch 'main' into enum-key-name-norm
MaryGao Nov 22, 2024
f1ff320
Merge branch 'main' of https://github.com/Azure/autorest.typescript i…
v-jiaodi Nov 22, 2024
4f40117
merge main
kazrael2119 Dec 11, 2024
c104234
merge to the latest main
MaryGao Jan 2, 2025
3a2fcd4
Merge remote-tracking branch 'origin/main' into enum-key-name-norm
MaryGao Jan 2, 2025
cab3694
update tsp
v-jiaodi Jan 2, 2025
29aff5a
Fix the duplicated template name issues
MaryGao Jan 2, 2025
03bd972
Merge branch 'enum-key-name-norm' of https://github.com/MARYGAO/autor…
MaryGao Jan 2, 2025
39fc763
Update the test cases in smoke testing
MaryGao Jan 2, 2025
1a4cf90
Revert the fix and split it into a new repo
MaryGao Jan 7, 2025
3c168ff
Update a dictionary to improve splitting words
MaryGao Jan 7, 2025
cfd6a24
Merge remote-tracking branch 'origin/main' into enum-key-name-norm
MaryGao Jan 7, 2025
a17750b
Revert word list changes
MaryGao Jan 7, 2025
cf01ad5
Revert the test cases
MaryGao Jan 7, 2025
9827649
Update the smoke test
MaryGao Jan 7, 2025
a8f8757
fix ci
kazrael2119 Jan 7, 2025
3a100be
Update modelsGenerator.spec.ts
kazrael2119 Jan 7, 2025
6dbeb37
fix ci
kazrael2119 Jan 8, 2025
80dee4d
Fix the failed UTs
MaryGao Jan 8, 2025
bf3d000
Update enumUnion.md
kazrael2119 Jan 8, 2025
a64819b
Update index.d.ts
kazrael2119 Jan 8, 2025
f809bbf
Merge to the latest main
MaryGao Jan 13, 2025
b1a50ed
Merge branch 'main' into enum-key-name-norm
MaryGao Jan 13, 2025
dddb5cb
Merge to the latest main
MaryGao Feb 19, 2025
cc21cad
Merge remote-tracking branch 'origin/main' into enum-key-name-norm
MaryGao Feb 19, 2025
727a83d
Merge remote-tracking branch 'origin/main' into enum-key-name-norm
MaryGao Feb 24, 2025
f5e5c4b
Update the autorest cases
MaryGao Feb 24, 2025
84c65bb
Merge branch 'enum-key-name-norm' of https://github.com/MARYGAO/autor…
MaryGao Feb 24, 2025
9fa611b
Merge remote-tracking branch 'origin/main' into enum-key-name-norm
MaryGao Mar 3, 2025
a3b86d4
Update the all test cases
MaryGao Mar 3, 2025
8494076
Revert change in operation renamings
MaryGao Mar 3, 2025
30a4efb
Add the option to allow ignore-enum-member-name-normalize
MaryGao Mar 3, 2025
8ad1ae3
Refresh the UTs and integration and smoke testings
MaryGao Mar 3, 2025
d99d380
Revert change in RLC swagger
MaryGao Mar 3, 2025
2fc48d6
Revert the change in launch.json
MaryGao Mar 3, 2025
323ddda
Update the useless changes
MaryGao Mar 3, 2025
a6e1257
Rename file to lower case one
MaryGao Mar 3, 2025
a595361
Rename file to lower case one
MaryGao Mar 3, 2025
29e0743
Update the version tolerance codes
MaryGao Mar 3, 2025
afd303d
Revert change in codes
MaryGao Mar 3, 2025
b6b2ac9
Update the file name to lower cases
MaryGao Mar 3, 2025
2498025
Remove wrongly added files
MaryGao Mar 3, 2025
7f562a7
Remove wrongly added files
MaryGao Mar 3, 2025
2ce3b62
Remove duplicated test cases
MaryGao Mar 3, 2025
845d3cc
Update packages/typespec-ts/test/unit/uriTemplate.spec.ts
MaryGao Mar 3, 2025
7c691e3
Update packages/typespec-ts/test/unit/uriTemplate.spec.ts
MaryGao Mar 3, 2025
ad611e7
Update the smoke test and integration and normalize operation name also
MaryGao Mar 3, 2025
be97198
Update the test cases for method name norm
MaryGao Mar 3, 2025
8f2fa14
Update the test cases for shouldn't report enum member diagnostic bec…
MaryGao Mar 3, 2025
3c7abf4
Fix the smoke testing
MaryGao Mar 3, 2025
813c5ea
Resolve comments
MaryGao Mar 3, 2025
8ee8777
Merge remote-tracking branch 'origin/main' into enum-key-name-norm
MaryGao Mar 5, 2025
23ea9a4
Merge to the latest main and resolve conflicts
MaryGao Mar 5, 2025
a05504d
Merge branch 'main' into enum-key-name-norm
MaryGao Mar 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"prefix": "package-version"
},
{
"path": "src/dPGCustomizationClient.ts",
"path": "src/dpgCustomizationClient.ts",
"prefix": "userAgentInfo"
}
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import DPGCustomizationClient from "./dPGCustomizationClient";
import DPGCustomizationClient from "./dpgCustomizationClient";

export * from "./dPGCustomizationClient";
export * from "./dpgCustomizationClient";
export * from "./parameters";
export * from "./responses";
export * from "./clientDefinitions";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import LRORestClient from "./lRORestClient";
import LRORestClient from "./lroRestClient";

export * from "./lRORestClient";
export * from "./lroRestClient";
export * from "./parameters";
export * from "./responses";
export * from "./clientDefinitions";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import DPGClient from "./dPGClient";
import DPGClient from "./dpgClient";

export * from "./dPGClient";
export * from "./dpgClient";
export * from "./parameters";
export * from "./responses";
export * from "./clientDefinitions";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import DPGClient from "./dPGClient";
import DPGClient from "./dpgClient";

export * from "./dPGClient";
export * from "./dpgClient";
export * from "./parameters";
export * from "./responses";
export * from "./clientDefinitions";
Expand Down
139 changes: 102 additions & 37 deletions packages/rlc-common/src/helpers/nameUtils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

export interface NormalizeNameOption {
shouldGuard?: boolean;
customReservedNames?: ReservedName[];
casingOverride?: CasingConvention;
numberPrefixOverride?: string;
}

export interface ReservedName {
name: string;
reservedFor: NameType[];
Expand All @@ -14,7 +21,8 @@ export enum NameType {
Parameter,
Operation,
OperationGroup,
Method
Method,
EnumMemberName
}

const Newable = [NameType.Class, NameType.Interface, NameType.OperationGroup];
Expand Down Expand Up @@ -135,39 +143,103 @@ export function normalizeName(
name: string,
nameType: NameType,
shouldGuard?: boolean,
customReservedNames: ReservedName[] = [],
customReservedNames?: ReservedName[],
casingOverride?: CasingConvention
): string;
export function normalizeName(
name: string,
nameType: NameType,
options?: NormalizeNameOption
): string;
export function normalizeName(
name: string,
nameType: NameType,
optionsOrShouldGuard?: NormalizeNameOption | boolean,
optionalCustomReservedNames?: ReservedName[],
optionalCasingOverride?: CasingConvention
): string {
let shouldGuard: boolean | undefined,
customReservedNames: ReservedName[],
casingOverride: CasingConvention | undefined,
numberPrefixOverride: string | undefined;
if (typeof optionsOrShouldGuard === "boolean") {
shouldGuard = optionsOrShouldGuard;
customReservedNames = optionalCustomReservedNames ?? [];
casingOverride = optionalCasingOverride;
} else {
shouldGuard = optionsOrShouldGuard?.shouldGuard;
customReservedNames = optionsOrShouldGuard?.customReservedNames ?? [];
casingOverride = optionsOrShouldGuard?.casingOverride;
numberPrefixOverride = optionsOrShouldGuard?.numberPrefixOverride;
}
if (name.startsWith("$DO_NOT_NORMALIZE$")) {
return name.replace("$DO_NOT_NORMALIZE$", "");
}
const casingConvention = casingOverride ?? getCasingConvention(nameType);
const sanitizedName = sanitizeName(name);
const parts = getNameParts(sanitizedName);
const parts = deconstruct(name);
if (parts.length === 0) {
return name;
}
const [firstPart, ...otherParts] = parts;
const normalizedFirstPart = toCasing(firstPart, casingConvention);
const normalizedFirstPart = toCasing(firstPart, casingConvention, true);
const normalizedParts = (otherParts || [])
.map((part) =>
part === "null" ? part : toCasing(part, CasingConvention.Pascal)
)
.map((part) => toCasing(part, CasingConvention.Pascal))
.join("");

const normalized = checkBeginning(`${normalizedFirstPart}${normalizedParts}`);
return shouldGuard
const normalized = `${normalizedFirstPart}${normalizedParts}`;
const result = shouldGuard
? guardReservedNames(normalized, nameType, customReservedNames)
: normalized;
return fixLeadingNumber(result, nameType, numberPrefixOverride);
}

function checkBeginning(name: string): string {
if (name.startsWith("@")) {
return name.substring(1);
export function fixLeadingNumber(
name: string,
nameType: NameType,
prefix: string = "_"
): string {
const casingConvention = getCasingConvention(nameType);
if (!name || !name.match(/^[-.]?\d/)) {
return name;
}
return name;
return `${toCasing(prefix, casingConvention)}${name}`;
}

function sanitizeName(name: string): string {
// Remove [, ], \, " and ' from name string
return name.replace(/["'\\[\]]+/g, "");
function isFullyUpperCase(
identifier: string,
maxUppercasePreserve: number = 3
) {
const len = identifier.length;
if (len > 1) {
if (
len <= maxUppercasePreserve &&
identifier === identifier.toUpperCase()
) {
return true;
}

if (len <= maxUppercasePreserve + 1 && identifier.endsWith("s")) {
const i = identifier.substring(0, len - 1);
if (i.toUpperCase() === i) {
return true;
}
}
}
return false;
}

function deconstruct(identifier: string): Array<string> {
return `${identifier}`
.replace(/([a-z]+)([A-Z])/g, "$1 $2") // Add a space in between camelCase words(e.g. fooBar => foo Bar)
.replace(/(\d+)/g, " $1 ") // Adds a space after numbers(e.g. foo123Bar => foo123 bar)
.replace(/_/g, " ") // Replace underscores with spaces
.replace(/\b([A-Z]+)([A-Z])s([^a-z])(.*)/g, "$1$2« $3$4") // Add a space after a plural upper cased word(e.g. MBsFoo => MBs Foo)
.replace(/\b([A-Z]+)([A-Z])([a-z]+)/g, "$1 $2$3") // Add a space between an upper case word(2 char+) and the last captial case.(e.g. SQLConnection -> SQL Connection)
.replace(/«/g, "s")
.trim()
.split(/[\W|_]+/)
.map((each) => (isFullyUpperCase(each) ? each : each.toLowerCase()))
.filter((part) => !!part);
}

export function getModelsName(title: string): string {
Expand All @@ -185,6 +257,7 @@ function getCasingConvention(nameType: NameType) {
case NameType.Class:
case NameType.Interface:
case NameType.OperationGroup:
case NameType.EnumMemberName:
return CasingConvention.Pascal;
case NameType.File:
case NameType.Property:
Expand All @@ -195,28 +268,20 @@ function getCasingConvention(nameType: NameType) {
}
}

/**
* TODO: Improve this function to handle cases such as TEST -> test. Current basic implementation
* results in TEST -> test or Test (depending on the CasingConvention). We should switch to relay
* on Modeler four namer for this once it is stable
*/
function toCasing(str: string, casing: CasingConvention): string {
let value = str;
if (value === value.toUpperCase()) {
value = str.toLowerCase();
}

function toCasing(
str: string,
casing: CasingConvention,
keepConsistent = false
): string {
const firstChar =
casing === CasingConvention.Pascal
? value.charAt(0).toUpperCase()
: value.charAt(0).toLowerCase();
return `${firstChar}${value.substring(1)}`;
}

function getNameParts(name: string) {
const parts = name.split(/[-._ ]+/).filter((part) => part.trim().length > 0);

return parts.length > 0 ? parts : [name];
? str.charAt(0).toUpperCase()
: str.charAt(0).toLowerCase();
const allLowerCases =
casing !== CasingConvention.Pascal &&
keepConsistent &&
str.toUpperCase() === str;
return allLowerCases ? str.toLowerCase() : `${firstChar}${str.substring(1)}`;
}

export function pascalCase(str: string) {
Expand Down
1 change: 1 addition & 0 deletions packages/rlc-common/src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ export interface RLCOptions {
experimentalExtensibleEnums?: boolean;
clearOutputFolder?: boolean;
ignorePropertyNameNormalize?: boolean;
ignoreEnumMemberNameNormalize?: boolean;
compatibilityQueryMultiFormat?: boolean;
typespecTitleMap?: Record<string, string>;
}
Expand Down
110 changes: 92 additions & 18 deletions packages/rlc-common/test/helpers/nameUtils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,93 @@ import "mocha";
import { NameType, normalizeName } from "../../src/helpers/nameUtils.js";

describe("#normalizeName", () => {
describe("general cases", () => {
describe("Step 1 - split words", () => {
it("should use uppercase words", () => {
expect(normalizeName("someSQLConnection", NameType.EnumMemberName)).to.equal(
"SomeSQLConnection"
);
});
it("should use special chars to help split", () => {
expect(normalizeName("pascal_case", NameType.EnumMemberName)).to.equal(
"PascalCase"
);
expect(normalizeName("pascal case", NameType.EnumMemberName)).to.equal(
"PascalCase"
);
expect(normalizeName("pascal/case", NameType.EnumMemberName)).to.equal(
"PascalCase"
);
});
it("should split a plural upper cased word correctly", () => {
expect(normalizeName("diskMBpsReadWrite", NameType.EnumMemberName)).to.equal(
"DiskMBpsReadWrite"
);
expect(
normalizeName("LRORetrysPost", NameType.OperationGroup,)
).to.equal("LRORetrysPost");
expect(
normalizeName("_LRORetrysPost", NameType.OperationGroup,)
).to.equal("LRORetrysPost");
});

it("should limit the charset to alphanumeric characters", () => {
expect(normalizeName("R-10Min", NameType.EnumMemberName)).to.equal("R10Min");
expect(normalizeName("___pascal____case6666", NameType.EnumMemberName)).to.equal("PascalCase6666");
expect(normalizeName("system,user", NameType.EnumMemberName)).to.equal("SystemUser");
expect(normalizeName("x86_64_mac", NameType.EnumMemberName)).to.equal("X8664Mac");
expect(normalizeName("size256x256", NameType.EnumMemberName)).to.equal("Size256X256");
});
});
describe("Step 2 - convert words", () => {
it("should convert to lowercases if lex > 3 for full upper-case words", () => {
expect(normalizeName("V", NameType.EnumMemberName)).to.equal("V");
expect(normalizeName("VA", NameType.EnumMemberName)).to.equal("VA");
expect(normalizeName("VAL", NameType.EnumMemberName)).to.equal("VAL");
expect(normalizeName("VALI", NameType.EnumMemberName)).to.equal("Vali");
expect(normalizeName("VALID", NameType.EnumMemberName)).to.equal("Valid");
});
it("should add underscore _ for the first leading number", () => {
expect(normalizeName("10Min", NameType.EnumMemberName)).to.equal("_10Min");
expect(normalizeName("-1.0Min", NameType.EnumMemberName)).to.equal("_10Min");
});
});

describe("Step 3 - to target casing", () => {
it("should keep whole upper case for enum member", () => {
expect(normalizeName("SAS_AUTHENTICATION_IP", NameType.EnumMemberName)).to.equal("SASAuthenticationIP");
});
it("should keep whole lower case for property", () => {
expect(normalizeName("SAS_AUTHENTICATION_IP", NameType.Property)).to.equal("sasAuthenticationIP");
});
});

describe("$DO_NOT_NORMALIZE", () => {
it("should keep the whole name if it starts with $DO_NOT_NORMALIZE$", () => {
expect(normalizeName("$DO_NOT_NORMALIZE$VALIDATION_NOT_REQUIRED", NameType.EnumMemberName)).to.equal("VALIDATION_NOT_REQUIRED");
});

});
});
describe("for enum member name", () => {
it("should handle pure numeric", () => {
expect(normalizeName("10", NameType.EnumMemberName)).to.equal("_10");
});
it("should handle api-version enums as normal enum", () => {
expect(normalizeName("V1.1", NameType.EnumMemberName)).to.equal("V11");
expect(normalizeName("2024-07-01-preview ", NameType.EnumMemberName)).to.equal("_20240701Preview");
});
});
describe("for property", () => {
it("should remove $ char", () => {
expect(normalizeName("$select", NameType.Property)).to.equal(
"select"
);
expect(normalizeName("hate/threatening", NameType.Property)).to.equal(
"hateThreatening"
);
});
Comment thread
MaryGao marked this conversation as resolved.
});
describe("for parameter", () => {
it("should return the name with the suffix 'Param' if the name is a reserved name", () => {
expect(normalizeName("static", NameType.Parameter, true)).to.equal(
Expand All @@ -11,34 +98,21 @@ describe("#normalizeName", () => {
expect(normalizeName("any", NameType.Parameter, true)).to.equal(
"anyParam"
);
});

it("should normalize the name with camel case", () => {
expect(normalizeName("API_KEY", NameType.Parameter, true)).to.equal(
"apiKey"
);
expect(normalizeName("SAS", NameType.Parameter)).to.equal("sas");
});
});

describe("for operation", () => {
it("should return the name with the suffix 'Operation' if the name is a reserved name", () => {
expect(normalizeName("export", NameType.Operation, true)).to.equal(
expect(normalizeName("export", NameType.Operation,)).to.equal(
"export"
);
});

it("should normalize the name with camel case", () => {
expect(
normalizeName("create_ wideget", NameType.Parameter, true)
).to.equal("createWideget");
});
});

describe("for operation group", () => {
it("should normalize the name with pasel case", () => {
it("should normalize the name", () => {
expect(
normalizeName("LoadTest_Administration ", NameType.OperationGroup, true)
).to.equal("LoadTestAdministration");
normalizeName("create_ widget", NameType.Parameter,)
).to.equal("createWidget");
});
});
});
Loading