Skip to content

Commit

Permalink
test for unsupported carrier
Browse files Browse the repository at this point in the history
  • Loading branch information
freshlogic committed Jun 26, 2019
1 parent 91fdf74 commit 87b81d7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ function Bloodhound(options) {

this.track = function(trackingNumber, carrier, callback) {
if (!trackingNumber) {
return callback(new Error('Tracking number is not specified'));
return callback(new Error('Tracking number is not specified.'));
}

if (!carrier) {
return callback(new Error('Carrier is not specified'));
return callback(new Error('Carrier is not specified.'));
}

const results = {
Expand Down
14 changes: 12 additions & 2 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('Error handling', function() {
it('Should return an error when a tracking number is not specified', function(done) {
bloodhound.track(null, 'fedex', function(err, data) {
assert(err);
assert.strictEqual(err.message, 'Tracking number is not specified');
assert.strictEqual(err.message, 'Tracking number is not specified.');
assert.strictEqual(data, undefined);

done();
Expand All @@ -18,7 +18,17 @@ describe('Error handling', function() {
it('Should return an error when a carrier is not specified', function(done) {
bloodhound.track('449044304137821', null, function(err, data) {
assert(err);
assert.strictEqual(err.message, 'Carrier is not specified');
assert.strictEqual(err.message, 'Carrier is not specified.');
assert.strictEqual(data, undefined);

done();
});
});

it('Should return an error when a carrier is not supported', function(done) {
bloodhound.track('449044304137821', 'foo', function(err, data) {
assert(err);
assert.strictEqual(err.message, 'Carrier foo is not supported.');
assert.strictEqual(data, undefined);

done();
Expand Down

0 comments on commit 87b81d7

Please sign in to comment.