From b5be8dea4273f9a64673fd99525db02527b34c84 Mon Sep 17 00:00:00 2001 From: Julian Simioni Date: Thu, 10 Dec 2015 16:52:50 -0500 Subject: [PATCH 1/3] Remove duplicate test --- test/unit/helper/types.js | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/test/unit/helper/types.js b/test/unit/helper/types.js index 92848d46..37720bb5 100644 --- a/test/unit/helper/types.js +++ b/test/unit/helper/types.js @@ -3,19 +3,6 @@ var types = require('../../../helper/types'); module.exports.tests = {}; module.exports.tests.no_cleaned_types = function(test, common) { - test('no cleaned types', function(t) { - try { - types(); - t.fail('exception should be thrown'); - } - catch (err) { - t.equal(err.message, 'clean_types should not be null or undefined', 'no input should result in exception'); - } - finally { - t.end(); - } - }); - test('no cleaned types', function(t) { try { types({}); From fcc9237993092d11cca7f38f578c06de08b266bc Mon Sep 17 00:00:00 2001 From: Julian Simioni Date: Thu, 10 Dec 2015 16:56:20 -0500 Subject: [PATCH 2/3] Use tape's doesNotThrow where appropriate --- test/unit/middleware/confidenceScore.js | 36 ++++++------------- .../unit/middleware/confidenceScoreReverse.js | 20 ++++------- 2 files changed, 16 insertions(+), 40 deletions(-) diff --git a/test/unit/middleware/confidenceScore.js b/test/unit/middleware/confidenceScore.js index 69821293..bf454381 100644 --- a/test/unit/middleware/confidenceScore.js +++ b/test/unit/middleware/confidenceScore.js @@ -5,17 +5,12 @@ module.exports.tests = {}; module.exports.tests.confidenceScore = function(test, common) { test('empty res and req should not throw exception', function(t) { - try { + function testIt() { 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) { @@ -27,18 +22,12 @@ module.exports.tests.confidenceScore = function(test, common) { meta: [10] }; - try { + function testIt() { 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) { @@ -61,17 +50,12 @@ module.exports.tests.confidenceScore = function(test, common) { } }; - try { + function testIt() { 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(); }); diff --git a/test/unit/middleware/confidenceScoreReverse.js b/test/unit/middleware/confidenceScoreReverse.js index 450fd0db..81d92a7c 100644 --- a/test/unit/middleware/confidenceScoreReverse.js +++ b/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) { var res = {}; - try { + function testIt() { 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) { @@ -23,16 +19,12 @@ module.exports.tests.confidenceScoreReverse = function(test, common) { results: {} }; - try { + function testIt() { 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) { From 87f6f32985b01fd62888c51a61b70b706917d967 Mon Sep 17 00:00:00 2001 From: Julian Simioni Date: Thu, 10 Dec 2015 16:56:35 -0500 Subject: [PATCH 3/3] Use tape's throws where appropriate --- test/unit/helper/types.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/test/unit/helper/types.js b/test/unit/helper/types.js index 37720bb5..4c68b46c 100644 --- a/test/unit/helper/types.js +++ b/test/unit/helper/types.js @@ -4,16 +4,13 @@ module.exports.tests = {}; module.exports.tests.no_cleaned_types = function(test, common) { test('no cleaned types', function(t) { - try { + function testIt() { types({}); - t.fail('exception should be thrown'); - } - catch (err) { - t.equal(err.message, 'clean_types should not be null or undefined', 'no input should result in exception'); - } - finally { - t.end(); } + + t.throws(testIt, /clean_types should not be null or undefined/, 'no input should result in exception'); + + t.end(); }); };