Browse Source

refactor; add tests

pull/7/head
Peter Johnson 10 years ago
parent
commit
2fd67fcc58
  1. 4
      query/suggest.js
  2. 23
      test/unit/query/indeces.js
  3. 29
      test/unit/query/suggest.js
  4. 4
      test/unit/run.js

4
query/suggest.js

@ -3,7 +3,7 @@ var logger = require('../src/logger');
// Build pelias suggest query
function generate( params ){
var cmd = {
'pelias' : {
'text' : params.input,
@ -23,7 +23,7 @@ function generate( params ){
}
};
logger.log( 'cmd', JSON.stringify( cmd, null, 2 ) );
// logger.log( 'cmd', JSON.stringify( cmd, null, 2 ) );
return cmd;
}

23
test/unit/query/indeces.js

@ -0,0 +1,23 @@
var indeces = require('../../../query/indeces');
module.exports.tests = {};
module.exports.tests.interface = function(test, common) {
test('valid interface', function(t) {
t.true(Array.isArray(indeces), 'valid array');
t.equal(indeces.length, 7, 'valid array');
t.end();
});
};
module.exports.all = function (tape, common) {
function test(name, testFunction) {
return tape('indeces ' + name, testFunction);
}
for( var testCase in module.exports.tests ){
module.exports.tests[testCase](test, common);
}
};

29
test/unit/query/suggest.js

@ -0,0 +1,29 @@
var query = require('../../../query/suggest');
module.exports.tests = {};
module.exports.tests.interface = function(test, common) {
test('valid interface', function(t) {
t.equal(typeof query, 'function', 'valid function');
t.end();
});
};
module.exports.tests.interface = function(test, common) {
test('valid interface', function(t) {
t.equal(typeof query, 'function', 'valid function');
t.end();
});
};
module.exports.all = function (tape, common) {
function test(name, testFunction) {
return tape('suggest query ' + name, testFunction);
}
for( var testCase in module.exports.tests ){
module.exports.tests[testCase](test, common);
}
};

4
test/unit/run.js

@ -5,7 +5,9 @@ var common = {};
var tests = [
require('./controller/index'),
require('./controller/suggest'),
require('./sanitiser/suggest')
require('./sanitiser/suggest'),
require('./query/indeces'),
require('./query/suggest')
];
tests.map(function(t) {

Loading…
Cancel
Save