Skip to content
This repository was archived by the owner on Dec 30, 2023. It is now read-only.

Commit 645ec95

Browse files
committed
fix(packages/test/unit): 🐛 Resolve issues print format
1 parent 2a4f017 commit 645ec95

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

packages/test/source/emoji/emoji.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ export const BUILT_IN_OBJECTS_EMOJIS = {
6565
FinalizationRegistry: `❔`,
6666
// Control abstraction
6767
Promise: `❔`,
68-
// GeneratorFunction: `❔`,
69-
// AsyncGeneratorFunction: `❔`,
70-
// Generator: `❔`,
68+
AsyncFunction: `❔`,
69+
AsyncGeneratorFunction: `❔`,
70+
GeneratorFunction: `❔`,
7171
// AsyncGenerator: `❔`,
72-
// AsyncFunction: `❔`,
72+
// Generator: `❔`,
7373
// Reflection
7474
Reflect: `❔`,
7575
Proxy: `❔`,

packages/test/source/unit/unit.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ String.prototype.sample = function (value: unknown): string {
3030
/* eslint-disable unicorn/switch-case-braces */
3131
case "bigint": return `${this}: ${value}n`;
3232
case "boolean": return `${this}: ${value}`;
33-
case "function": return `${this}: ${value.name}()`;
33+
case "function": return `${this}: ${value.toString()}`;
3434
case "number": return `${this}: ${value}`;
3535
case "object": {
3636
const stringified = value ? value.toString() : `null`;
@@ -67,6 +67,7 @@ function getFormattedPrimitiveValue(value: unknown): string {
6767
/* eslint-disable unicorn/switch-case-braces */
6868
case "bigint": return `${value}n`;
6969
case "boolean": return `${value}`;
70+
case "function": return `${value.toString()}`;
7071
case "number": return `${value}`;
7172
case "string": return `"${value}"`;
7273
case "symbol": return `"${value.toString()}"`;
@@ -97,7 +98,15 @@ function stringifyValue(value: unknown, valueType: string): string | undefined {
9798
}
9899

99100
function jsonReplacer(_key: string, value: unknown) {
100-
return typeof value === "bigint" ? `${value.toString()}n` : value;
101+
/* prettier-ignore */
102+
switch(typeof value) {
103+
/* eslint-disable unicorn/switch-case-braces */
104+
case "bigint": return `${value.toString()}n`;
105+
case "function": return value.toString();
106+
case "undefined": return `undefined`;
107+
default: return value;
108+
/* eslint-enable unicorn/switch-case-braces */
109+
}
101110
}
102111

103112
function getStringifiedAndTruncatedArray(array: Array<unknown>): string {

0 commit comments

Comments
 (0)