Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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') | ||
}) | ||
}) |