Browse Source

refactor; add tests

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

2
query/suggest.js

@ -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; 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 = [ var tests = [
require('./controller/index'), require('./controller/index'),
require('./controller/suggest'), require('./controller/suggest'),
require('./sanitiser/suggest') require('./sanitiser/suggest'),
require('./query/indeces'),
require('./query/suggest')
]; ];
tests.map(function(t) { tests.map(function(t) {

Loading…
Cancel
Save