@@ -6,7 +6,7 @@ import { SubstituteException } from './SubstituteException'
66import { is , stringify , transform } from './utilities'
77
88import { constants } from './Constants'
9- import type { SubstituteContext , PropertyType , SubstituteNodeModel , AccessorType , SubstituteMethod , SubstitutionMethod } from './Types'
9+ import type { SubstituteContext , PropertyType , SubstituteNodeModel , AccessorType , SubstituteMethod , SubstitutionMethod , AssertionMethod } from './Types'
1010import { constants as sharedConstants } from '../shared/Constants'
1111
1212
@@ -48,10 +48,12 @@ export class SubstituteNode extends SubstituteNodeBase implements ObjectSubstitu
4848
4949 const newNode = SubstituteNode . createChild ( property , target )
5050 if ( target . isAssertion ) newNode . executeAssertion ( )
51- if ( target . hasDepthOfAtLeast ( 1 ) && ! target . hasContext && is . method . assertion ( target . property ) ) {
51+ const unresolvedAssertionFollowedBySubstitution = ! target . hasContext && is . method . assertion ( target . property ) && ! is . method . substitution ( newNode . property )
52+ if ( target . hasDepthOfAtLeast ( 1 ) && unresolvedAssertionFollowedBySubstitution ) {
5253 target . assignContext ( target . property )
53- target [ target . property ] ( ...Array . isArray ( target . recordedArguments . value ) ? target . recordedArguments . value : [ undefined ] )
54+ target [ target . context as AssertionMethod ] ( ...Array . isArray ( target . recordedArguments . value ) ? target . recordedArguments . value : [ undefined ] )
5455 if ( target . isAssertion ) newNode . executeAssertion ( )
56+ // if (target.isConfiguration) newNode.executeConfiguration()
5557 }
5658 if ( target . isRoot ( ) && is . method . contextValue ( property ) && ( is . method . assertion ( property ) || is . method . configuration ( property ) ) ) {
5759 newNode . assignContext ( property )
@@ -238,7 +240,8 @@ export class SubstituteNode extends SubstituteNodeBase implements ObjectSubstitu
238240 return
239241 }
240242
241- const withContext = this . parent . property === sharedConstants . CONTEXT . received . symbol
243+ // const withContext = this.parent.property === sharedConstants.CONTEXT.received.symbol
244+ const withContext = false
242245 const siblings = [ ...this . getAllSiblings ( ) . filter ( n => ( withContext || ! n . hasContext ) && n . accessorType === this . accessorType ) ]
243246 const hasBeenCalled = siblings . length > 0
244247 const hasSiblingOfSamePropertyType = siblings . some ( sibling => sibling . propertyType === this . propertyType )
0 commit comments