Browse Source

Use tape's doesNotThrow where appropriate

pull/385/head
Julian Simioni 9 years ago
parent
commit
fcc9237993
  1. 36
      test/unit/middleware/confidenceScore.js
  2. 20
      test/unit/middleware/confidenceScoreReverse.js

36
test/unit/middleware/confidenceScore.js

@ -5,17 +5,12 @@ module.exports.tests = {};
module.exports.tests.confidenceScore = function(test, common) { module.exports.tests.confidenceScore = function(test, common) {
test('empty res and req should not throw exception', function(t) { test('empty res and req should not throw exception', function(t) {
try { function testIt() {
confidenceScore({}, {}, function() {}); confidenceScore({}, {}, function() {});
t.pass('no exception');
}
catch (e) {
t.fail('an exception should not have been thrown');
}
finally {
t.end();
} }
t.doesNotThrow(testIt, 'an exception should not have been thrown');
t.end();
}); });
test('res.results without parsed_text should not throw exception', function(t) { test('res.results without parsed_text should not throw exception', function(t) {
@ -27,18 +22,12 @@ module.exports.tests.confidenceScore = function(test, common) {
meta: [10] meta: [10]
}; };
try { function testIt() {
confidenceScore(req, res, function() {}); confidenceScore(req, res, function() {});
t.pass('no exception');
}
catch (e) {
t.fail('an exception should not have been thrown');
console.log(e.stack);
}
finally {
t.end();
} }
t.doesNotThrow(testIt, 'an exception should not have been thrown');
t.end();
}); });
test('hit without address should not error', function(t) { test('hit without address should not error', function(t) {
@ -61,17 +50,12 @@ module.exports.tests.confidenceScore = function(test, common) {
} }
}; };
try { function testIt() {
confidenceScore(req, res, function() {}); confidenceScore(req, res, function() {});
t.pass('no exception');
}
catch (e) {
t.fail('an exception should not have been thrown with no address');
console.log(e.stack);
}
finally {
t.end();
} }
t.doesNotThrow(testIt, 'an exception should not have been thrown with no address');
t.end();
}); });

20
test/unit/middleware/confidenceScoreReverse.js

@ -6,16 +6,12 @@ module.exports.tests.confidenceScoreReverse = function(test, common) {
test('res without results should not throw exception', function(t) { test('res without results should not throw exception', function(t) {
var res = {}; var res = {};
try { function testIt() {
confidenceScoreReverse(null, res, function() {}); confidenceScoreReverse(null, res, function() {});
} }
catch (e) {
t.fail('an exception should not have been thrown');
}
finally {
t.end();
}
t.doesNotThrow(testIt, 'an exception should not have been thrown');
t.end();
}); });
test('res.results without data should not throw exception', function(t) { test('res.results without data should not throw exception', function(t) {
@ -23,16 +19,12 @@ module.exports.tests.confidenceScoreReverse = function(test, common) {
results: {} results: {}
}; };
try { function testIt() {
confidenceScoreReverse(null, res, function() {}); confidenceScoreReverse(null, res, function() {});
} }
catch (e) {
t.fail('an exception should not have been thrown');
}
finally {
t.end();
}
t.doesNotThrow(testIt, 'an exception should not have been thrown');
t.end();
}); });
test('0m <= distance < 1m should be given score 1.0', function(t) { test('0m <= distance < 1m should be given score 1.0', function(t) {

Loading…
Cancel
Save