@balena/odata-parser 3.1.1 → 3.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.versionbot/CHANGELOG.yml +12 -1
- package/CHANGELOG.md +5 -0
- package/package.json +14 -14
- package/test/filterby.js +201 -131
- package/test/test.js +1 -1
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
- commits:
|
|
2
|
+
- subject: Update dependencies
|
|
3
|
+
hash: e671fc822a9db4c4aa43fc5b3d46d7c9b2558700
|
|
4
|
+
body: ""
|
|
5
|
+
footer:
|
|
6
|
+
Change-type: patch
|
|
7
|
+
change-type: patch
|
|
8
|
+
author: Pagan Gazzard
|
|
9
|
+
version: 3.1.2
|
|
10
|
+
title: ""
|
|
11
|
+
date: 2024-10-04T15:44:57.990Z
|
|
1
12
|
- commits:
|
|
2
13
|
- subject: Avoid setting `property`/`count`/`options` for expands when not provided
|
|
3
14
|
hash: 1f3e69085a7e4225c648ea55a594895c288c45e2
|
|
@@ -15,7 +26,7 @@
|
|
|
15
26
|
author: Pagan Gazzard
|
|
16
27
|
version: 3.1.1
|
|
17
28
|
title: ""
|
|
18
|
-
date: 2024-10-04T15:
|
|
29
|
+
date: 2024-10-04T15:32:30.651Z
|
|
19
30
|
- commits:
|
|
20
31
|
- subject: Use bind vars for $top and $skip options
|
|
21
32
|
hash: f160a140209cc5c9d3abc617cf8de7a37a0abf16
|
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file
|
|
|
4
4
|
automatically by Versionist. DO NOT EDIT THIS FILE MANUALLY!
|
|
5
5
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
|
6
6
|
|
|
7
|
+
# v3.1.2
|
|
8
|
+
## (2024-10-04)
|
|
9
|
+
|
|
10
|
+
* Update dependencies [Pagan Gazzard]
|
|
11
|
+
|
|
7
12
|
# v3.1.1
|
|
8
13
|
## (2024-10-04)
|
|
9
14
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@balena/odata-parser",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.2",
|
|
4
4
|
"description": "An OData parser written in OMeta",
|
|
5
5
|
"main": "odata-parser.js",
|
|
6
6
|
"scripts": {
|
|
@@ -9,24 +9,24 @@
|
|
|
9
9
|
"test": "mocha",
|
|
10
10
|
"posttest": "npm run lint",
|
|
11
11
|
"prepare": "node -e \"try { (await import('husky')).default() } catch (e) { if (e.code !== 'ERR_MODULE_NOT_FOUND') throw e }\" --input-type module && peggy --source-map --extra-options-file odata-parser.config.json --output odata-parser.js odata-parser.pegjs",
|
|
12
|
-
"
|
|
12
|
+
"lint-fix": "balena-lint -e ts -e js --typescript --fix odata-parser.d.ts test"
|
|
13
13
|
},
|
|
14
14
|
"repository": "https://github.com/balena-io-modules/odata-parser.git",
|
|
15
15
|
"author": "",
|
|
16
16
|
"license": "BSD",
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@balena/lint": "^8.
|
|
19
|
-
"@types/chai": "^4.3.
|
|
20
|
-
"@types/lodash": "^4.
|
|
21
|
-
"@types/mocha": "^10.0.
|
|
22
|
-
"chai": "^4.
|
|
23
|
-
"husky": "^9.
|
|
24
|
-
"lint-staged": "^15.
|
|
18
|
+
"@balena/lint": "^8.2.8",
|
|
19
|
+
"@types/chai": "^4.3.20",
|
|
20
|
+
"@types/lodash": "^4.17.10",
|
|
21
|
+
"@types/mocha": "^10.0.8",
|
|
22
|
+
"chai": "^4.5.0",
|
|
23
|
+
"husky": "^9.1.6",
|
|
24
|
+
"lint-staged": "^15.2.10",
|
|
25
25
|
"lodash": "^4.17.21",
|
|
26
|
-
"mocha": "^10.
|
|
27
|
-
"peggy": "^4.
|
|
28
|
-
"ts-node": "^10.9.
|
|
29
|
-
"typescript": "^5.
|
|
26
|
+
"mocha": "^10.7.3",
|
|
27
|
+
"peggy": "^4.1.1",
|
|
28
|
+
"ts-node": "^10.9.2",
|
|
29
|
+
"typescript": "^5.6.2"
|
|
30
30
|
},
|
|
31
31
|
"mocha": {
|
|
32
32
|
"reporter": "spec",
|
|
@@ -39,6 +39,6 @@
|
|
|
39
39
|
"npm": ">=8.1.0"
|
|
40
40
|
},
|
|
41
41
|
"versionist": {
|
|
42
|
-
"publishedAt": "2024-10-04T15:
|
|
42
|
+
"publishedAt": "2024-10-04T15:44:58.097Z"
|
|
43
43
|
}
|
|
44
44
|
}
|
package/test/filterby.js
CHANGED
|
@@ -151,11 +151,13 @@ export default function (test) {
|
|
|
151
151
|
});
|
|
152
152
|
|
|
153
153
|
test('$filter=Price gt 5 and Price lt 10', [5, 10], function (result) {
|
|
154
|
-
it('A filter should be present', () =>
|
|
155
|
-
assert.notEqual(result.options.$filter, null)
|
|
154
|
+
it('A filter should be present', () => {
|
|
155
|
+
assert.notEqual(result.options.$filter, null);
|
|
156
|
+
});
|
|
156
157
|
|
|
157
|
-
it("Filter should be an instance of 'and'", () =>
|
|
158
|
-
assert.equal(result.options.$filter[0], 'and')
|
|
158
|
+
it("Filter should be an instance of 'and'", () => {
|
|
159
|
+
assert.equal(result.options.$filter[0], 'and');
|
|
160
|
+
});
|
|
159
161
|
|
|
160
162
|
it('Left hand side should be Price gt $0', function () {
|
|
161
163
|
const lhs = result.options.$filter[1];
|
|
@@ -173,11 +175,13 @@ export default function (test) {
|
|
|
173
175
|
});
|
|
174
176
|
|
|
175
177
|
test('$filter=Price eq 5 or Price eq 10', [5, 10], function (result) {
|
|
176
|
-
it('A filter should be present', () =>
|
|
177
|
-
assert.notEqual(result.options.$filter, null)
|
|
178
|
+
it('A filter should be present', () => {
|
|
179
|
+
assert.notEqual(result.options.$filter, null);
|
|
180
|
+
});
|
|
178
181
|
|
|
179
|
-
it("Filter should be an instance of 'or'", () =>
|
|
180
|
-
assert.equal(result.options.$filter[0], 'or')
|
|
182
|
+
it("Filter should be an instance of 'or'", () => {
|
|
183
|
+
assert.equal(result.options.$filter[0], 'or');
|
|
184
|
+
});
|
|
181
185
|
|
|
182
186
|
it('Left hand side should be Price eq $0', function () {
|
|
183
187
|
const lhs = result.options.$filter[1];
|
|
@@ -195,30 +199,37 @@ export default function (test) {
|
|
|
195
199
|
});
|
|
196
200
|
|
|
197
201
|
test('$filter=Published', function (result) {
|
|
198
|
-
it('A filter should be present', () =>
|
|
199
|
-
assert.notEqual(result.options.$filter, null)
|
|
202
|
+
it('A filter should be present', () => {
|
|
203
|
+
assert.notEqual(result.options.$filter, null);
|
|
204
|
+
});
|
|
200
205
|
|
|
201
|
-
it("value should be 'Published'", () =>
|
|
202
|
-
assert.equal(result.options.$filter.name, 'Published')
|
|
206
|
+
it("value should be 'Published'", () => {
|
|
207
|
+
assert.equal(result.options.$filter.name, 'Published');
|
|
208
|
+
});
|
|
203
209
|
});
|
|
204
210
|
|
|
205
211
|
test('$filter=not Published', function (result) {
|
|
206
|
-
it('A filter should be present', () =>
|
|
207
|
-
assert.notEqual(result.options.$filter, null)
|
|
212
|
+
it('A filter should be present', () => {
|
|
213
|
+
assert.notEqual(result.options.$filter, null);
|
|
214
|
+
});
|
|
208
215
|
|
|
209
|
-
it("Filter should be an instance of 'not'", () =>
|
|
210
|
-
assert.equal(result.options.$filter[0], 'not')
|
|
216
|
+
it("Filter should be an instance of 'not'", () => {
|
|
217
|
+
assert.equal(result.options.$filter[0], 'not');
|
|
218
|
+
});
|
|
211
219
|
|
|
212
|
-
it("value should be 'Published'", () =>
|
|
213
|
-
assert.equal(result.options.$filter[1].name, 'Published')
|
|
220
|
+
it("value should be 'Published'", () => {
|
|
221
|
+
assert.equal(result.options.$filter[1].name, 'Published');
|
|
222
|
+
});
|
|
214
223
|
});
|
|
215
224
|
|
|
216
225
|
test('$filter=not (Price gt 5)', [5], function (result) {
|
|
217
|
-
it('A filter should be present', () =>
|
|
218
|
-
assert.notEqual(result.options.$filter, null)
|
|
226
|
+
it('A filter should be present', () => {
|
|
227
|
+
assert.notEqual(result.options.$filter, null);
|
|
228
|
+
});
|
|
219
229
|
|
|
220
|
-
it("Filter should be an instance of 'not'", () =>
|
|
221
|
-
assert.equal(result.options.$filter[0], 'not')
|
|
230
|
+
it("Filter should be an instance of 'not'", () => {
|
|
231
|
+
assert.equal(result.options.$filter[0], 'not');
|
|
232
|
+
});
|
|
222
233
|
|
|
223
234
|
it('Value should be Price gt $0', function () {
|
|
224
235
|
const rhs = result.options.$filter[1];
|
|
@@ -229,14 +240,17 @@ export default function (test) {
|
|
|
229
240
|
});
|
|
230
241
|
|
|
231
242
|
test('$filter=Price in (1, 2, 3)', [1, 2, 3], function (result) {
|
|
232
|
-
it('A filter should be present', () =>
|
|
233
|
-
assert.notEqual(result.options.$filter, null)
|
|
243
|
+
it('A filter should be present', () => {
|
|
244
|
+
assert.notEqual(result.options.$filter, null);
|
|
245
|
+
});
|
|
234
246
|
|
|
235
|
-
it("Filter should be an instance of 'in'", () =>
|
|
236
|
-
assert.equal(result.options.$filter[0], 'in')
|
|
247
|
+
it("Filter should be an instance of 'in'", () => {
|
|
248
|
+
assert.equal(result.options.$filter[0], 'in');
|
|
249
|
+
});
|
|
237
250
|
|
|
238
|
-
it('lhr should be Price', () =>
|
|
239
|
-
assert.equal(result.options.$filter[1].name, 'Price')
|
|
251
|
+
it('lhr should be Price', () => {
|
|
252
|
+
assert.equal(result.options.$filter[1].name, 'Price');
|
|
253
|
+
});
|
|
240
254
|
|
|
241
255
|
it('rhr should be [ $1, $2, $3 ]', function () {
|
|
242
256
|
assert.equal(result.options.$filter[2][0].bind, 0);
|
|
@@ -246,14 +260,17 @@ export default function (test) {
|
|
|
246
260
|
});
|
|
247
261
|
|
|
248
262
|
test('$filter=Price in ((1), ((2)), (((3))))', [1, 2, 3], function (result) {
|
|
249
|
-
it('A filter should be present', () =>
|
|
250
|
-
assert.notEqual(result.options.$filter, null)
|
|
263
|
+
it('A filter should be present', () => {
|
|
264
|
+
assert.notEqual(result.options.$filter, null);
|
|
265
|
+
});
|
|
251
266
|
|
|
252
|
-
it("Filter should be an instance of 'in'", () =>
|
|
253
|
-
assert.equal(result.options.$filter[0], 'in')
|
|
267
|
+
it("Filter should be an instance of 'in'", () => {
|
|
268
|
+
assert.equal(result.options.$filter[0], 'in');
|
|
269
|
+
});
|
|
254
270
|
|
|
255
|
-
it('lhr should be Price', () =>
|
|
256
|
-
assert.equal(result.options.$filter[1].name, 'Price')
|
|
271
|
+
it('lhr should be Price', () => {
|
|
272
|
+
assert.equal(result.options.$filter[1].name, 'Price');
|
|
273
|
+
});
|
|
257
274
|
|
|
258
275
|
it('rhr should be [ $1, $2, $3 ]', function () {
|
|
259
276
|
assert.equal(result.options.$filter[2][0].bind, 0);
|
|
@@ -263,14 +280,17 @@ export default function (test) {
|
|
|
263
280
|
});
|
|
264
281
|
|
|
265
282
|
test("$filter=Price in ('a', 'b', 'c')", ['a', 'b', 'c'], function (result) {
|
|
266
|
-
it('A filter should be present', () =>
|
|
267
|
-
assert.notEqual(result.options.$filter, null)
|
|
283
|
+
it('A filter should be present', () => {
|
|
284
|
+
assert.notEqual(result.options.$filter, null);
|
|
285
|
+
});
|
|
268
286
|
|
|
269
|
-
it("Filter should be an instance of 'in'", () =>
|
|
270
|
-
assert.equal(result.options.$filter[0], 'in')
|
|
287
|
+
it("Filter should be an instance of 'in'", () => {
|
|
288
|
+
assert.equal(result.options.$filter[0], 'in');
|
|
289
|
+
});
|
|
271
290
|
|
|
272
|
-
it('lhr should be Price', () =>
|
|
273
|
-
assert.equal(result.options.$filter[1].name, 'Price')
|
|
291
|
+
it('lhr should be Price', () => {
|
|
292
|
+
assert.equal(result.options.$filter[1].name, 'Price');
|
|
293
|
+
});
|
|
274
294
|
|
|
275
295
|
it('rhr should be [ $1, $2, $3 ]', function () {
|
|
276
296
|
assert.equal(result.options.$filter[2][0].bind, 0);
|
|
@@ -280,11 +300,13 @@ export default function (test) {
|
|
|
280
300
|
});
|
|
281
301
|
|
|
282
302
|
test('$filter=Price add 5 gt 10', [5, 10], function (result) {
|
|
283
|
-
it('A filter should be present', () =>
|
|
284
|
-
assert.notEqual(result.options.$filter, null)
|
|
303
|
+
it('A filter should be present', () => {
|
|
304
|
+
assert.notEqual(result.options.$filter, null);
|
|
305
|
+
});
|
|
285
306
|
|
|
286
|
-
it("Filter should be an instance of 'gt'", () =>
|
|
287
|
-
assert.equal(result.options.$filter[0], 'gt')
|
|
307
|
+
it("Filter should be an instance of 'gt'", () => {
|
|
308
|
+
assert.equal(result.options.$filter[0], 'gt');
|
|
309
|
+
});
|
|
288
310
|
|
|
289
311
|
it('lhr should be Price add $0', function () {
|
|
290
312
|
const rhs = result.options.$filter[1];
|
|
@@ -293,16 +315,19 @@ export default function (test) {
|
|
|
293
315
|
assert.equal(rhs[2].bind, 0);
|
|
294
316
|
});
|
|
295
317
|
|
|
296
|
-
it('rhr should be $1', () =>
|
|
297
|
-
assert.equal(result.options.$filter[2].bind, 1)
|
|
318
|
+
it('rhr should be $1', () => {
|
|
319
|
+
assert.equal(result.options.$filter[2].bind, 1);
|
|
320
|
+
});
|
|
298
321
|
});
|
|
299
322
|
|
|
300
323
|
test('$filter=Price sub 5 gt 10', [5, 10], function (result) {
|
|
301
|
-
it('A filter should be present', () =>
|
|
302
|
-
assert.notEqual(result.options.$filter, null)
|
|
324
|
+
it('A filter should be present', () => {
|
|
325
|
+
assert.notEqual(result.options.$filter, null);
|
|
326
|
+
});
|
|
303
327
|
|
|
304
|
-
it("Filter should be an instance of 'gt'", () =>
|
|
305
|
-
assert.equal(result.options.$filter[0], 'gt')
|
|
328
|
+
it("Filter should be an instance of 'gt'", () => {
|
|
329
|
+
assert.equal(result.options.$filter[0], 'gt');
|
|
330
|
+
});
|
|
306
331
|
|
|
307
332
|
it('lhr should be Price sub $0', function () {
|
|
308
333
|
const rhs = result.options.$filter[1];
|
|
@@ -311,16 +336,19 @@ export default function (test) {
|
|
|
311
336
|
assert.equal(rhs[2].bind, 0);
|
|
312
337
|
});
|
|
313
338
|
|
|
314
|
-
it('rhr should be $1', () =>
|
|
315
|
-
assert.equal(result.options.$filter[2].bind, 1)
|
|
339
|
+
it('rhr should be $1', () => {
|
|
340
|
+
assert.equal(result.options.$filter[2].bind, 1);
|
|
341
|
+
});
|
|
316
342
|
});
|
|
317
343
|
|
|
318
344
|
test('$filter=Price mul 5 gt 10', [5, 10], function (result) {
|
|
319
|
-
it('A filter should be present', () =>
|
|
320
|
-
assert.notEqual(result.options.$filter, null)
|
|
345
|
+
it('A filter should be present', () => {
|
|
346
|
+
assert.notEqual(result.options.$filter, null);
|
|
347
|
+
});
|
|
321
348
|
|
|
322
|
-
it("Filter should be an instance of 'gt'", () =>
|
|
323
|
-
assert.equal(result.options.$filter[0], 'gt')
|
|
349
|
+
it("Filter should be an instance of 'gt'", () => {
|
|
350
|
+
assert.equal(result.options.$filter[0], 'gt');
|
|
351
|
+
});
|
|
324
352
|
|
|
325
353
|
it('lhr should be Price add $0', function () {
|
|
326
354
|
const lhs = result.options.$filter[1];
|
|
@@ -329,16 +357,19 @@ export default function (test) {
|
|
|
329
357
|
assert.equal(lhs[2].bind, 0);
|
|
330
358
|
});
|
|
331
359
|
|
|
332
|
-
it('rhr should be $1', () =>
|
|
333
|
-
assert.equal(result.options.$filter[2].bind, 1)
|
|
360
|
+
it('rhr should be $1', () => {
|
|
361
|
+
assert.equal(result.options.$filter[2].bind, 1);
|
|
362
|
+
});
|
|
334
363
|
});
|
|
335
364
|
|
|
336
365
|
test('$filter=Price div Price mul 5 gt 10', [5, 10], function (result) {
|
|
337
|
-
it('A filter should be present', () =>
|
|
338
|
-
assert.notEqual(result.options.$filter, null)
|
|
366
|
+
it('A filter should be present', () => {
|
|
367
|
+
assert.notEqual(result.options.$filter, null);
|
|
368
|
+
});
|
|
339
369
|
|
|
340
|
-
it("Filter should be an instance of 'gt'", () =>
|
|
341
|
-
assert.equal(result.options.$filter[0], 'gt')
|
|
370
|
+
it("Filter should be an instance of 'gt'", () => {
|
|
371
|
+
assert.equal(result.options.$filter[0], 'gt');
|
|
372
|
+
});
|
|
342
373
|
|
|
343
374
|
const lexpr = result?.options?.$filter?.[1];
|
|
344
375
|
|
|
@@ -353,16 +384,19 @@ export default function (test) {
|
|
|
353
384
|
assert.equal(lexpr[2][2].bind, 0);
|
|
354
385
|
});
|
|
355
386
|
|
|
356
|
-
it('rhr should be $1', () =>
|
|
357
|
-
assert.equal(result.options.$filter[2].bind, 1)
|
|
387
|
+
it('rhr should be $1', () => {
|
|
388
|
+
assert.equal(result.options.$filter[2].bind, 1);
|
|
389
|
+
});
|
|
358
390
|
});
|
|
359
391
|
|
|
360
392
|
test('$filter=(Price div Price) mul 5 gt 10', [5, 10], function (result) {
|
|
361
|
-
it('A filter should be present', () =>
|
|
362
|
-
assert.notEqual(result.options.$filter, null)
|
|
393
|
+
it('A filter should be present', () => {
|
|
394
|
+
assert.notEqual(result.options.$filter, null);
|
|
395
|
+
});
|
|
363
396
|
|
|
364
|
-
it("Filter should be an instance of 'gt'", () =>
|
|
365
|
-
assert.equal(result.options.$filter[0], 'gt')
|
|
397
|
+
it("Filter should be an instance of 'gt'", () => {
|
|
398
|
+
assert.equal(result.options.$filter[0], 'gt');
|
|
399
|
+
});
|
|
366
400
|
|
|
367
401
|
const lexpr = result?.options?.$filter?.[1];
|
|
368
402
|
|
|
@@ -377,16 +411,19 @@ export default function (test) {
|
|
|
377
411
|
assert.equal(lexpr[1][2].name, 'Price');
|
|
378
412
|
});
|
|
379
413
|
|
|
380
|
-
it('rhr should be $1', () =>
|
|
381
|
-
assert.equal(result.options.$filter[2].bind, 1)
|
|
414
|
+
it('rhr should be $1', () => {
|
|
415
|
+
assert.equal(result.options.$filter[2].bind, 1);
|
|
416
|
+
});
|
|
382
417
|
});
|
|
383
418
|
|
|
384
419
|
test('$filter=Products/$count eq 10', [10], function (result) {
|
|
385
|
-
it('A filter should be present', () =>
|
|
386
|
-
assert.notEqual(result.options.$filter, null)
|
|
420
|
+
it('A filter should be present', () => {
|
|
421
|
+
assert.notEqual(result.options.$filter, null);
|
|
422
|
+
});
|
|
387
423
|
|
|
388
|
-
it("Filter should be an instance of 'eq'", () =>
|
|
389
|
-
assert.equal(result.options.$filter[0], 'eq')
|
|
424
|
+
it("Filter should be an instance of 'eq'", () => {
|
|
425
|
+
assert.equal(result.options.$filter[0], 'eq');
|
|
426
|
+
});
|
|
390
427
|
|
|
391
428
|
it('lhr should be Foo', function () {
|
|
392
429
|
expect(result.options.$filter[1])
|
|
@@ -397,19 +434,22 @@ export default function (test) {
|
|
|
397
434
|
.that.equals(true);
|
|
398
435
|
});
|
|
399
436
|
|
|
400
|
-
it('rhr should be $0', () =>
|
|
401
|
-
assert.equal(result.options.$filter[2].bind, 0)
|
|
437
|
+
it('rhr should be $0', () => {
|
|
438
|
+
assert.equal(result.options.$filter[2].bind, 0);
|
|
439
|
+
});
|
|
402
440
|
});
|
|
403
441
|
|
|
404
442
|
test(
|
|
405
443
|
'$filter=Products/$count($filter=Price lt 5) ge 1',
|
|
406
444
|
[5, 1],
|
|
407
445
|
function (result) {
|
|
408
|
-
it('A filter should be present', () =>
|
|
409
|
-
assert.notEqual(result.options.$filter, null)
|
|
446
|
+
it('A filter should be present', () => {
|
|
447
|
+
assert.notEqual(result.options.$filter, null);
|
|
448
|
+
});
|
|
410
449
|
|
|
411
|
-
it("Filter should be an instance of 'ge'", () =>
|
|
412
|
-
assert.equal(result.options.$filter[0], 'ge')
|
|
450
|
+
it("Filter should be an instance of 'ge'", () => {
|
|
451
|
+
assert.equal(result.options.$filter[0], 'ge');
|
|
452
|
+
});
|
|
413
453
|
|
|
414
454
|
it('lhr should have the Product count', function () {
|
|
415
455
|
expect(result.options.$filter[1])
|
|
@@ -424,8 +464,9 @@ export default function (test) {
|
|
|
424
464
|
assert.notEqual(result.options.$filter[1].options, null);
|
|
425
465
|
});
|
|
426
466
|
|
|
427
|
-
it('A filter should be present on the Product count lhs', () =>
|
|
428
|
-
assert.notEqual(result.options.$filter[1].options.$filter, null)
|
|
467
|
+
it('A filter should be present on the Product count lhs', () => {
|
|
468
|
+
assert.notEqual(result.options.$filter[1].options.$filter, null);
|
|
469
|
+
});
|
|
429
470
|
|
|
430
471
|
it(`has a Product count filter that is an instance of 'lt'`, () => {
|
|
431
472
|
assert.equal(result.options.$filter[1].options.$filter[0], 'lt');
|
|
@@ -453,11 +494,13 @@ export default function (test) {
|
|
|
453
494
|
'$filter=Products/$count($filter=Price gt 5 and Price lt 10) ge 1',
|
|
454
495
|
[5, 10, 1],
|
|
455
496
|
function (result) {
|
|
456
|
-
it('A filter should be present', () =>
|
|
457
|
-
assert.notEqual(result.options.$filter, null)
|
|
497
|
+
it('A filter should be present', () => {
|
|
498
|
+
assert.notEqual(result.options.$filter, null);
|
|
499
|
+
});
|
|
458
500
|
|
|
459
|
-
it("Filter should be an instance of 'ge'", () =>
|
|
460
|
-
assert.equal(result.options.$filter[0], 'ge')
|
|
501
|
+
it("Filter should be an instance of 'ge'", () => {
|
|
502
|
+
assert.equal(result.options.$filter[0], 'ge');
|
|
503
|
+
});
|
|
461
504
|
|
|
462
505
|
it('lhr should have the Product count', function () {
|
|
463
506
|
expect(result.options.$filter[1]).to.have.property('name', 'Products');
|
|
@@ -468,11 +511,13 @@ export default function (test) {
|
|
|
468
511
|
assert.notEqual(result.options.$filter[1].options, null);
|
|
469
512
|
});
|
|
470
513
|
|
|
471
|
-
it('A filter should be present on the Product count lhs', () =>
|
|
472
|
-
assert.notEqual(result.options.$filter[1].options.$filter, null)
|
|
514
|
+
it('A filter should be present on the Product count lhs', () => {
|
|
515
|
+
assert.notEqual(result.options.$filter[1].options.$filter, null);
|
|
516
|
+
});
|
|
473
517
|
|
|
474
|
-
it(`has a Product count filter that is an instance of 'and'`, () =>
|
|
475
|
-
assert.equal(result.options.$filter[1].options.$filter[0], 'and')
|
|
518
|
+
it(`has a Product count filter that is an instance of 'and'`, () => {
|
|
519
|
+
assert.equal(result.options.$filter[1].options.$filter[0], 'and');
|
|
520
|
+
});
|
|
476
521
|
|
|
477
522
|
it(`has an lhs on the 'and' of the Product count filter that is Price gt $0`, () => {
|
|
478
523
|
const filter = result.options.$filter[1].options.$filter[1];
|
|
@@ -495,19 +540,22 @@ export default function (test) {
|
|
|
495
540
|
);
|
|
496
541
|
|
|
497
542
|
test("$filter=note eq 'foobar'", ['foobar'], function (result) {
|
|
498
|
-
it('A filter should be present', () =>
|
|
499
|
-
assert.notEqual(result.options.$filter, null)
|
|
543
|
+
it('A filter should be present', () => {
|
|
544
|
+
assert.notEqual(result.options.$filter, null);
|
|
545
|
+
});
|
|
500
546
|
|
|
501
|
-
it("Filter should be an instance of 'eq'", () =>
|
|
502
|
-
assert.equal(result.options.$filter[0], 'eq')
|
|
547
|
+
it("Filter should be an instance of 'eq'", () => {
|
|
548
|
+
assert.equal(result.options.$filter[0], 'eq');
|
|
549
|
+
});
|
|
503
550
|
|
|
504
551
|
it('lhr should be Foo', () =>
|
|
505
552
|
expect(result.options.$filter[1])
|
|
506
553
|
.to.have.property('name')
|
|
507
554
|
.that.equals('note'));
|
|
508
555
|
|
|
509
|
-
it('rhr should be $0', () =>
|
|
510
|
-
assert.equal(result.options.$filter[2].bind, 0)
|
|
556
|
+
it('rhr should be $0', () => {
|
|
557
|
+
assert.equal(result.options.$filter[2].bind, 0);
|
|
558
|
+
});
|
|
511
559
|
});
|
|
512
560
|
|
|
513
561
|
const methodTest = (args, binds, argsTest) => (methodName, expectFailure) =>
|
|
@@ -516,28 +564,33 @@ export default function (test) {
|
|
|
516
564
|
binds.concat('cake'),
|
|
517
565
|
function (result, err) {
|
|
518
566
|
if (expectFailure) {
|
|
519
|
-
it("Should fail because it's invalid", () =>
|
|
520
|
-
assert.notEqual(err, null)
|
|
567
|
+
it("Should fail because it's invalid", () => {
|
|
568
|
+
assert.notEqual(err, null);
|
|
569
|
+
});
|
|
521
570
|
} else if (err) {
|
|
522
571
|
throw err;
|
|
523
572
|
}
|
|
524
573
|
|
|
525
|
-
it('A filter should be present', () =>
|
|
526
|
-
assert.notEqual(result.options.$filter, null)
|
|
574
|
+
it('A filter should be present', () => {
|
|
575
|
+
assert.notEqual(result.options.$filter, null);
|
|
576
|
+
});
|
|
527
577
|
|
|
528
|
-
it("Filter should be an instance of 'eq'", () =>
|
|
529
|
-
assert.equal(result.options.$filter[0], 'eq')
|
|
578
|
+
it("Filter should be an instance of 'eq'", () => {
|
|
579
|
+
assert.equal(result.options.$filter[0], 'eq');
|
|
580
|
+
});
|
|
530
581
|
|
|
531
|
-
it('lhs should be a call', () =>
|
|
532
|
-
assert.equal(result.options.$filter[1][0], 'call')
|
|
582
|
+
it('lhs should be a call', () => {
|
|
583
|
+
assert.equal(result.options.$filter[1][0], 'call');
|
|
584
|
+
});
|
|
533
585
|
|
|
534
586
|
it(`lhs should be ${methodName} with correct args`, function () {
|
|
535
587
|
assert.equal(result.options.$filter[1][1].method, methodName);
|
|
536
588
|
argsTest(result.options.$filter[1][1].args);
|
|
537
589
|
});
|
|
538
590
|
|
|
539
|
-
it('rhs should be bound to the last arg', () =>
|
|
540
|
-
assert.equal(result.options.$filter[2].bind, binds.length)
|
|
591
|
+
it('rhs should be bound to the last arg', () => {
|
|
592
|
+
assert.equal(result.options.$filter[2].bind, binds.length);
|
|
593
|
+
});
|
|
541
594
|
},
|
|
542
595
|
);
|
|
543
596
|
|
|
@@ -563,12 +616,14 @@ export default function (test) {
|
|
|
563
616
|
const methodTestWithOneArg = methodTest(
|
|
564
617
|
"'alfred'",
|
|
565
618
|
['alfred'],
|
|
566
|
-
(argsResult) =>
|
|
619
|
+
(argsResult) => {
|
|
620
|
+
assert.equal(argsResult[0].bind, 0);
|
|
621
|
+
},
|
|
567
622
|
);
|
|
568
623
|
|
|
569
|
-
const methodTestWithZeroArg = methodTest('', [], (argsResult) =>
|
|
570
|
-
assert.equal(argsResult.length, 0)
|
|
571
|
-
);
|
|
624
|
+
const methodTestWithZeroArg = methodTest('', [], (argsResult) => {
|
|
625
|
+
assert.equal(argsResult.length, 0);
|
|
626
|
+
});
|
|
572
627
|
|
|
573
628
|
methodTestWithTwoArgs('contains');
|
|
574
629
|
methodTestWithTwoArgs('endswith');
|
|
@@ -615,13 +670,17 @@ export default function (test) {
|
|
|
615
670
|
|
|
616
671
|
const lambdaTest = function (methodName) {
|
|
617
672
|
const lambdaAsserts = function (lambda, alias = 'd') {
|
|
618
|
-
it('where it is a lambda', () =>
|
|
673
|
+
it('where it is a lambda', () => {
|
|
674
|
+
assert.notEqual(lambda, null);
|
|
675
|
+
});
|
|
619
676
|
|
|
620
|
-
it(`of type '${methodName}'`, () =>
|
|
621
|
-
assert.equal(lambda.method, methodName)
|
|
677
|
+
it(`of type '${methodName}'`, () => {
|
|
678
|
+
assert.equal(lambda.method, methodName);
|
|
679
|
+
});
|
|
622
680
|
|
|
623
|
-
it(`with the element identified by '${alias}'`, () =>
|
|
624
|
-
assert.equal(lambda.identifier, alias)
|
|
681
|
+
it(`with the element identified by '${alias}'`, () => {
|
|
682
|
+
assert.equal(lambda.identifier, alias);
|
|
683
|
+
});
|
|
625
684
|
|
|
626
685
|
it('and an expression that is d/name', function () {
|
|
627
686
|
assert.equal(lambda.expression[1].name, alias);
|
|
@@ -629,9 +688,13 @@ export default function (test) {
|
|
|
629
688
|
assert.equal(lambda.expression[1].property.property, null);
|
|
630
689
|
});
|
|
631
690
|
|
|
632
|
-
it("'eq'", () =>
|
|
691
|
+
it("'eq'", () => {
|
|
692
|
+
assert.equal(lambda.expression[0], 'eq');
|
|
693
|
+
});
|
|
633
694
|
|
|
634
|
-
it('$0', () =>
|
|
695
|
+
it('$0', () => {
|
|
696
|
+
assert.equal(lambda.expression[2].bind, 0);
|
|
697
|
+
});
|
|
635
698
|
};
|
|
636
699
|
|
|
637
700
|
test(
|
|
@@ -642,11 +705,13 @@ export default function (test) {
|
|
|
642
705
|
throw err;
|
|
643
706
|
}
|
|
644
707
|
|
|
645
|
-
it('A filter should be present', () =>
|
|
646
|
-
assert.notEqual(result.options.$filter, null)
|
|
708
|
+
it('A filter should be present', () => {
|
|
709
|
+
assert.notEqual(result.options.$filter, null);
|
|
710
|
+
});
|
|
647
711
|
|
|
648
|
-
it('Filter should be on the child resource', () =>
|
|
649
|
-
assert.equal(result.options.$filter.name, 'child')
|
|
712
|
+
it('Filter should be on the child resource', () => {
|
|
713
|
+
assert.equal(result.options.$filter.name, 'child');
|
|
714
|
+
});
|
|
650
715
|
|
|
651
716
|
lambdaAsserts(result?.options?.$filter?.lambda);
|
|
652
717
|
},
|
|
@@ -660,11 +725,13 @@ export default function (test) {
|
|
|
660
725
|
throw err;
|
|
661
726
|
}
|
|
662
727
|
|
|
663
|
-
it('A filter should be present', () =>
|
|
664
|
-
assert.notEqual(result.options.$filter, null)
|
|
728
|
+
it('A filter should be present', () => {
|
|
729
|
+
assert.notEqual(result.options.$filter, null);
|
|
730
|
+
});
|
|
665
731
|
|
|
666
|
-
it('Filter should be on the child resource', () =>
|
|
667
|
-
assert.equal(result.options.$filter.name, 'child')
|
|
732
|
+
it('Filter should be on the child resource', () => {
|
|
733
|
+
assert.equal(result.options.$filter.name, 'child');
|
|
734
|
+
});
|
|
668
735
|
|
|
669
736
|
lambdaAsserts(result?.options?.$filter?.lambda, 'long_name');
|
|
670
737
|
},
|
|
@@ -678,8 +745,9 @@ export default function (test) {
|
|
|
678
745
|
throw err;
|
|
679
746
|
}
|
|
680
747
|
|
|
681
|
-
it('A filter should be present', () =>
|
|
682
|
-
assert.notEqual(result.options.$filter, null)
|
|
748
|
+
it('A filter should be present', () => {
|
|
749
|
+
assert.notEqual(result.options.$filter, null);
|
|
750
|
+
});
|
|
683
751
|
|
|
684
752
|
it('Filter should be on the child/grandchild resource', function () {
|
|
685
753
|
assert.equal(result.options.$filter.name, 'child');
|
|
@@ -700,11 +768,13 @@ export default function (test) {
|
|
|
700
768
|
throw err;
|
|
701
769
|
}
|
|
702
770
|
|
|
703
|
-
it('A filter should be present', () =>
|
|
704
|
-
assert.notEqual(result.options.$filter, null)
|
|
771
|
+
it('A filter should be present', () => {
|
|
772
|
+
assert.notEqual(result.options.$filter, null);
|
|
773
|
+
});
|
|
705
774
|
|
|
706
|
-
it('Filter should be on the child resource', () =>
|
|
707
|
-
assert.equal(result.options.$filter.name, 'child')
|
|
775
|
+
it('Filter should be on the child resource', () => {
|
|
776
|
+
assert.equal(result.options.$filter.name, 'child');
|
|
777
|
+
});
|
|
708
778
|
|
|
709
779
|
it('Filter should show the canAccess method', function () {
|
|
710
780
|
expect(result.options.$filter).to.have.property('method');
|
package/test/test.js
CHANGED