Since fulfill and resolve are equivalent when not given a thenable.įinally, note that none of these functions, including deferred().resolve and deferred().reject, should throwĮxceptions. Or thenable-accepting forms of the resolve operation directly, and instead only use the direct fulfillment operation, That means that we never use the promise. Note that the tests will never pass a promise or a thenable as a resolution. But, if your promise library has the capability to create already-resolved orĪlready-rejected promises, then you should include these exports, so that the test runner can provide you with betterĬode coverage and uncover any bugs in those methods. The resolved and rejected exports are actually optional, and will be automatically created by the test runner usingĭeferred if they are not present. reject(reason) moves the promise from the pending state to the rejected state, with rejection reason reason.resolve(value) resolves the promise with value.promise is a promise that is currently in the pending state.deferred(): creates an object consisting of :.rejected(reason): creates a promise that is already rejected with reason.resolved(value): creates a promise that is resolved with value.In order to test your promise library, you must expose a very minimal adapter interface. The tests can run in either a Node.js environment or, if you set things up correctly, in the browser. You can also send a pull request to have your implementation listed on the implementations page. Passing the tests in this repo means that you have a Promises/A+ compliant implementation of the then() method, and you can display the Promises/A+ logo in your README. This suite tests compliance of a promise implementation with the Promises/A+ specification.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |