Skip to content

Commit

Permalink
Add missing coverage tests for local transport
Browse files Browse the repository at this point in the history
  • Loading branch information
SomeoneWeird committed May 15, 2015
1 parent d893fbb commit 0f9b838
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
3 changes: 0 additions & 3 deletions src/transports/local.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ function LocalTransportClientWrapper(o) {
if(response.error && response.error != responseErrKeyBefore) {
// forceJSON error
return callback(formatError(response));
} else {
// response has an 'error' key, pass through normally
return callback(null, response);
}

return callback(null, response);
Expand Down
38 changes: 38 additions & 0 deletions test-src/transports/local.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,44 @@ describe("Local Transport", function() {

});

it("should return undefined if no data is returned from service", function(done) {

let transport = new LOCAL();

let _server = new transport.Server(function(method, data, callback) {
callback();
});

let _client = new transport.Client();

_client.call("hello", "world", function(err, response) {
assert.ifError(err);
assert.strictEqual(response, undefined);
done();
});

});

it("should return error if data returned from service cannot be coerced to JSON", function(done) {

let transport = new LOCAL();

let response = {};
response.hello = response;

let _server = new transport.Server(function(method, data, callback) {
callback(null, response);
});

let _client = new transport.Client();

_client.call("hello", "world", function(err) {
assert.equal(err.error, "Converting circular structure to JSON");
done();
});

});

});

describe("forceJSON", function() {
Expand Down

0 comments on commit 0f9b838

Please sign in to comment.