@@ -51,11 +51,15 @@ describe('LiveController parent -> child component tests', () => {
5151
5252 const parentComponent = test . component ;
5353 const childComponent = getComponent ( getByTestId ( test . element , 'child' ) ) ;
54+ // setting a marker to help verify THIS exact Component instance continues to be used
55+ childComponent . fingerprint = 'FOO-FINGERPRINT' ;
5456
5557 // check that the relationships all loaded correctly
5658 expect ( parentComponent . getChildren ( ) . size ) . toEqual ( 1 ) ;
57- expect ( parentComponent . getChildren ( ) . get ( 'the-child-id' ) ) . toEqual ( childComponent ) ;
58- expect ( childComponent . getParent ( ) ) . toEqual ( parentComponent ) ;
59+ // check fingerprint instead of checking object equality with childComponent
60+ // because childComponent is actually the proxied Component
61+ expect ( parentComponent . getChildren ( ) . get ( 'the-child-id' ) ?. fingerprint ) . toEqual ( 'FOO-FINGERPRINT' ) ;
62+ expect ( childComponent . getParent ( ) ) . toBe ( parentComponent ) ;
5963
6064 // remove the child
6165 childComponent . element . remove ( ) ;
@@ -66,7 +70,7 @@ describe('LiveController parent -> child component tests', () => {
6670 // now put it back!
6771 test . element . appendChild ( childComponent . element ) ;
6872 await waitFor ( ( ) => expect ( parentComponent . getChildren ( ) . size ) . toEqual ( 1 ) ) ;
69- expect ( parentComponent . getChildren ( ) . get ( 'the-child-id' ) ) . toEqual ( childComponent ) ;
73+ expect ( parentComponent . getChildren ( ) . get ( 'the-child-id' ) ?. fingerprint ) . toEqual ( 'FOO-FINGERPRINT' ) ;
7074 expect ( childComponent . getParent ( ) ) . toEqual ( parentComponent ) ;
7175
7276 // now remove the whole darn thing!
@@ -78,7 +82,7 @@ describe('LiveController parent -> child component tests', () => {
7882 // put it *all* back
7983 document . body . appendChild ( test . element ) ;
8084 await waitFor ( ( ) => expect ( parentComponent . getChildren ( ) . size ) . toEqual ( 1 ) ) ;
81- expect ( parentComponent . getChildren ( ) . get ( 'the-child-id' ) ) . toEqual ( childComponent ) ;
85+ expect ( parentComponent . getChildren ( ) . get ( 'the-child-id' ) ?. fingerprint ) . toEqual ( 'FOO-FINGERPRINT' ) ;
8286 expect ( childComponent . getParent ( ) ) . toEqual ( parentComponent ) ;
8387 } ) ;
8488
0 commit comments