summaryrefslogtreecommitdiff
path: root/js/console_test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'js/console_test.ts')
-rw-r--r--js/console_test.ts19
1 files changed, 18 insertions, 1 deletions
diff --git a/js/console_test.ts b/js/console_test.ts
index 94a627a5f..9e6a37256 100644
--- a/js/console_test.ts
+++ b/js/console_test.ts
@@ -68,7 +68,7 @@ test(function consoleTestStringifyCircular() {
nestedObj.o = circularObj;
- const nestedObjExpected = `{ num: 1, bool: true, str: "a", method: [Function: method], asyncMethod: [AsyncFunction: asyncMethod], generatorMethod: [GeneratorFunction: generatorMethod], un: undefined, nu: null, arrowFunc: [Function: arrowFunc], extendedClass: Extended { a: 1, b: 2 }, nFunc: [Function], extendedCstr: [Function: Extended], o: { num: 2, bool: false, str: "b", method: [Function: method], un: undefined, nu: null, nested: [Circular], emptyObj: {}, arr: [ 1, "s", false, null, [Circular] ], baseClass: Base { a: 1 } } }`;
+ const nestedObjExpected = `{ num: 1, bool: true, str: "a", method: [Function: method], asyncMethod: [AsyncFunction: asyncMethod], generatorMethod: [GeneratorFunction: generatorMethod], un: undefined, nu: null, arrowFunc: [Function: arrowFunc], extendedClass: Extended { a: 1, b: 2 }, nFunc: [Function], extendedCstr: [Function: Extended], o: { num: 2, bool: false, str: "b", method: [Function: method], un: undefined, nu: null, nested: [Circular], emptyObj: [object], arr: [object], baseClass: [object] } }`;
assertEqual(stringify(1), "1");
assertEqual(stringify("s"), "s");
@@ -92,6 +92,23 @@ test(function consoleTestStringifyCircular() {
);
});
+test(function consoleTestStringifyWithDepth() {
+ const nestedObj: any = { a: { b: { c: { d: { e: { f: 42 } } } } } };
+ assertEqual(
+ stringifyArgs([nestedObj], { depth: 3 }),
+ "{ a: { b: { c: [object] } } }"
+ );
+ assertEqual(
+ stringifyArgs([nestedObj], { depth: 4 }),
+ "{ a: { b: { c: { d: [object] } } } }"
+ );
+ assertEqual(stringifyArgs([nestedObj], { depth: 0 }), "[object]");
+ assertEqual(
+ stringifyArgs([nestedObj], { depth: null }),
+ "{ a: { b: [object] } }"
+ );
+});
+
test(function consoleTestError() {
class MyError extends Error {
constructor(msg: string) {