Skip to content

Commit b0fbd5c

Browse files
committed
fixup: remaining comments
1 parent 20ac274 commit b0fbd5c

File tree

3 files changed

+54
-34
lines changed

3 files changed

+54
-34
lines changed

src/camundaBuiltins.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,21 @@
66
* Make sure you edit the template file `tasks/camundaBuiltins.template.js` and run `compile:builtins` (or `update:builtins`) to update the file in lib.
77
*/
88

9+
/**
10+
* @typedef { {
11+
* name: string,
12+
* info: string,
13+
* type?: 'function',
14+
* params?: Array<{
15+
* name: string;
16+
* }>
17+
* } } Builtin
18+
*/
19+
920
/**
1021
* List of standard FEEL built-in functions (excluding Camunda-specific extensions).
1122
*
12-
* @type { import("../dist/index.d.ts").Builtin[] }
23+
* @type {Builtin[] }
1324
*/
1425
export const feelBuiltins = [
1526
{
@@ -1353,7 +1364,7 @@ export const feelBuiltins = [
13531364
/**
13541365
* List of FEEL camunda extensions.
13551366
*
1356-
* @type { import("../dist/index.d.ts").Builtin[] }
1367+
* @type {Builtin[] }
13571368
*/
13581369
export const camundaExtensions = [
13591370
{
@@ -1662,14 +1673,14 @@ export const camundaExtensions = [
16621673
/**
16631674
* Collection of builtins of camunda scala FEEL.
16641675
*
1665-
* @type { import("../dist/index.d.ts").Builtin[] }
1676+
* @type {Builtin[] }
16661677
*/
16671678
export const camundaBuiltins = [ ...feelBuiltins, ...camundaExtensions ];
16681679

16691680
/**
16701681
* Functions using reserved keywords in their name and need to be added to the parser context.
16711682
*
1672-
* @type { import("../dist/index.d.ts").Builtin[] }
1683+
* @type {Builtin[] }
16731684
*/
16741685
export const reservedNameBuiltins = [
16751686
{

tasks/camundaBuiltins.template.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,41 @@
66
* Make sure you edit the template file `tasks/camundaBuiltins.template.js` and run `compile:builtins` (or `update:builtins`) to update the file in lib.
77
*/
88

9+
/**
10+
* @typedef { {
11+
* name: string,
12+
* info: string,
13+
* type?: 'function',
14+
* params?: Array<{
15+
* name: string;
16+
* }>
17+
* } } Builtin
18+
*/
19+
920
/**
1021
* List of standard FEEL built-in functions (excluding Camunda-specific extensions).
1122
*
12-
* @type { import("../dist/index.d.ts").Builtin[] }
23+
* @type {Builtin[] }
1324
*/
1425
export const feelBuiltins = /** FEEL_BUILTINS_PLACEHOLDER */ [];
1526

1627
/**
1728
* List of FEEL camunda extensions.
1829
*
19-
* @type { import("../dist/index.d.ts").Builtin[] }
30+
* @type {Builtin[] }
2031
*/
2132
export const camundaExtensions = /** CAMUNDA_EXTENSIONS_PLACEHOLDER */ [];
2233

2334
/**
2435
* Collection of builtins of camunda scala FEEL.
2536
*
26-
* @type { import("../dist/index.d.ts").Builtin[] }
37+
* @type {Builtin[] }
2738
*/
2839
export const camundaBuiltins = [ ...feelBuiltins, ...camundaExtensions ];
2940

3041
/**
3142
* Functions using reserved keywords in their name and need to be added to the parser context.
3243
*
33-
* @type { import("../dist/index.d.ts").Builtin[] }
44+
* @type {Builtin[] }
3445
*/
3546
export const reservedNameBuiltins = /** RESERVED_NAME_BUILTINS_PLACEHOLDER */ [];

test/spec/lib/camundaBuiltins.spec.js

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,36 @@ import { expect } from 'chai';
33
import { camundaBuiltins, feelBuiltins, camundaExtensions, reservedNameBuiltins } from '@camunda/feel-builtins';
44

55

6-
describe('lib/camundaBuiltins', function() {
6+
describe('camundaBuiltins', function() {
77

8-
it('should export ALL built-ins', function() {
8+
it('should export ALL builtins', function() {
9+
10+
// testing if the count of builtin changes, if it does we have to adjust from chore to feat and do a minor release
911

1012
// then
1113
expect(camundaBuiltins).to.be.an('array').with.length(135);
14+
expect(reservedNameBuiltins).to.be.an('array').with.length(1);
1215
});
1316

1417

1518
it('should export feelBuiltins', function() {
1619

1720
// then
18-
expect(feelBuiltins).to.be.an('array');
19-
expect(feelBuiltins.length).to.be.greaterThan(0);
20-
21-
// standard FEEL function should be in feelBuiltins
22-
const notFunction = feelBuiltins.find(b => b.name === 'not');
23-
expect(notFunction).to.exist;
21+
expectBuiltin(feelBuiltins, 'not');
2422
});
2523

2624

2725
it('should export camundaExtensions', function() {
2826

2927
// then
30-
expect(camundaExtensions).to.be.an('array');
31-
expect(camundaExtensions.length).to.be.greaterThan(0);
28+
expectBuiltin(camundaExtensions, 'get or else');
29+
});
30+
31+
32+
it('should export reservedNameBuiltins', function() {
3233

33-
// Camunda extension should be in camundaExtensions
34-
const getOrElse = camundaExtensions.find(b => b.name === 'get or else');
35-
expect(getOrElse).to.exist;
34+
// then
35+
expectBuiltin(reservedNameBuiltins, 'get or else');
3636
});
3737

3838

@@ -43,29 +43,24 @@ describe('lib/camundaBuiltins', function() {
4343
});
4444

4545

46-
it('should export reservedNameBuiltins', function() {
4746

48-
// then
49-
expect(reservedNameBuiltins).to.be.an('array').with.length(1);
50-
expect(reservedNameBuiltins[0].name).to.equal('get or else');
51-
});
5247

5348

54-
it('should export parameterized built-in', function() {
49+
it('should export parameterized builtin', function() {
5550

5651
// then
57-
expectBuiltin('get or else', {
52+
expectBuiltinProperties(camundaBuiltins, 'get or else', {
5853
name: 'get or else',
5954
type: 'function',
6055
params: [ { name: 'value' }, { name: 'default' } ],
6156
});
6257
});
6358

6459

65-
it('should export parameterless built-in', function() {
60+
it('should export parameterless builtin', function() {
6661

6762
// then
68-
expectBuiltin('random number', {
63+
expectBuiltinProperties(camundaBuiltins, 'random number', {
6964
name: 'random number',
7065
type: 'function',
7166
params: []
@@ -78,12 +73,13 @@ describe('lib/camundaBuiltins', function() {
7873
// helpers /////////
7974

8075
/**
76+
* @param {import('@camunda/feel-builtins').Builtin[]} builtins
8177
* @param {string} name
8278
*
8379
* @return {import('@camunda/feel-builtins').Builtin}
8480
*/
85-
function findBuiltin(name) {
86-
const builtin = camundaBuiltins.find(builtin => builtin.name === name);
81+
function expectBuiltin(builtins, name) {
82+
const builtin = builtins.find(builtin => builtin.name === name);
8783

8884
if (!builtin) {
8985
throw expect(builtin, `builtin with name <${name}>`).to.exist;
@@ -93,11 +89,13 @@ function findBuiltin(name) {
9389
}
9490

9591
/**
92+
* @param {import('@camunda/feel-builtins').Builtin[]} builtins
9693
* @param {string} name
94+
*
9795
* @param {Record<string, any>} expectedProperties
9896
*/
99-
function expectBuiltin(name, expectedProperties) {
100-
const builtin = findBuiltin(name);
97+
function expectBuiltinProperties(builtins, name, expectedProperties) {
98+
const builtin = expectBuiltin(builtins, name);
10199

102100
expect(builtin).to.deep.include(expectedProperties);
103101
expect(builtin).to.have.property('info');

0 commit comments

Comments
 (0)