Skip to content

Commit

Permalink
Merge 4a76eb3 into 6a9308c
Browse files Browse the repository at this point in the history
  • Loading branch information
paolochiodi committed Nov 3, 2016
2 parents 6a9308c + 4a76eb3 commit 54b3b53
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions test/timeout.test.js
@@ -0,0 +1,44 @@
/* Copyright (c) 2016 Richard Rodger, MIT License */
'use strict'

var Lab = require('lab')
var Code = require('code')


var Seneca = require('..')


var lab = exports.lab = Lab.script()
var describe = lab.describe
var it = lab.it
var expect = Code.expect

describe('timeout', function () {
it('returns error', function (fin) {
Seneca({timeout: 100})
.add('a:1', function (msg, done) {
setTimeout(function () {
done(null, {a: 2})
}, 300)
})
.act('a:1', function (err, out) {
expect(err).to.exist()
expect(out).to.not.exist()
fin()
})
})

it('still call error if callback not present', function (fin) {
Seneca({timeout: 100})
.error(function (err) {
expect(err).to.exist()
fin()
})
.add('a:1', function (msg, done) {
setTimeout(function () {
done(null, {a: 2})
}, 300)
})
.act('a:1')
})
})

0 comments on commit 54b3b53

Please sign in to comment.