Skip to content

Commit 483a71d

Browse files
committed
Use .filter the old way
Revert changes on the .filter method
1 parent c6f0f4e commit 483a71d

File tree

1 file changed

+15
-20
lines changed

1 file changed

+15
-20
lines changed

test/query.ts

+15-20
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {beforeEach, describe, it} from 'mocha';
1717
// eslint-disable-next-line @typescript-eslint/no-var-requires
1818
const {Query} = require('../src/query');
1919
// eslint-disable-next-line @typescript-eslint/no-var-requires
20-
import {and, Datastore} from '../src';
20+
import {Datastore} from '../src';
2121
import {AggregateField, AggregateQuery} from '../src/aggregate';
2222
import {PropertyFilter, EntityFilter, or} from '../src/filter';
2323
import {entity} from '../src/entity';
@@ -208,9 +208,7 @@ describe('Query', () => {
208208
describe('filter', () => {
209209
it('should support filtering', () => {
210210
const now = new Date();
211-
const query = new Query(['kind1']).filter(
212-
new PropertyFilter('date', '<=', now)
213-
);
211+
const query = new Query(['kind1']).filter('date', '<=', now);
214212
const filter = query.filters[0];
215213

216214
assert.strictEqual(filter.name, 'date');
@@ -220,18 +218,15 @@ describe('Query', () => {
220218

221219
it('should recognize all the different operators', () => {
222220
const now = new Date();
223-
const query = new Query(['kind1']).filter(
224-
and([
225-
new PropertyFilter('date', '<=', now),
226-
new PropertyFilter('name', '=', 'Title'),
227-
new PropertyFilter('count', '>', 20),
228-
new PropertyFilter('size', '<', 10),
229-
new PropertyFilter('something', '>=', 11),
230-
new PropertyFilter('neProperty', '!=', 12),
231-
new PropertyFilter('inProperty', 'IN', 13),
232-
new PropertyFilter('notInProperty', 'NOT_IN', 14),
233-
])
234-
);
221+
const query = new Query(['kind1'])
222+
.filter('date', '<=', now)
223+
.filter('name', '=', 'Title')
224+
.filter('count', '>', 20)
225+
.filter('size', '<', 10)
226+
.filter('something', '>=', 11)
227+
.filter('neProperty', '!=', 12)
228+
.filter('inProperty', 'IN', 13)
229+
.filter('notInProperty', 'NOT_IN', 14);
235230

236231
assert.strictEqual(query.filters[0].name, 'date');
237232
assert.strictEqual(query.filters[0].op, '<=');
@@ -267,16 +262,16 @@ describe('Query', () => {
267262
});
268263

269264
it('should remove any whitespace surrounding the filter name', () => {
270-
const query = new Query(['kind1']).filter(
271-
new PropertyFilter(' count ', '>', 123)
272-
);
265+
const query = new Query(['kind1']).filter(' count ', '>', 123);
273266

274267
assert.strictEqual(query.filters[0].name, 'count');
275268
});
276269

277270
it('should remove any whitespace surrounding the operator', () => {
278271
const query = new Query(['kind1']).filter(
279-
new PropertyFilter('count', ' < ', 123)
272+
'count',
273+
' < ',
274+
123
280275
);
281276

282277
assert.strictEqual(query.filters[0].op, '<');

0 commit comments

Comments
 (0)