File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -34,9 +34,15 @@ export default function createFieldsTest(
3434 const fieldByProperty = ( ipos_for_probing . myField as any ) . __original ?? ipos_for_probing . myField
3535 const fieldByFunction = ( ipos_for_probing . get ( 'myField' ) as any ) . __original ?? ipos_for_probing . get ( 'myField' )
3636
37- // lodash equal to compare maps and sets
38- expect ( _ . isEqualWith ( fieldByProperty , value , customizer ) ) . toEqual ( true )
39- expect ( _ . isEqualWith ( fieldByFunction , value , customizer ) ) . toEqual ( true )
37+ // some objects cannot be "the same" (e.g. instances not holding data)
38+ if ( [ EventTarget ] . some ( type => value instanceof type ) ) {
39+ expect ( fieldByProperty . constructor === value . constructor ) . toBe ( true )
40+ expect ( fieldByFunction . constructor === value . constructor ) . toBe ( true )
41+ } else {
42+ // lodash equal to compare maps and sets
43+ expect ( _ . isEqualWith ( fieldByProperty , value , customizer ) ) . toEqual ( true )
44+ expect ( _ . isEqualWith ( fieldByFunction , value , customizer ) ) . toEqual ( true )
45+ }
4046 }
4147 )
4248 } )
Original file line number Diff line number Diff line change @@ -32,7 +32,8 @@ export const examples = {
3232 } ) ) ,
3333 'set' : new Set ( [ 'myItem' , 42 ] ) ,
3434 'function' : ( a : number , b : number ) => a + b ,
35- 'class' : new TestClass ( 'myClass' )
35+ 'class' : new TestClass ( 'myClass' ) ,
36+ 'eventTarget' : new EventTarget ( ) ,
3637}
3738
3839// exemplary; don't iterate every possible method, just do one direct value assignment and one method
You can’t perform that action at this time.
0 commit comments