Skip to content

RedRabbitDevelopment/promised

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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;
});

.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.

About

Promise assertions for should.js

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%