mirror of https://github.com/pelias/api.git
Stephen K Hess
7 years ago
committed by
GitHub
15 changed files with 123 additions and 12 deletions
@ -0,0 +1,15 @@
|
||||
// this sanitizer exists solely to allow `lang` as a request parameter
|
||||
function _sanitize( raw, clean ){ |
||||
// error & warning messages
|
||||
return { errors: [], warnings: [] }; |
||||
} |
||||
|
||||
function _expected(){ |
||||
return [{ 'name': 'lang' }]; |
||||
} |
||||
|
||||
// export function
|
||||
module.exports = () => ({ |
||||
sanitize: _sanitize, |
||||
expected: _expected |
||||
}); |
@ -0,0 +1,35 @@
|
||||
const sanitizer = require('../../../sanitizer/_request_language')(); |
||||
|
||||
module.exports.tests = {}; |
||||
|
||||
module.exports.tests.do_nothing = (test, common) => { |
||||
test('sanitize should return empty warnings/erros', t => { |
||||
const messages = sanitizer.sanitize(); |
||||
|
||||
t.deepEquals(messages.errors, [], 'no errors'); |
||||
t.deepEquals(messages.warnings, [], 'no warnings'); |
||||
t.end(); |
||||
|
||||
}); |
||||
|
||||
}; |
||||
|
||||
module.exports.tests.expected = (test, common) => { |
||||
test('expected should contain only \'lang\'', t => { |
||||
const expected = sanitizer.expected(); |
||||
|
||||
t.deepEquals(expected, [{'name': 'lang'}]); |
||||
t.end(); |
||||
|
||||
}); |
||||
}; |
||||
|
||||
module.exports.all = (tape, common) => { |
||||
function test(name, testFunction) { |
||||
return tape(`SANITIZE _request_language: ${name}`, testFunction); |
||||
} |
||||
|
||||
for( const testCase in module.exports.tests ){ |
||||
module.exports.tests[testCase](test, common); |
||||
} |
||||
}; |
Loading…
Reference in new issue