@@ -213,6 +213,33 @@ describe('utils/DataMap', () => {
213
213
'string(EmployeeID)' ,
214
214
] ) ;
215
215
} ) ;
216
+
217
+ it ( 'Concat with three values including custom string' , async ( ) => {
218
+ expect ( splitKeyIntoChildren ( 'concat(EmployeeName, "EmployeeAge", EmployeeID)' ) ) . toEqual ( [
219
+ 'EmployeeName' ,
220
+ '"EmployeeAge"' ,
221
+ 'EmployeeID' ,
222
+ ] ) ;
223
+ } ) ;
224
+
225
+ it ( 'Concat with three values surrounded by another function including custom string' , async ( ) => {
226
+ expect ( splitKeyIntoChildren ( 'int(concat(/ns0:PersonOrigin/FirstName, " ",/ns0:PersonOrigin/LastName))' ) ) . toEqual ( [
227
+ 'concat(/ns0:PersonOrigin/FirstName, " ",/ns0:PersonOrigin/LastName)' ,
228
+ ] ) ;
229
+ } ) ;
230
+
231
+ it ( 'Concat with three values surrounded by two other functions including custom string in the middle' , async ( ) => {
232
+ expect ( splitKeyIntoChildren ( 'subtract(2023, int(concat(/ns0:PersonOrigin/FirstName, " ",/ns0:PersonOrigin/LastName)))' ) ) . toEqual ( [
233
+ '2023' ,
234
+ 'int(concat(/ns0:PersonOrigin/FirstName, " ",/ns0:PersonOrigin/LastName))' ,
235
+ ] ) ;
236
+ } ) ;
237
+
238
+ it ( 'Concat with three values surrounded by two other functions including custom string in the middle' , async ( ) => {
239
+ expect (
240
+ splitKeyIntoChildren ( 'subtract(2023, int(concat("custom string", /ns0:PersonOrigin/FirstName, /ns0:PersonOrigin/LastName)))' )
241
+ ) . toEqual ( [ '2023' , 'int(concat("custom string", /ns0:PersonOrigin/FirstName, /ns0:PersonOrigin/LastName))' ] ) ;
242
+ } ) ;
216
243
} ) ;
217
244
218
245
describe ( 'qualifyLoopRelativeSourceKeys' , ( ) => {
@@ -332,6 +359,23 @@ describe('utils/DataMap', () => {
332
359
'/ns0:TargetSchemaRoot/Looping/ManyToMany/$for(/ns0:SourceSchemaRoot/Looping/ManyToMany/Simple)/Simple/$for(SourceSimpleChild)/SimpleChild/$for(SourceSimpleChildChild)/SimpleChildChild/Direct'
333
360
) ;
334
361
} ) ;
362
+
363
+ it ( 'returns unchanged string for multiple loops with custom string' , ( ) => {
364
+ const result = removeSequenceFunction ( [
365
+ 'int' ,
366
+ Separators . OpenParenthesis ,
367
+ 'concat' ,
368
+ Separators . OpenParenthesis ,
369
+ '"customString"' ,
370
+ Separators . Comma ,
371
+ '/ns0:PersonOrigin/FirstName' ,
372
+ Separators . Comma ,
373
+ '/ns0:PersonOrigin/LastName' ,
374
+ Separators . CloseParenthesis ,
375
+ Separators . CloseParenthesis ,
376
+ ] ) ;
377
+ expect ( result ) . toEqual ( 'int(concat("customString",/ns0:PersonOrigin/FirstName,/ns0:PersonOrigin/LastName))' ) ;
378
+ } ) ;
335
379
} ) ;
336
380
337
381
describe ( 'separateIntoTokens' , ( ) => {
@@ -369,6 +413,49 @@ describe('utils/DataMap', () => {
369
413
expect ( result [ 13 ] ) . toEqual ( Separators . CloseParenthesis ) ;
370
414
expect ( result [ 14 ] ) . toEqual ( '/Person/Name' ) ;
371
415
} ) ;
416
+
417
+ it ( 'separates a loop and sequence target' , ( ) => {
418
+ const result = separateIntoTokens ( 'int(concat(/ns0:PersonOrigin/FirstName,/ns0:PersonOrigin/LastName))' ) ;
419
+ expect ( result [ 0 ] ) . toEqual ( 'int' ) ;
420
+ expect ( result [ 1 ] ) . toEqual ( Separators . OpenParenthesis ) ;
421
+ expect ( result [ 2 ] ) . toEqual ( 'concat' ) ;
422
+ expect ( result [ 3 ] ) . toEqual ( Separators . OpenParenthesis ) ;
423
+ expect ( result [ 4 ] ) . toEqual ( '/ns0:PersonOrigin/FirstName' ) ;
424
+ expect ( result [ 5 ] ) . toEqual ( Separators . Comma ) ;
425
+ expect ( result [ 6 ] ) . toEqual ( '/ns0:PersonOrigin/LastName' ) ;
426
+ expect ( result [ 7 ] ) . toEqual ( Separators . CloseParenthesis ) ;
427
+ expect ( result [ 8 ] ) . toEqual ( Separators . CloseParenthesis ) ;
428
+ } ) ;
429
+
430
+ it ( 'separates a loop and sequence target' , ( ) => {
431
+ const result = separateIntoTokens ( 'int(concat(/ns0:PersonOrigin/FirstName,/ns0:PersonOrigin/LastName,"customString"))' ) ;
432
+ expect ( result [ 0 ] ) . toEqual ( 'int' ) ;
433
+ expect ( result [ 1 ] ) . toEqual ( Separators . OpenParenthesis ) ;
434
+ expect ( result [ 2 ] ) . toEqual ( 'concat' ) ;
435
+ expect ( result [ 3 ] ) . toEqual ( Separators . OpenParenthesis ) ;
436
+ expect ( result [ 4 ] ) . toEqual ( '/ns0:PersonOrigin/FirstName' ) ;
437
+ expect ( result [ 5 ] ) . toEqual ( Separators . Comma ) ;
438
+ expect ( result [ 6 ] ) . toEqual ( '/ns0:PersonOrigin/LastName' ) ;
439
+ expect ( result [ 7 ] ) . toEqual ( Separators . Comma ) ;
440
+ expect ( result [ 8 ] ) . toEqual ( '"customString"' ) ;
441
+ expect ( result [ 9 ] ) . toEqual ( Separators . CloseParenthesis ) ;
442
+ expect ( result [ 10 ] ) . toEqual ( Separators . CloseParenthesis ) ;
443
+ } ) ;
444
+
445
+ it ( 'separates a loop and sequence target' , ( ) => {
446
+ const result = separateIntoTokens ( 'int(concat("customString",/ns0:PersonOrigin/FirstName,/ns0:PersonOrigin/LastName))' ) ;
447
+ expect ( result [ 0 ] ) . toEqual ( 'int' ) ;
448
+ expect ( result [ 1 ] ) . toEqual ( Separators . OpenParenthesis ) ;
449
+ expect ( result [ 2 ] ) . toEqual ( 'concat' ) ;
450
+ expect ( result [ 3 ] ) . toEqual ( Separators . OpenParenthesis ) ;
451
+ expect ( result [ 4 ] ) . toEqual ( '"customString"' ) ;
452
+ expect ( result [ 5 ] ) . toEqual ( Separators . Comma ) ;
453
+ expect ( result [ 6 ] ) . toEqual ( '/ns0:PersonOrigin/FirstName' ) ;
454
+ expect ( result [ 7 ] ) . toEqual ( Separators . Comma ) ;
455
+ expect ( result [ 8 ] ) . toEqual ( '/ns0:PersonOrigin/LastName' ) ;
456
+ expect ( result [ 9 ] ) . toEqual ( Separators . CloseParenthesis ) ;
457
+ expect ( result [ 10 ] ) . toEqual ( Separators . CloseParenthesis ) ;
458
+ } ) ;
372
459
} ) ;
373
460
} ) ;
374
461
0 commit comments