The problem is that the moment I trigger .resolves() on the first stub it automatically triggers the second then.
The problem seems to be on:
line 59 return this;
line 8 if (this.resolved && !this.rejected) { - this will never be executed because all thens are triggered before a promise can be resolved which means that all chained thens are triggered on the first stub due to return this;
There is a problem when I try to stub chained promises like
The problem is that the moment I trigger
.resolves()
on the first stub it automatically triggers the second then. The problem seems to be on:return this
;if (this.resolved && !this.rejected) {
- this will never be executed because all thens are triggered before a promise can be resolved which means that all chained thens are triggered on the first stub due toreturn this
;I created a PR https://github.com/substantial/sinon-stub-promise/pull/28 so you can check exactly what happens (this should not be merged). I tried to fix this but it didn't really work out as I was hoping. Any ideas?