Skip to content

Commit 37400a6

Browse files
committed
new warning test
1 parent c397608 commit 37400a6

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/query.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,9 @@ class Query {
213213
this.filters.push(propertyOrFilter);
214214
return this;
215215
} else {
216+
process.emitWarning(
217+
'Providing Filter objects is recommended when using .filter'
218+
);
216219
let operator = operatorOrValue as Operator;
217220
if (arguments.length === 2) {
218221
value = operatorOrValue as {};

test/query.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,17 @@ describe('Query', () => {
164164
assert.strictEqual(filter.op, '=');
165165
assert.strictEqual(filter.val, 'Stephen');
166166
});
167+
168+
it('should issue a warning when a Filter instance is not provided', done => {
169+
new Query(['kind1']).filter('name', 'Stephen');
170+
process.on('warning', warning => {
171+
assert.strictEqual(
172+
warning.message,
173+
'Providing Filter objects is recommended when using .filter'
174+
);
175+
done();
176+
});
177+
});
167178
});
168179

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

0 commit comments

Comments
 (0)