diff --git a/sanitiser/_text.js b/sanitiser/_text.js index 0aa5c26c..e8b055f0 100644 --- a/sanitiser/_text.js +++ b/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; diff --git a/test/unit/run.js b/test/unit/run.js index fb8b1728..b79f9aca 100644 --- a/test/unit/run.js +++ b/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'), diff --git a/test/unit/sanitiser/_text.js b/test/unit/sanitiser/_text.js new file mode 100644 index 00000000..3ccfbbb2 --- /dev/null +++ b/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); + } +};