Skip to content

Commit

Permalink
add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Rémi Flament committed Dec 15, 2016
1 parent 528a6b0 commit 9f5e050
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion test/client-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ var fs = require('fs'),
}, baseUrl);
});

it('Should emit the "request" and "response" events with the same exchange id', function (done) {
it('Should emit the "request" and "response" events with the same generated exchange id if none is given', function (done) {
soap.createClient(__dirname + '/wsdl/default_namespace.wsdl', meta.options, function (err, client) {
var didEmitRequestEvent = false;
var didEmitResponseEvent = false;
Expand All @@ -703,6 +703,34 @@ var fs = require('fs'),
}, baseUrl);
});

it('Should emit the "request" and "response" events with the given exchange id', function (done) {
soap.createClient(__dirname + '/wsdl/default_namespace.wsdl', meta.options, function (err, client) {
var didEmitRequestEvent = false;
var didEmitResponseEvent = false;
var requestEid, responseEid;

client.on('request', function (xml, eid) {
didEmitRequestEvent = true;
requestEid = eid;
assert.ok(eid);
});

client.on('response', function (xml, response, eid) {
didEmitResponseEvent = true;
responseEid = eid;
assert.ok(eid);
});

client.MyOperation({}, function () {
assert.ok(didEmitRequestEvent);
assert.ok(didEmitResponseEvent);
assert.equal('unit', requestEid);
assert.equal(responseEid, requestEid);
done();
}, {exchangeId : 'unit'});
}, baseUrl);
});

it('should emit a \'soapError\' event with an exchange id', function (done) {
soap.createClient(__dirname + '/wsdl/default_namespace.wsdl', meta.options, function (err, client) {
var didEmitEvent = false;
Expand Down

0 comments on commit 9f5e050

Please sign in to comment.