mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-20 09:20:16 +00:00
Fixed typescript strict issue of Statusbar, hostedUtils, StringUtils etc (#785)
This commit is contained in:
committed by
GitHub
parent
0bbf9de963
commit
397231dca2
@@ -3,27 +3,27 @@ import * as StringUtils from "./StringUtils";
|
||||
describe("StringUtils", () => {
|
||||
describe("stripSpacesFromString()", () => {
|
||||
it("should strip all spaces from input string", () => {
|
||||
const transformedString: string = StringUtils.stripSpacesFromString("a b c");
|
||||
const transformedString: string | undefined = StringUtils.stripSpacesFromString("a b c");
|
||||
expect(transformedString).toBe("abc");
|
||||
});
|
||||
|
||||
it("should return original string if input string has no spaces", () => {
|
||||
const transformedString: string = StringUtils.stripSpacesFromString("abc");
|
||||
const transformedString: string | undefined = StringUtils.stripSpacesFromString("abc");
|
||||
expect(transformedString).toBe("abc");
|
||||
});
|
||||
|
||||
it("should return undefined if input is undefined", () => {
|
||||
const transformedString: string = StringUtils.stripSpacesFromString(undefined);
|
||||
const transformedString: string | undefined = StringUtils.stripSpacesFromString(undefined);
|
||||
expect(transformedString).toBeUndefined();
|
||||
});
|
||||
|
||||
it("should return undefined if input is undefiend", () => {
|
||||
const transformedString: string = StringUtils.stripSpacesFromString(undefined);
|
||||
const transformedString: string | undefined = StringUtils.stripSpacesFromString(undefined);
|
||||
expect(transformedString).toBe(undefined);
|
||||
});
|
||||
|
||||
it("should return empty string if input is an empty string", () => {
|
||||
const transformedString: string = StringUtils.stripSpacesFromString("");
|
||||
const transformedString: string | undefined = StringUtils.stripSpacesFromString("");
|
||||
expect(transformedString).toBe("");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export function stripSpacesFromString(inputString: string): string {
|
||||
export function stripSpacesFromString(inputString?: string): string | undefined {
|
||||
if (inputString === undefined || typeof inputString !== "string") {
|
||||
return inputString;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user