0.0.2 • Published 12 years ago

assert-promise v0.0.2

Weekly downloads
40
License
Apache 2.0
Repository
github
Last release
12 years ago

Has all the functions from Node's assert, where the first param is a promise containing the actual value.

Usage

var assertPromise = require('assert-promise')

it('assert.equal passing promise', function(done) {
  assertPromise.equal(Q(1).delay(50), 1).done(done)
})

it('assert passing promise with own assert function', function(done) {
  var assertOneLess = function(actual, expected, message) {
    assert.equal(actual + 1, expected, message)
  }
  assertPromise.withFn(Q(2).delay(50), 3, 'this should pass', assertOneLess).done(done)
})

or

require('mocha-as-promised')()
var assertPromise = require('assert-promise')

it('assert passing mocha-as-promised', function() {
  return assertPromise.equal(Q(2).delay(50), 2)
    .then(function() {
      return assertPromise.notEqual(Q(3).delay(50), 2)
    }).then(function() {
      return assertPromise(Q(true).delay(50))
    }).then(function() {
      return assertPromise.deepEqual(Q({a: 1}).delay(50), {a: true})
    }).then(function() {
      return assertPromise.notDeepEqual(Q({a: 2}).delay(50), {a: true})
    }).then(function() {
      return assertPromise.strictEqual(Q(1).delay(50), 1)
    }).then(function() {
      return assertPromise.notStrictEqual(Q(true).delay(50), 1)
    })
})