From d270ba71cbb4badc571f0dfb8c24e19df1518a12 Mon Sep 17 00:00:00 2001 From: Stephen Hess Date: Wed, 16 Sep 2015 20:57:23 -0400 Subject: [PATCH] added negative tests for req w/o results and req.results w/o data --- .../unit/middleware/confidenceScoreReverse.js | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/test/unit/middleware/confidenceScoreReverse.js b/test/unit/middleware/confidenceScoreReverse.js index ddd53400..bad7d93b 100644 --- a/test/unit/middleware/confidenceScoreReverse.js +++ b/test/unit/middleware/confidenceScoreReverse.js @@ -3,6 +3,38 @@ var confidenceScoreReverse = require('../../../middleware/confidenceScoreReverse module.exports.tests = {}; module.exports.tests.confidenceScoreReverse = function(test, common) { + test('req without results should not throw exception', function(t) { + var req = {}; + + try { + confidenceScoreReverse(req, null, function() {}); + } + catch (e) { + t.fail('an exception should not have been thrown'); + } + finally { + t.end(); + } + + }); + + test('req.results without data should not throw exception', function(t) { + var req = { + results: {} + }; + + try { + confidenceScoreReverse(req, null, function() {}); + } + catch (e) { + t.fail('an exception should not have been thrown'); + } + finally { + t.end(); + } + + }); + test('0m <= distance < 1m should be given score 1.0', function(t) { var req = { results: {