Browse Source

synthesize query value from parameter

pull/763/head
Stephen Hess 8 years ago
parent
commit
16fc3bee66
  1. 1
      sanitizer/_synthesize_analysis.js
  2. 6
      test/unit/sanitizer/_synthesize_analysis.js

1
sanitizer/_synthesize_analysis.js

@ -2,6 +2,7 @@ const _ = require('lodash');
const text_analyzer = require('pelias-text-analyzer'); const text_analyzer = require('pelias-text-analyzer');
const fields = { const fields = {
'query': 'query',
'address': 'address', 'address': 'address',
'neighbourhood': 'neighbourhood', 'neighbourhood': 'neighbourhood',
'borough': 'borough', 'borough': 'borough',

6
test/unit/sanitizer/_synthesize_analysis.js

@ -26,6 +26,7 @@ module.exports.tests.text_parser = function(test, common) {
const expected_clean = { const expected_clean = {
parsed_text: { parsed_text: {
query: 'query value',
neighbourhood: 'neighbourhood value', neighbourhood: 'neighbourhood value',
borough: 'borough value', borough: 'borough value',
city: 'locality value', city: 'locality value',
@ -58,6 +59,7 @@ module.exports.tests.text_parser = function(test, common) {
} }
const raw = { const raw = {
query: getInvalidValue(),
address: getInvalidValue(), address: getInvalidValue(),
neighbourhood: getInvalidValue(), neighbourhood: getInvalidValue(),
borough: getInvalidValue(), borough: getInvalidValue(),
@ -78,7 +80,7 @@ module.exports.tests.text_parser = function(test, common) {
t.deepEquals(clean, expected_clean); t.deepEquals(clean, expected_clean);
t.deepEquals(messages.errors, ['at least one of the following fields is required: ' + t.deepEquals(messages.errors, ['at least one of the following fields is required: ' +
'address, neighbourhood, borough, locality, county, region, postalcode, country'], 'no errors'); 'query, address, neighbourhood, borough, locality, county, region, postalcode, country'], 'no errors');
t.deepEquals(messages.warnings, [], 'no warnings'); t.deepEquals(messages.warnings, [], 'no warnings');
t.end(); t.end();
@ -101,7 +103,7 @@ module.exports.tests.text_parser = function(test, common) {
t.deepEquals(clean, expected_clean); t.deepEquals(clean, expected_clean);
t.deepEquals(messages.errors, ['at least one of the following fields is required: ' + t.deepEquals(messages.errors, ['at least one of the following fields is required: ' +
'address, neighbourhood, borough, locality, county, region, postalcode, country'], 'no errors'); 'query, address, neighbourhood, borough, locality, county, region, postalcode, country'], 'no errors');
t.deepEquals(messages.warnings, [], 'no warnings'); t.deepEquals(messages.warnings, [], 'no warnings');
t.end(); t.end();

Loading…
Cancel
Save