From fcbdf0051d390fc7bafc5d9177a5534cc70e06cb Mon Sep 17 00:00:00 2001 From: Mikhail Ivanov Date: Sat, 4 Nov 2023 16:33:25 +0000 Subject: [PATCH] beauty assert json --- assert/assert.test.ts | 8 ++++++++ assert/assert.ts | 2 +- assert/demo/demo.view.tree | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/assert/assert.test.ts b/assert/assert.test.ts index ed529b857d8..4a4e2db1598 100644 --- a/assert/assert.test.ts +++ b/assert/assert.test.ts @@ -32,6 +32,14 @@ namespace $ { 'three must be alike'() { $mol_assert_like( [ 3 ] , [ 3 ] , [ 3 ] ) } , + + 'two object must be alike'() { + $mol_assert_like( { a: 1 }, { a: 1 } ) + } , + + 'three object must be alike'() { + $mol_assert_like( { a: 1 }, { a: 1 }, { a: 1 } ) + } , } ) } diff --git a/assert/assert.ts b/assert/assert.ts index 6c2351a3c3c..89f5231bf83 100644 --- a/assert/assert.ts +++ b/assert/assert.ts @@ -116,7 +116,7 @@ namespace $ { if( 'outerHTML' in val ) return val.outerHTML try { - return JSON.stringify( val ) + return JSON.stringify( val, null, '\t' ) } catch( error: any ) { console.error( error ) return val diff --git a/assert/demo/demo.view.tree b/assert/demo/demo.view.tree index c2a9123f113..0db233edbe9 100644 --- a/assert/demo/demo.view.tree +++ b/assert/demo/demo.view.tree @@ -3,6 +3,7 @@ $mol_assert_demo $mol_example_code \$mol_assert_unique( 1 , 2 , 3 ) \$mol_assert_equal( 1 , 1 , 1 ) \$mol_assert_like( [1] , [1] , [1] ) + \$mol_assert_like( { a: 1 } , { a: 1 } , { a: 1 } ) aspects / \Algorithm/Assert \Testing