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. 9
      test/unit/query/search.js

9
test/unit/query/search.js

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

Loading…
Cancel
Save