Skip to content

Commit

Permalink
new warning test
Browse files Browse the repository at this point in the history
  • Loading branch information
danieljbruce committed Jan 26, 2023
1 parent c397608 commit 37400a6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ class Query {
this.filters.push(propertyOrFilter);
return this;
} else {
process.emitWarning(
'Providing Filter objects is recommended when using .filter'
);
let operator = operatorOrValue as Operator;
if (arguments.length === 2) {
value = operatorOrValue as {};
Expand Down
11 changes: 11 additions & 0 deletions test/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,17 @@ describe('Query', () => {
assert.strictEqual(filter.op, '=');
assert.strictEqual(filter.val, 'Stephen');
});

it('should issue a warning when a Filter instance is not provided', done => {
new Query(['kind1']).filter('name', 'Stephen');
process.on('warning', warning => {
assert.strictEqual(
warning.message,
'Providing Filter objects is recommended when using .filter'
);
done();
});
});
});

describe('filter with Filter class', () => {
Expand Down

0 comments on commit 37400a6

Please sign in to comment.