@@ -18,9 +18,12 @@ import {
1818 returnValidator ,
1919 returnReadOnlyCollector ,
2020 returnNoValueCollector ,
21+ returnObjectSelectCollector ,
2122} from './collector.utils.js' ;
2223import type {
2324 DaVinciField ,
25+ DeviceAuthenticationFieldValue ,
26+ DeviceRegistrationFieldValue ,
2427 ReadOnlyFieldValue ,
2528 RedirectFieldValue ,
2629 StandardFieldValue ,
@@ -227,6 +230,12 @@ describe('Action Collectors', () => {
227230 } ) ;
228231 } ) ;
229232
233+ it ( 'creates an action collector from flow link field type' , ( ) => {
234+ const result = returnFlowCollector ( mockField , 1 ) ;
235+ expect ( result . type ) . toBe ( 'FlowCollector' ) ;
236+ expect ( result . output ) . not . toHaveProperty ( 'value' ) ;
237+ } ) ;
238+
230239 it ( 'handles missing authentication URL for social login' , ( ) => {
231240 const result = returnActionCollector ( mockField , 1 , 'IdpCollector' ) ;
232241 if ( 'url' in result . output ) {
@@ -373,7 +382,11 @@ describe('Single Value Collectors', () => {
373382 expect ( result . type ) . toBe ( 'SingleSelectCollector' ) ;
374383 expect ( result . output ) . toHaveProperty ( 'value' , '' ) ;
375384 } ) ;
385+ } ) ;
386+ } ) ;
376387
388+ describe ( 'Multi-Value Collectors' , ( ) => {
389+ describe ( 'Specialized Multi-Select Collectors' , ( ) => {
377390 it ( 'creates a multi-select collector from combobox field type' , ( ) => {
378391 const comboField : DaVinciField = {
379392 type : 'COMBOBOX' ,
@@ -396,11 +409,118 @@ describe('Single Value Collectors', () => {
396409 expect ( result . type ) . toBe ( 'MultiSelectCollector' ) ;
397410 expect ( result . output ) . toHaveProperty ( 'value' , [ ] ) ;
398411 } ) ;
412+ } ) ;
413+ } ) ;
399414
400- it ( 'creates an action collector from flow link field type' , ( ) => {
401- const result = returnFlowCollector ( mockField , 1 ) ;
402- expect ( result . type ) . toBe ( 'FlowCollector' ) ;
403- expect ( result . output ) . not . toHaveProperty ( 'value' ) ;
415+ describe ( 'Object value collectors' , ( ) => {
416+ describe ( 'returnDeviceAuthenticationCollector' , ( ) => {
417+ const mockField : DeviceAuthenticationFieldValue = {
418+ key : 'device-auth-key' ,
419+ label : 'Device Authentication' ,
420+ type : 'DEVICE_AUTHENTICATION' ,
421+ devices : [
422+ {
423+ type : 'device1' ,
424+ iconSrc : 'icon1.png' ,
425+ title : 'Device 1' ,
426+ id : '123123' ,
427+ default : true ,
428+ value : 'device1-value' ,
429+ } ,
430+ {
431+ type : 'device2' ,
432+ iconSrc : 'icon2.png' ,
433+ title : 'Device 2' ,
434+ id : '345345' ,
435+ default : false ,
436+ value : 'device2-value' ,
437+ } ,
438+ ] ,
439+ required : true ,
440+ } ;
441+
442+ const transformedDevices = mockField . devices . map ( ( device ) => ( {
443+ label : device . title ,
444+ value : device . id ,
445+ content : device . value ,
446+ type : device . type ,
447+ key : device . id ,
448+ default : device . default ,
449+ } ) ) ;
450+
451+ it ( 'should create a valid DeviceAuthenticationCollector' , ( ) => {
452+ const result = returnObjectSelectCollector ( mockField , 1 ) ;
453+ expect ( result ) . toEqual ( {
454+ category : 'ObjectValueCollector' ,
455+ error : null ,
456+ type : 'DeviceAuthenticationCollector' ,
457+ id : 'device-auth-key-1' ,
458+ name : 'device-auth-key' ,
459+ input : {
460+ key : mockField . key ,
461+ value : null ,
462+ type : mockField . type ,
463+ } ,
464+ output : {
465+ key : mockField . key ,
466+ label : mockField . label ,
467+ type : mockField . type ,
468+ options : transformedDevices ,
469+ } ,
470+ } ) ;
471+ } ) ;
472+ } ) ;
473+
474+ describe ( 'returnDeviceRegistrationCollector' , ( ) => {
475+ const mockField : DeviceRegistrationFieldValue = {
476+ key : 'device-reg-key' ,
477+ label : 'Device Registration' ,
478+ type : 'DEVICE_REGISTRATION' ,
479+ devices : [
480+ {
481+ type : 'device1' ,
482+ iconSrc : 'icon1.png' ,
483+ title : 'Device 1' ,
484+ description : 'Device 1 Description' ,
485+ } ,
486+ {
487+ type : 'device2' ,
488+ iconSrc : 'icon2.png' ,
489+ title : 'Device 2' ,
490+ description : 'Device 2 Description' ,
491+ } ,
492+ ] ,
493+ required : true ,
494+ } ;
495+
496+ const transformedDevices = mockField . devices . map ( ( device , idx ) => ( {
497+ label : device . title ,
498+ value : device . type ,
499+ content : device . description ,
500+ type : device . type ,
501+ key : `${ device . type } -${ idx } ` ,
502+ } ) ) ;
503+
504+ it ( 'should create a valid DeviceRegistrationCollector' , ( ) => {
505+ const result = returnObjectSelectCollector ( mockField , 1 ) ;
506+ expect ( result ) . toEqual ( {
507+ category : 'ObjectValueCollector' ,
508+ error : null ,
509+ type : 'DeviceRegistrationCollector' ,
510+ id : 'device-reg-key-1' ,
511+ name : 'device-reg-key' ,
512+ input : {
513+ key : mockField . key ,
514+ value : null ,
515+ type : mockField . type ,
516+ } ,
517+ output : {
518+ key : mockField . key ,
519+ label : mockField . label ,
520+ type : mockField . type ,
521+ options : transformedDevices ,
522+ } ,
523+ } ) ;
404524 } ) ;
405525 } ) ;
406526} ) ;
0 commit comments