File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed
Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ export const deepStrictAssert =
3333 if ( input instanceof Array ) {
3434 const elements = input . map ( ( element ) => {
3535 if ( first in element ) {
36- if ( typeof element [ first ] === 'object' && element [ first ] !== null ) {
36+ if ( typeof element [ first ] === 'object' && element [ first ] !== null && rest . length > 0 ) {
3737 return { [ first ] : traverse ( element [ first ] , rest ) } ;
3838 }
3939
@@ -46,7 +46,7 @@ export const deepStrictAssert =
4646 return elements ;
4747 } else {
4848 if ( first in input ) {
49- if ( typeof input [ first ] === 'object' && input [ first ] !== null ) {
49+ if ( typeof input [ first ] === 'object' && input [ first ] !== null && rest . length > 0 ) {
5050 return { [ first ] : traverse ( input [ first ] , rest ) } ;
5151 }
5252 return { [ first ] : input [ first ] } ;
Original file line number Diff line number Diff line change @@ -105,6 +105,14 @@ export function test_functions_deepStrictAssert_accesses_nested_object_property(
105105 typia . assertEquals ( deepStrictAssert ( original ) ( 'user.name' ) ) ;
106106}
107107
108+ /**
109+ * Tests that deepStrictAssert can access a top-level key whose value is a plain object.
110+ */
111+ export function test_functions_deepStrictAssert_accesses_top_level_object_property ( ) {
112+ const original = typia . random < SimpleNested > ( ) ;
113+ typia . assertEquals ( deepStrictAssert ( original ) ( 'user' ) ) ;
114+ }
115+
108116/**
109117 * Tests that deepStrictAssert throws when accessing a non-existent key.
110118 */
You can’t perform that action at this time.
0 commit comments