11import { inspect } from 'util'
2- import { ContextState } from " ./states/ContextState" ;
3- import { InitialState } from " ./states/InitialState" ;
4- import { HandlerKey } from " ./Substitute" ;
5- import { Type } from " ./Utilities" ;
6- import { SetPropertyState } from " ./states/SetPropertyState" ;
2+ import { ContextState } from ' ./states/ContextState' ;
3+ import { InitialState } from ' ./states/InitialState' ;
4+ import { HandlerKey } from ' ./Substitute' ;
5+ import { PropertyType } from ' ./Utilities' ;
6+ import { SetPropertyState } from ' ./states/SetPropertyState' ;
77import { SubstituteJS as SubstituteBase , SubstituteException } from './SubstituteBase'
88
99export class Context {
@@ -23,9 +23,9 @@ export class Context {
2323 this . _getState = this . _initialState ;
2424
2525 this . _proxy = new Proxy ( SubstituteBase , {
26- apply : ( _target , _this , args ) => this . apply ( _target , _this , args ) ,
27- set : ( _target , property , value ) => ( this . set ( _target , property , value ) , true ) ,
28- get : ( _target , property ) => this . _filterAndReturnProperty ( _target , property , this . get )
26+ apply : ( _target , _this , args ) => this . getStateApply ( _target , _this , args ) ,
27+ set : ( _target , property , value ) => ( this . setStateSet ( _target , property , value ) , true ) ,
28+ get : ( _target , property ) => this . _filterAndReturnProperty ( _target , property , this . getStateGet )
2929 } ) ;
3030
3131 this . _rootProxy = new Proxy ( SubstituteBase , {
@@ -36,19 +36,19 @@ export class Context {
3636
3737 this . _receivedProxy = new Proxy ( SubstituteBase , {
3838 apply : ( _target , _this , args ) => this . _receivedState === void 0 ? void 0 : this . _receivedState . apply ( this , args ) ,
39- set : ( _target , property , value ) => ( this . set ( _target , property , value ) , true ) ,
39+ set : ( _target , property , value ) => ( this . setStateSet ( _target , property , value ) , true ) ,
4040 get : ( _target , property ) => {
4141 const state = this . initialState . getPropertyStates . find ( getPropertyState => getPropertyState . property === property ) ;
4242 if ( state === void 0 ) return this . handleNotFoundState ( property ) ;
43- if ( ! state . functionState )
43+ if ( ! state . isFunctionState )
4444 state . get ( this , property ) ;
4545 this . _receivedState = state ;
4646 return this . receivedProxy ;
4747 }
4848 } ) ;
4949 }
5050
51- private _filterAndReturnProperty ( target : typeof SubstituteBase , property : PropertyKey , defaultGet : Context [ 'get' ] ) {
51+ private _filterAndReturnProperty ( target : typeof SubstituteBase , property : PropertyKey , getToExecute : ContextState [ 'get' ] ) {
5252 switch ( property ) {
5353 case 'constructor' :
5454 case 'valueOf' :
@@ -68,13 +68,13 @@ export class Context {
6868 return target . prototype [ Symbol . toStringTag ] ;
6969 default :
7070 target . prototype . lastRegisteredSubstituteJSMethodOrProperty = property . toString ( )
71- return defaultGet . bind ( this ) ( target , property ) ;
71+ return getToExecute . bind ( this ) ( target as any , property ) ;
7272 }
7373 }
7474
7575 private handleNotFoundState ( property : PropertyKey ) {
7676 if ( this . initialState . hasExpectations && this . initialState . expectedCount !== null ) {
77- this . initialState . assertCallCountMatchesExpectations ( [ ] , 0 , Type . property , property , [ ] ) ;
77+ this . initialState . assertCallCountMatchesExpectations ( [ ] , 0 , PropertyType . property , property , [ ] ) ;
7878 return this . receivedProxy ;
7979 }
8080 throw SubstituteException . forPropertyNotMocked ( property ) ;
@@ -84,15 +84,15 @@ export class Context {
8484 return this . initialState . get ( this , property ) ;
8585 }
8686
87- apply ( _target : any , _this : any , args : any [ ] ) {
87+ getStateApply ( _target : any , _this : any , args : any [ ] ) {
8888 return this . _getState . apply ( this , args ) ;
8989 }
9090
91- set ( _target : any , property : PropertyKey , value : any ) {
91+ setStateSet ( _target : any , property : PropertyKey , value : any ) {
9292 return this . _setState . set ( this , property , value ) ;
9393 }
9494
95- get ( _target : any , property : PropertyKey ) {
95+ getStateGet ( _target : any , property : PropertyKey ) {
9696 if ( property === HandlerKey ) {
9797 return this ;
9898 }
0 commit comments