Skip to content

Commit

Permalink
Merge pull request #307 from mshangle1/master
Browse files Browse the repository at this point in the history
Modified data processor functional param splitting logic
  • Loading branch information
ASaiAnudeep authored Jan 13, 2024
2 parents 2af9418 + ea42eff commit 9ace745
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/helpers/dataProcessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const dataProcessor = {
values.push(typeof value === 'undefined' ? raw : value);
}
if (refType === 'F') {
const [handlerName, ..._args] = refValue.split(':');
const [handlerName, ..._args] = refValue.split(/:(.*)/);
const handlerFun = handler.getDataFuncHandler(handlerName);
const handler_data = handlerFun({ args: _args.length > 0 ? _args[0].split(',') : _args });
values.push(this.processDataRefs(handler_data));
Expand Down
18 changes: 18 additions & 0 deletions test/unit/dataProcessor.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,24 @@ describe('Data Processing - Functions', () => {
expect(data).deep.equals({ name: 'Jon' });
});

it('should return data passed in as parameter', () => {
handler.addDataFuncHandler('GetParam', (ctx) => {
return ctx.args[0]
});

const data = dp.processData('$F{GetParam:Jon}');
expect(data).equals('Jon');
});

it('should return data passed in as parameter with semicolon', () => {
handler.addDataFuncHandler('GetParam', (ctx) => {
return ctx.args[0]
});

const data = dp.processData('$F{GetParam:Jon:Doe}');
expect(data).equals('Jon:Doe');
});

afterEach(() => {
config.data.ref.map.enabled = false;
config.data.ref.map.processed = false;
Expand Down

0 comments on commit 9ace745

Please sign in to comment.