Package detail

should-promised

shouldjs60MITdeprecated0.3.1

Project merged to should.js >= 8.x.x

Some sort of promise assertion helpers

should, promise

readme

should-promised

There some helpers for asserting promises.

.Promise

Assert given object is promise

.fulfilled

Assert given promise will be fulfilled. It will return promise.

it('should be allow to check if promise fulfilled', function() {
  return promised(10).should.be.fulfilled;
});

.fulfilledWith

Assert given promise will be fulfilled with an expected value. It will return promise.

it('should be allow to check if promise fulfilledWith an expected value', function() {
  return promised(10).should.be.fulfilledWith(10);
});

.rejected

Assert given promise will be rejected. It will return promise.

it('should be allow to check if promise rejected', function() {
  return promiseFail().should.be.rejected;
});

.rejectedWith

Assert given promise will be rejected with matched Error. Arguments are the same as Assertion#throw.

.finally or .eventually

This method begin assertions for promises, all next .chain calls will be shortcuts for .thenable calls on promise.

So you can do like this

promised('abc').should.finally.be.exactly('abc')
      .and.be.a.String;

//or combine with any of Promise methods as any assertion will return Promise itself

Promise.all([
  promised(10).should.finally.be.a.Number,
  promised('abc').should.finally.be.a.String
])

Before .finally

Everything you did before .finally saved into new assertion (but that is not quite usefull as object will be promise). Main idea is to save .not and .any.

changelog

15/08/2015 - 0.3.1

  • Small fix with getter

18/06/2015 - 0.3.0

  • Updates with latest should.js

17/04/2015 - 0.2.1

  • Fix compatibilty issue with es6 promise

18/03/2015 - 0.2.0

  • Added .fullfilledWith

21/02/2015 - 0.1.0

  • In .Promise do not use current context
  • Added umd wrapper

13/02/2015 - 0.0.5

  • Fix errors appeared with latest should.js
  • Fix reference error in .rejectedWith

08/01/2015 - 0.0.4

  • Added .rejectedWith to assert matched errors

08/01/2015 - 0.0.3

  • Added .fulfilled to assert if given promise fulfilled
  • Added .rejected to assert if given promise rejected
  • Added .Promise to assert given object is Promise

29/10/2014 - 0.0.2

  • Added alias .eventually
  • .not and .any calls before .finally now propagated

27/10/2014 - 0.0.1

  • First version - it copy all properties of Assertion.prototype to be .thenable