domenic / promise-tests

DEPRECATED: use https://github.com/promises-aplus/promises-tests instead!
https://github.com/promises-aplus/promises-tests
Do What The F*ck You Want To Public License
61 stars 10 forks source link

Example test to ensure that promise chains are isolated #3

Closed briancavalier closed 12 years ago

briancavalier commented 12 years ago

Is this kind of test valuable? I could imagine expanding it to cover cases like one fulfillment handler returning successfully, while another throws--ensuring that the subsequent steps in the chain are fulfilled and rejected.

Also, I use the .then(done, done) pattern in when.js's test because it tends to allow the test framework (buster.js in my case, but seems to work here, too) to report the real error rather than a timeout. That may provide better feedback for failures, but I'm not as familiar with async testing in mocha.

domenic commented 12 years ago

I think this is covered by

https://github.com/domenic/promise-tests/blob/master/lib/promises-a.js#L284-338

right?

briancavalier commented 12 years ago

Hmmm, they do seem different, although I'm still not convinced that my example actually tests something useful :)

The existing tests ensure that all the immediate handlers of promise receive the same value, and a handler cannot affect the promise resolution state, or the value seen by any of its peer handlers. I was hoping to try ensure that each immediate handler of promise can return a different value (or take a different action, e.g. throw), and that each will be propagated downstream correctly to the next handler in the corresponding fork of the promise chain. In other words, the promise chain can diverge.