@@ -691,27 +691,24 @@ class ModuleMockerClass {
691691 return object [ methodName ] ;
692692 }
693693
694- spyOnProperty ( object : any , propertyName : any , accessType = 'get' ) : any {
695- if ( typeof object !== 'object' && typeof object !== 'function' ) {
694+ spyOnProperty ( obj : any , propertyName : any , accessType : string = 'get' ) : any {
695+ if ( typeof obj !== 'object' && typeof obj !== 'function' ) {
696696 throw new Error (
697- 'Cannot spyOn on a primitive value; ' + this . _typeOf ( object ) + ' given' ,
697+ 'Cannot spyOn on a primitive value; ' + this . _typeOf ( obj ) + ' given' ,
698698 ) ;
699699 }
700700
701701 if ( ! obj ) {
702- throw new Error ( 'spyOn could not find an object to spy upon for ' + propertyName + '' ) ;
702+ throw new Error (
703+ 'spyOn could not find an object to spy upon for ' + propertyName + '' ,
704+ ) ;
703705 }
704706
705707 if ( ! propertyName ) {
706708 throw new Error ( 'No property name supplied' ) ;
707709 }
708710
709- let descriptor ;
710- try {
711- descriptor = Object . getOwnPropertyDescriptor ( obj , propertyName ) ;
712- } catch ( e ) {
713- // IE 8 doesn't support `definePropery` on non-DOM nodes
714- }
711+ const descriptor = Object . getOwnPropertyDescriptor ( obj , propertyName ) ;
715712
716713 if ( ! descriptor ) {
717714 throw new Error ( propertyName + ' property does not exist' ) ;
@@ -722,27 +719,29 @@ class ModuleMockerClass {
722719 }
723720
724721 if ( ! descriptor [ accessType ] ) {
725- throw new Error ( 'Property ' + propertyName + ' does not have access type ' + accessType ) ;
722+ throw new Error (
723+ 'Property ' + propertyName + ' does not have access type ' + accessType ,
724+ ) ;
726725 }
727726
728- const original = descriptor [ accessType ]
727+ const original = descriptor [ accessType ] ;
729728
730729 if ( ! this . isMockFunction ( original ) ) {
731730 if ( typeof original !== 'function' ) {
732731 throw new Error (
733732 'Cannot spy the ' +
734- methodName +
733+ propertyName +
735734 ' property because it is not a function; ' +
736735 this . _typeOf ( original ) +
737736 ' given instead' ,
738737 ) ;
739738 }
740739
741- descriptor [ accessType ] = this . _makeComponent ( { type : 'function' } , ( ) => {
740+ descriptor [ accessType ] = this . _makeComponent ( { type : 'function' } , ( ) => {
742741 descriptor [ accessType ] = original ;
743742 } ) ;
744743
745- descriptor [ accessType ] . mockImplementation ( function ( ) {
744+ descriptor [ accessType ] . mockImplementation ( function ( ) {
746745 return original . apply ( this , arguments ) ;
747746 } ) ;
748747 }
0 commit comments