Skip to content

Commit 8304319

Browse files
committed
Tests: remove lodash
Change-type: patch
1 parent d60a63f commit 8304319

4 files changed

Lines changed: 10 additions & 15 deletions

File tree

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,10 @@
1818
"devDependencies": {
1919
"@balena/lint": "^9.2.1",
2020
"@types/chai": "^4.3.20",
21-
"@types/lodash": "^4.17.10",
2221
"@types/mocha": "^10.0.8",
2322
"chai": "^4.5.0",
2423
"husky": "^9.1.6",
2524
"lint-staged": "^16.0.0",
26-
"lodash": "^4.17.21",
2725
"mocha": "^11.0.0",
2826
"peggy": "^5.0.0",
2927
"ts-node": "^10.9.2",

test/filterby.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import * as assert from 'assert';
22
import { expect } from 'chai';
3-
import * as _ from 'lodash';
43
import type { ExpectationFn, TestFn } from './test';
54

65
type Duration = {
@@ -19,7 +18,7 @@ export default function (test: TestFn) {
1918
value: typeof odataValue | Duration = odataValue,
2019
) {
2120
const binds: Array<string | number | boolean> = [];
22-
if (value != null && !_.isObject(value)) {
21+
if (value != null && typeof value !== 'object') {
2322
binds.push(value);
2423
}
2524
test(`$filter=Foo ${op} ${odataValue}`, binds, function (result) {
@@ -35,7 +34,7 @@ export default function (test: TestFn) {
3534
.to.have.property('name')
3635
.that.equals('Foo'));
3736

38-
if (odataValue === null || _.isObject(value)) {
37+
if (odataValue === null || typeof value === 'object') {
3938
it(`rhr should be ${value}`, () => {
4039
expect(result.options.$filter[2]).to.deep.equal(value);
4140
});
@@ -56,7 +55,7 @@ export default function (test: TestFn) {
5655
expect(result.options.$filter[0]).to.equal(op);
5756
});
5857

59-
if (odataValue === null || _.isObject(value)) {
58+
if (odataValue === null || typeof value === 'object') {
6059
it(`lhr should be ${value}`, () =>
6160
expect(result.options.$filter[1]).to.deep.equal(value));
6261
} else {

test/stress.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import test from './test';
22
import * as assert from 'assert';
3-
import * as _ from 'lodash';
43

54
describe('Stress Testing', function () {
6-
const ids = _.range(1, 2000);
5+
const ids = Array.from({ length: 1999 }, (_, i) => i + 1);
76
const filterString = ids.map((i) => 'id eq ' + i).join(' or ');
87
test('$filter=' + filterString, ids, (result) => {
98
it('A filter should be present', () => {

test/test.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import * as ODataParser from '../odata-parser';
22
import { expect } from 'chai';
3-
import * as _ from 'lodash';
43

54
type BindPrimitive = number | string | boolean | object;
65
const getBindType = function (value: BindPrimitive) {
7-
if (_.isNumber(value)) {
6+
if (typeof value === 'number') {
87
return ['Real', value];
9-
} else if (_.isString(value)) {
8+
} else if (typeof value === 'string') {
109
return ['Text', value];
11-
} else if (_.isBoolean(value)) {
10+
} else if (typeof value === 'boolean') {
1211
return ['Boolean', value];
1312
} else {
1413
return value;
@@ -61,11 +60,11 @@ function raw(
6160
const expectation = optArgs.pop() as ExpectationFn;
6261
const [binds = [], options = { startRule: 'Process' }, params = {}] =
6362
optArgs as any as [binds?: Binds, opts?: Opts, params?: Params];
64-
const processedBinds = _.map(binds, getBindType) as Binds &
63+
const processedBinds = binds.map(getBindType) as Binds &
6564
Record<string, BindPrimitive>;
66-
_.each(params, (value, key) => {
65+
for (const [key, value] of Object.entries(params)) {
6766
processedBinds[key] = getBindType(value);
68-
});
67+
}
6968
describe(`Parsing ${input}`, function () {
7069
let result;
7170
try {

0 commit comments

Comments
 (0)