Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
junosuarez committed Mar 13, 2013
1 parent 000e6ef commit 504cf69
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions test/test.connective.js → test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ chai.use(require('sinon-chai'))
var Q = require('q')
var K = require('ski/k')

describe('connective-promise', function () {
var connective = require('../index')
describe('shortcircuit-promise', function () {
var shortcircuit = require('../index')

it('has interface', function () {
connective.should.have.interface({
shortcircuit.should.have.interface({
or: Function,
and: Function,
not: Function,
Expand All @@ -20,7 +20,7 @@ describe('connective-promise', function () {
})

describe('and', function () {
var and = connective.and
var and = shortcircuit.and

it('is rejected if there are no terms', function (done) {
and().then(null, function (err) {
Expand Down Expand Up @@ -73,7 +73,7 @@ describe('connective-promise', function () {
})

describe('or', function () {
var or = connective.or
var or = shortcircuit.or

it('is rejected if there are no terms', function (done) {
or().then(null, function (err) {
Expand Down Expand Up @@ -123,10 +123,22 @@ describe('connective-promise', function () {
}).then(done, done)
})

it('is rejected if any of the executed terms is rejected', function (done) {
var err = new Error('foo')
var t1 = sinon.stub().returns(Q.resolve(false))
var t2 = sinon.stub().returns(Q.reject(err))

or(t1, t2).then(function () {
done(new Error('should not resolve'))
}, function (e) {
e.should.equal(err)
done()
})
})
})

describe('not', function () {
var not = connective.not
var not = shortcircuit.not

it('is rejected if there are no terms', function (done) {
not().then(null, function () { done() })
Expand All @@ -142,7 +154,7 @@ describe('connective-promise', function () {
})

describe('some', function () {
var some = connective.some
var some = shortcircuit.some

it('is rejected if there are no terms', function (done) {
some().then(null, function (err) {
Expand Down Expand Up @@ -183,7 +195,7 @@ describe('connective-promise', function () {
})

describe('every', function () {
var every = connective.every
var every = shortcircuit.every

it('is rejected if there are no terms', function (done) {
every().then(null, function (err) {
Expand Down

0 comments on commit 504cf69

Please sign in to comment.