From ea78b8268ae229991bb78d9539e7478063b9fd33 Mon Sep 17 00:00:00 2001 From: Harish Krishna Date: Wed, 15 Apr 2015 13:12:30 -0400 Subject: [PATCH] more tests: testing falsy and truthy params --- test/unit/helper/geojsonify.js | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/test/unit/helper/geojsonify.js b/test/unit/helper/geojsonify.js index d45b318e..c94f45dd 100644 --- a/test/unit/helper/geojsonify.js +++ b/test/unit/helper/geojsonify.js @@ -178,12 +178,22 @@ module.exports.tests.search = function(test, common) { ] }; - test('geojsonify.search()', function(t) { + var truthy_params = [true, 1, -1, 123, 'abc']; + + test('geojsonify.search(doc, true) with details', function(t) { var json = geojsonify.search( input, true ); - t.deepEqual(json, expected, 'all docs mapped'); + t.deepEqual(json, expected, 'all docs (with details) mapped'); t.end(); }); + truthy_params.forEach(function(details) { + test('geojsonify.search(doc, '+ details +') with details', function(t) { + var json = geojsonify.search( input, details ); + t.deepEqual(json, expected, 'all docs (with details) mapped'); + t.end(); + }); + }); + var no_details_expected = { 'type': 'FeatureCollection', 'bbox': [ -73.985656, 40.748432, -0.101795, 51.5337144 ], @@ -236,11 +246,21 @@ module.exports.tests.search = function(test, common) { ] }; - test('geojsonify.search() with no details (default)', function(t) { + test('geojsonify.search(doc) with no details (default)', function(t) { var json = geojsonify.search( input ); t.deepEqual(json, no_details_expected, 'all docs (with no details) mapped'); t.end(); }); + + var falsy_params = [false, undefined, null, 0 ]; + + falsy_params.forEach(function(details) { + test('geojsonify.search(doc, '+ details +') with no details', function(t) { + var json = geojsonify.search( input, details ); + t.deepEqual(json, no_details_expected, 'all docs (with no details) mapped'); + t.end(); + }); + }); }; module.exports.all = function (tape, common) {