Browse Source

External test

pull/1076/head
Gibran Parvez 7 years ago
parent
commit
e80af64d65
  1. 65
      test/unit/service/external.js

65
test/unit/service/external.js

@ -0,0 +1,65 @@
const proxyquire = require('proxyquire').noCallThru();
module.exports.tests = {};
module.exports.tests.interface = (test, common) => {
test('valid interface', (t) => {
var service = proxyquire('../../../service/external', {
'pelias-logger': {
get: (section) => {
t.equal(section, 'api');
}
}
});
t.equal(typeof service, 'object', 'service is a object');
t.equal(typeof service.geotrans, 'function', 'geotrans is a function');
t.end();
});
};
module.exports.tests.functionality = (test, common) => {
test('error thrown', (t) => {
var service = proxyquire('../../../service/external', {
'logger': {
get: (section) => {
t.equal(section, 'api');
}
}
});
service.geotrans('4CFG').then(function(response){
t.equal(response, 'ERROR: Invalid MGRS String', 'Geotrans conversion throws error when an invalid coordinate is given');
t.end();
});
});
/*test('error thrown', (t) => {
var service = proxyquire('../../../service/external', {
'logger': {
get: (section) => {
t.equal(section, 'api');
}
}
});
service.geotrans('18TXM9963493438').then(function(response){
t.equal(response, { 'type': 'Feature', 'geometry': { 'type': 'Point', 'coordinates': [ -72.57553258519015, 42.367593344066776 ] }, 'properties': { 'name': '18TXM9963493438' } }, 'Geotrans conversion succeeds and properties are added');
t.end();
});
});*/
};
module.exports.all = (tape, common) => {
function test(name, testFunction) {
return tape('SERVICE /external ' + name, testFunction);
}
for( var testCase in module.exports.tests ){
module.exports.tests[testCase](test, common);
}
};
Loading…
Cancel
Save