Skip to content

Commit

Permalink
Add aggregation tests to Request.
Browse files Browse the repository at this point in the history
  • Loading branch information
mattweber committed Mar 16, 2014
1 parent d300edf commit 41a834e
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions tests/search_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1134,14 +1134,17 @@ exports.search = {
test.done();
},
Request: function (test) {
test.expect(52);
test.expect(56);

var req = ejs.Request(),
matchAll = ejs.MatchAllQuery(),
termQuery = ejs.TermQuery('t', 'v'),
termFilter = ejs.TermFilter('tf', 'vf'),
filterFacet = ejs.FilterFacet('my_filter_facet').filter(termFilter),
termsFacet = ejs.TermsFacet('my_terms_facet').field('author'),
globalAgg = ejs.GlobalAggregation('myglobal'),
termsAgg = ejs.TermsAggregation('termsagg').field('afield'),
filterAgg = ejs.FilterAggregation('filteragg').filter(termFilter),
scriptField = ejs.ScriptField('my_script_field')
.script('doc["my_field_name"].value * 2'),
scriptField2 = ejs.ScriptField('my_script_field2')
Expand Down Expand Up @@ -1268,6 +1271,14 @@ exports.search = {
expected.facets.my_terms_facet = termsFacet.toJSON().my_terms_facet;
doTest();

req.agg(filterAgg);
expected.aggs = filterAgg.toJSON();
doTest();

req.aggregation(globalAgg.agg(termsAgg));
expected.aggs.myglobal = globalAgg.toJSON().myglobal;
doTest();

req.filter(termFilter);
expected.filter = termFilter.toJSON();
doTest();
Expand Down Expand Up @@ -1318,7 +1329,6 @@ exports.search = {

test.strictEqual(req._type(), 'request');


test.throws(function () {
req.query('invalid');
}, TypeError);
Expand All @@ -1327,6 +1337,14 @@ exports.search = {
req.facet('invalid');
}, TypeError);

test.throws(function () {
req.agg('invalid');
}, TypeError);

test.throws(function () {
req.aggregation('invalid');
}, TypeError);

test.throws(function () {
req.filter('invalid');
}, TypeError);
Expand Down

0 comments on commit 41a834e

Please sign in to comment.