pelias-fuzzy-tester
Advanced tools
Comparing version 1.6.0 to 1.7.0
@@ -5,2 +5,6 @@ var util = require( 'util' ); | ||
function setEndpoint(testCase, testSuite) { | ||
testCase.endpoint = testCase.endpoint || testSuite.endpoint || 'search'; | ||
} | ||
function validateTestSuite(testSuite) { | ||
@@ -15,2 +19,5 @@ return testSuite.tests.map( function ( testCase ){ | ||
// ensure endpoint is set for later use | ||
setEndpoint(testCase, testSuite); | ||
if( 'unexpected' in testCase ){ | ||
@@ -17,0 +24,0 @@ testCase.unexpected.properties.forEach( function ( props ){ |
@@ -11,2 +11,3 @@ /** | ||
var util = require( 'util' ); | ||
const url = require('url'); | ||
@@ -16,2 +17,29 @@ var percentageForDisplay = require('../lib/percentageForDisplay'); | ||
function inputToUrl(testCase) { | ||
const path = `/v1/${testCase.endpoint}`; | ||
const paramStrings = []; | ||
const priorityParams = ['point.lat', 'point.lon', 'text']; | ||
Object.keys(testCase.in).forEach(function(key) { | ||
// skip keys already in the priority list | ||
if (priorityParams.includes(key)) { | ||
return; | ||
} else { | ||
paramStrings.push(`${key}=${testCase.in[key]}`); | ||
} | ||
}); | ||
// ensure priority params are last | ||
priorityParams.forEach(function (priorityParam) { | ||
if (testCase.in[priorityParam]) { | ||
paramStrings.push(`${priorityParam}=${testCase.in[priorityParam]}`); | ||
} | ||
}); | ||
return `${path}?${paramStrings.join('&')}`; | ||
} | ||
/** | ||
@@ -25,3 +53,4 @@ * Format and print a test result to the terminal. | ||
var input = JSON.stringify(result.testCase.in); | ||
const query = inputToUrl(testCase); | ||
var expectationCount; | ||
@@ -36,3 +65,3 @@ | ||
var expectationString = (expectationCount > 1) ? ' (' + expectationCount + ' expectations)' : ''; | ||
var testDescription = input + expectationString; | ||
var testDescription = query + expectationString; | ||
@@ -39,0 +68,0 @@ var status = (result.progress === undefined) ? '' : result.progress.inverse + ' '; |
{ | ||
"name": "pelias-fuzzy-tester", | ||
"version": "1.6.0", | ||
"version": "1.7.0", | ||
"description": "A testing suite by Mapzen with fuzzy testing ability", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
154108
3288