File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -134,11 +134,12 @@ export class FunctionState implements ContextState {
134134 || property === SubstituteMethods . resolves
135135 || property === SubstituteMethods . rejects
136136 ) {
137- return ( ...returns : any [ ] ) => {
137+ return ( ...returnValues : any [ ] ) => {
138138 if ( ! this . _lastArgs ) {
139- throw SubstituteException . generic ( 'Eh, there\'s a bug, no args recorded for this return :/' )
139+ throw SubstituteException . generic ( 'Eh, there\'s a bug, no args recorded for this return :/' ) ;
140140 }
141141 const returnMock : Partial < ReturnMock > = { returnIndex : 0 , args : this . _lastArgs } ;
142+ const returns = returnValues . length === 0 ? [ void 0 ] : returnValues
142143 switch ( property ) {
143144 case SubstituteMethods . returns :
144145 returnMock . returnValues = returns ;
@@ -149,6 +150,10 @@ export class FunctionState implements ContextState {
149150 case SubstituteMethods . rejects :
150151 returnMock . returnValues = returns . map ( value => Promise . reject ( value ) ) ;
151152 break ;
153+ default :
154+ throw SubstituteException . generic (
155+ `Expected one of the following methods: "${ SubstituteMethods . returns } ", "${ SubstituteMethods . resolves } " or "${ SubstituteMethods . rejects } "`
156+ ) ;
152157 }
153158 this . returns . push ( < ReturnMock > returnMock ) ;
154159 this . _calls . pop ( )
You can’t perform that action at this time.
0 commit comments