Browse Source

Remove singleton expected query object.

test/unit/query/search.js
	-Rather than maintaining a "singleton" expected query object,
	which poses problems for tests that want to slightly modify it
	(for instance, by conditionally adding a constraint to
	`filter.bool.must`), make a function that returns it on demand,
	thereby creating a new one each time.
search-suggest-categories
Severyn Kozak 10 years ago
parent
commit
eca8a82818
  1. 11
      test/unit/query/search.js

11
test/unit/query/search.js

@ -71,7 +71,8 @@ var sort = [
}
];
var expected = {
function createExpectedQuery(){
return {
'query': {
'filtered': {
'query': {
@ -107,8 +108,8 @@ var expected = {
'sort': sort,
'size': 10,
'track_scores': true
};
};
}
module.exports.tests.query = function(test, common) {
test('valid query', function(t) {
var query = generate({
@ -123,7 +124,7 @@ module.exports.tests.query = function(test, common) {
layers: ['test']
});
t.deepEqual(query, expected, 'valid search query');
t.deepEqual(query, createExpectedQuery(), 'valid search query');
t.end();
});
@ -139,7 +140,7 @@ module.exports.tests.query = function(test, common) {
layers: ['test']
});
t.deepEqual(query, expected, 'valid search query');
t.deepEqual(query, createExpectedQuery(), 'valid search query');
t.end();
});

Loading…
Cancel
Save