-
Notifications
You must be signed in to change notification settings - Fork 5
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
jasonk000
committed
Aug 27, 2016
1 parent
e6e2bba
commit 1f65c9c
Showing
2 changed files
with
42 additions
and
1 deletion.
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
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,39 @@ | ||
|
||
"use strict"; | ||
|
||
const assert = require('assert'); | ||
const s = require('ht-schema'); | ||
const bluebird = require('bluebird'); | ||
|
||
const Service = require('../src/service'); | ||
const Client = require('../src/client'); | ||
const Transports = require('../src/transports'); | ||
|
||
describe("Integrations", function () { | ||
it("does not double call when callback throws", function (done) { | ||
var transport = new Transports.Local(); | ||
var service = new Service(transport); | ||
var client = new Client({ s: transport }); | ||
|
||
let countCalled = 0 | ||
|
||
service.on("hello", null, function () { | ||
return new Promise(function (resolve, reject) { | ||
resolve('hello') | ||
}) | ||
}) | ||
|
||
client.call('s', 'hello', function (err, result) { | ||
countCalled++ | ||
throw Error('oops') | ||
}) | ||
|
||
setTimeout(function () { | ||
switch (countCalled) { | ||
case 0: throw Error('did not get called at all') | ||
case 1: return done() | ||
case 2: throw Error('called multiple times') | ||
} | ||
}, 100) | ||
}); | ||
}); |