Skip to content

Commit

Permalink
Improve test case for modifierFiltersResults parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex committed Dec 14, 2020
1 parent 4eafd5e commit 9c0a4ea
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2105,25 +2105,38 @@ describe('Feathers Objection Service', () => {
};

return companies.find({
query: { $modify: ['google'] }, modifierFiltersResults: false
query: { $modify: ['withRelationAndGroupBy'] }, modifierFiltersResults: false
}).then(data => {
expect(data.total).to.be.equal(2);
expect(data.data.length).to.be.equal(1);
expect(data.data.length).to.be.equal(2);
expect(data.data[0].name).to.be.equal('Google');
});
});

it('params.modifierFiltersResults=true does not apply count from modify query', () => {
it('params.modifierFiltersResults=true applies count from modify query', () => {
companies.options.paginate = {
default: 2,
max: 2
};

return companies.find({
query: { $modify: ['google'] }, modifierFiltersResults: true
query: { $modify: ['withRelationAndGroupBy'] }, modifierFiltersResults: true
}).then(data => {
expect(data.total).to.be.equal(1);
expect(data.data.length).to.be.equal(1);
expect(data.total).to.be.equal(1); // count result from GROUP BY
expect(data.data.length).to.be.equal(2);
expect(data.data[0].name).to.be.equal('Google');
});
});

it('params.modifierFiltersResults=undefined applies count from modify query', () => {
companies.options.paginate = {
default: 2,
max: 2
};

return companies.find({query: { $modify: ['withRelationAndGroupBy'] }}).then(data => {
expect(data.total).to.be.equal(1); // count result from GROUP BY
expect(data.data.length).to.be.equal(2);
expect(data.data[0].name).to.be.equal('Google');
});
});
Expand Down

0 comments on commit 9c0a4ea

Please sign in to comment.