Skip to content
This repository has been archived by the owner on Jan 4, 2024. It is now read-only.

Commit

Permalink
style: cleaning up callback syntax in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MattMorgis committed Nov 7, 2016
1 parent 55e24dd commit dbf8604
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 35 deletions.
36 changes: 7 additions & 29 deletions test/client/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,52 +48,30 @@ Client.prototype.createClient = function(callback) {
*/
Client.prototype.serverVersion = function(callback) {
this.client.serverVersion({}, function(err, result) {
if (err) {

return callback(err);
} else {

return callback(null, result);
}
})
return callback(err, result);
});
};

Client.prototype.clientVersion = function(callback) {
var args = {strVersion: '2.1.0.30'};
this.client.clientVersion(args, function(err, result) {
if (err) {
console.log(err);
return callback(err);
} else {
console.log(result);
return callback(null, result);
}
return callback(err, result);
});
};

Client.prototype.clientVersionBelowMinimum = function(callback) {
var args = {strVersion: '0.1.0'};
this.client.clientVersion(args, function(err, result) {
if (err) {
console.log(err);
return callback(err);
} else {
console.log(result);
return callback(null, result);
}
return callback(err, result);
});
};

Client.prototype.clientVersionBelowRecommended = function(callback) {
var args = {strVersion: '2.0.0'};
this.client.clientVersion(args, function(err, result) {
if (err) {
console.log(err);
return callback(err);
} else {
console.log(result);
return callback(null, result);
}
return callback(err, result);
});
};

Client.prototype.authenticateWithCorrectUsernameAndPassword = function(callback) {
var args = {
Expand Down
9 changes: 3 additions & 6 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,23 @@ describe('Soap Client', function() {

it('should run client version method', function(done) {
soapClient.clientVersion(function(err, result) {
if (err) { done (err); }
console.log(result.clientVersionResult.string);
if (err) { done(err); }
assert.deepEqual(result.clientVersionResult.string, {});
done();
});
});

it('should be below minimum client version', function(done) {
soapClient.clientVersionBelowMinimum(function(err, result) {
if (err) { done (err); }
console.log(result.clientVersionResult.string);
if (err) { done(err); }
assert.deepEqual(result.clientVersionResult.string, 'E:You need to upgrade your QBWebConnector');
done();
});
});

it('should be below recommended client version', function(done) {
soapClient.clientVersionBelowRecommended(function(err, result) {
if (err) { done (err); }
console.log(result.clientVersionResult.string);
if (err) { done(err); }
assert.deepEqual(result.clientVersionResult.string, 'W:It is recommended that you upgrade your QBWebConnector');
done();
});
Expand Down

0 comments on commit dbf8604

Please sign in to comment.