-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: api reference switching issue (#1530)
- Loading branch information
1 parent
d87272f
commit aa0d005
Showing
30 changed files
with
850 additions
and
809 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
packages/commons/core-utils/src/__test__/unknownToString.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { unknownToString } from "../unknownToString"; | ||
|
||
describe("unknownToString", () => { | ||
it("should preserve strings", () => { | ||
expect(unknownToString("foo")).toBe("foo"); | ||
}); | ||
|
||
it("should convert booleans to strings", () => { | ||
expect(unknownToString(true)).toBe("true"); | ||
expect(unknownToString(false)).toBe("false"); | ||
}); | ||
|
||
it("should convert numbers to strings", () => { | ||
expect(unknownToString(42)).toBe("42"); | ||
expect(unknownToString(3.14)).toBe("3.14"); | ||
expect(unknownToString(1_000_000_000_000_000_000)).toBe("1000000000000000000"); | ||
}); | ||
|
||
it("should convert nulls", () => { | ||
expect(unknownToString(null)).toBe(""); | ||
expect(unknownToString(undefined)).toBe(""); | ||
expect(unknownToString(null, { renderNull: true })).toBe("null"); | ||
expect(unknownToString(undefined, { renderNull: true })).toBe("null"); | ||
}); | ||
|
||
it("should convert objects to JSON strings", () => { | ||
expect(unknownToString({ foo: "bar" })).toBe('{"foo":"bar"}'); | ||
}); | ||
|
||
it("should convert arrays to JSON strings", () => { | ||
expect(unknownToString([1, 2, 3])).toBe("[1,2,3]"); | ||
}); | ||
|
||
it("should not render functions", () => { | ||
// eslint-disable-next-line @typescript-eslint/no-empty-function | ||
expect(unknownToString(() => {})).toBe(""); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
interface Opts { | ||
renderNull?: boolean; | ||
} | ||
|
||
export function unknownToString(value: unknown, { renderNull = false }: Opts = {}): string { | ||
if (value == null || typeof value === "function") { | ||
return renderNull ? "null" : ""; | ||
} else if (typeof value === "string") { | ||
return value; | ||
} | ||
return JSON.stringify(value); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
packages/ui/app/src/api-reference/examples/stringifyHttpRequestExampleToCurl.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
packages/ui/app/src/playground/code-snippets/builders/common.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.