Browse Source

Fix mismatching name of types preference parameter

The parameter in clean.types being set by `helpers/text_parser.js` was
"from_address_parsing", but the code in `helper/types.js` was expecting
"from_address_parser". This commit makes both use "from_address_parser"
and adds a test.
pull/347/head
Julian Simioni 9 years ago
parent
commit
b188a2046c
  1. 2
      sanitiser/_text.js
  2. 1
      test/unit/run.js
  3. 32
      test/unit/sanitiser/_text.js

2
sanitiser/_text.js

@ -26,7 +26,7 @@ function sanitize( raw, clean ){
// try to set layers from query parser results
clean.types = clean.layers || {};
clean.types.from_address_parsing = text_parser.get_layers(clean.text);
clean.types.from_address_parser = text_parser.get_layers(clean.text);
}
return messages;

1
test/unit/run.js

@ -29,6 +29,7 @@ var tests = [
require('./sanitiser/_single_scalar_parameters'),
require('./sanitiser/_size'),
require('./sanitiser/_sources'),
require('./sanitiser/_text'),
require('./sanitiser/autocomplete'),
require('./sanitiser/place'),
require('./sanitiser/reverse'),

32
test/unit/sanitiser/_text.js

@ -0,0 +1,32 @@
var sanitiser = require('../../../sanitiser/_text');
var type_mapping = require('../../../helper/type_mapping');
module.exports.tests = {};
module.exports.tests.text_parser = function(test, common) {
test('short input text has admin layers set ', function(t) {
var raw = {
text: 'emp' //start of empire state building
};
var clean = {
};
var messages = sanitiser(raw, clean);
t.deepEquals(messages.errors, [], 'no errors');
t.deepEquals(messages.warnings, [], 'no warnings');
t.equal(clean.types.from_address_parser, type_mapping.layer_with_aliases_to_type.coarse, 'coarse layers preferred');
t.end();
});
};
module.exports.all = function (tape, common) {
function test(name, testFunction) {
return tape('SANITISER _text: ' + name, testFunction);
}
for( var testCase in module.exports.tests ){
module.exports.tests[testCase](test, common);
}
};
Loading…
Cancel
Save