@@ -11,11 +11,12 @@ import type {
11
11
FlowCollector ,
12
12
SocialLoginCollector ,
13
13
SubmitCollector ,
14
- DropDownCollector ,
15
- ComboboxCollector ,
16
- RadioCollector ,
17
- FlowLinkCollector ,
18
- InferSingleValueCollectorFromSingleValueCollectorType ,
14
+ SingleSelectCollector ,
15
+ MultiValueCollectorWithValue ,
16
+ MultiSelectCollector ,
17
+ InferSingleValueCollectorType ,
18
+ InferMultiValueCollectorType ,
19
+ InferActionCollectorType ,
19
20
} from './collector.types.js' ;
20
21
21
22
describe ( 'Collector Types' , ( ) => {
@@ -45,48 +46,30 @@ describe('Collector Types', () => {
45
46
} > ( ) ;
46
47
} ) ;
47
48
48
- it ( 'should validate DropDownCollector structure' , ( ) => {
49
- expectTypeOf < DropDownCollector > ( ) . toMatchTypeOf <
50
- SingleValueCollectorWithValue < 'DropDownCollector ' >
49
+ it ( 'should validate SingleCollector structure' , ( ) => {
50
+ expectTypeOf < SingleSelectCollector > ( ) . toMatchTypeOf <
51
+ SingleValueCollectorWithValue < 'SingleSelectCollector ' >
51
52
> ( ) ;
52
- expectTypeOf < DropDownCollector > ( )
53
+ expectTypeOf < SingleSelectCollector > ( )
53
54
. toHaveProperty ( 'category' )
54
55
. toEqualTypeOf < 'SingleValueCollector' > ( ) ;
55
- expectTypeOf < DropDownCollector > ( ) . toHaveProperty ( 'type' ) . toEqualTypeOf < 'DropDownCollector' > ( ) ;
56
- expectTypeOf < DropDownCollector [ 'output' ] > ( ) . toHaveProperty ( 'value' ) ;
57
- } ) ;
58
-
59
- it ( 'should validate ComboboxCollector structure' , ( ) => {
60
- expectTypeOf < ComboboxCollector > ( ) . toMatchTypeOf <
61
- SingleValueCollectorWithValue < 'ComboboxCollector' >
62
- > ( ) ;
63
- expectTypeOf < ComboboxCollector > ( )
64
- . toHaveProperty ( 'category' )
65
- . toEqualTypeOf < 'SingleValueCollector' > ( ) ;
66
- expectTypeOf < ComboboxCollector > ( ) . toHaveProperty ( 'type' ) . toEqualTypeOf < 'ComboboxCollector' > ( ) ;
67
- expectTypeOf < ComboboxCollector [ 'output' ] > ( ) . toHaveProperty ( 'value' ) ;
68
- } ) ;
69
-
70
- it ( 'should validate RadioCollector structure' , ( ) => {
71
- expectTypeOf < RadioCollector > ( ) . toMatchTypeOf <
72
- SingleValueCollectorWithValue < 'RadioCollector' >
73
- > ( ) ;
74
- expectTypeOf < RadioCollector > ( )
75
- . toHaveProperty ( 'category' )
76
- . toEqualTypeOf < 'SingleValueCollector' > ( ) ;
77
- expectTypeOf < RadioCollector > ( ) . toHaveProperty ( 'type' ) . toEqualTypeOf < 'RadioCollector' > ( ) ;
78
- expectTypeOf < RadioCollector [ 'output' ] > ( ) . toHaveProperty ( 'value' ) ;
56
+ expectTypeOf < SingleSelectCollector > ( )
57
+ . toHaveProperty ( 'type' )
58
+ . toEqualTypeOf < 'SingleSelectCollector' > ( ) ;
59
+ expectTypeOf < SingleSelectCollector [ 'output' ] > ( ) . toHaveProperty ( 'value' ) ;
79
60
} ) ;
80
61
81
- it ( 'should validate FlowLinkCollector structure' , ( ) => {
82
- expectTypeOf < FlowLinkCollector > ( ) . toMatchTypeOf <
83
- SingleValueCollectorNoValue < 'FlowLinkCollector '>
62
+ it ( 'should validate MultiSelectCollector structure' , ( ) => {
63
+ expectTypeOf < MultiSelectCollector > ( ) . toMatchTypeOf <
64
+ MultiValueCollectorWithValue < 'MultiSelectCollector '>
84
65
> ( ) ;
85
- expectTypeOf < FlowLinkCollector > ( )
66
+ expectTypeOf < MultiSelectCollector > ( )
86
67
. toHaveProperty ( 'category' )
87
- . toEqualTypeOf < 'SingleValueCollector' > ( ) ;
88
- expectTypeOf < FlowLinkCollector > ( ) . toHaveProperty ( 'type' ) . toEqualTypeOf < 'FlowLinkCollector' > ( ) ;
89
- expectTypeOf < TextCollector [ 'output' ] [ 'value' ] > ( ) . toBeString ( ) ;
68
+ . toEqualTypeOf < 'MultiValueCollector' > ( ) ;
69
+ expectTypeOf < MultiSelectCollector > ( )
70
+ . toHaveProperty ( 'type' )
71
+ . toEqualTypeOf < 'MultiSelectCollector' > ( ) ;
72
+ expectTypeOf < MultiSelectCollector [ 'output' ] > ( ) . toHaveProperty ( 'value' ) ;
90
73
} ) ;
91
74
} ) ;
92
75
@@ -121,21 +104,19 @@ describe('Collector Types', () => {
121
104
122
105
describe ( 'Type Inference' , ( ) => {
123
106
it ( 'should correctly infer SingleValueCollector types' , ( ) => {
124
- expectTypeOf <
125
- InferSingleValueCollectorFromSingleValueCollectorType < 'TextCollector' >
126
- > ( ) . toEqualTypeOf < TextCollector > ( ) ;
107
+ expectTypeOf < InferSingleValueCollectorType < 'TextCollector' > > ( ) . toEqualTypeOf < TextCollector > ( ) ;
127
108
128
109
expectTypeOf <
129
- InferSingleValueCollectorFromSingleValueCollectorType < 'PasswordCollector' >
110
+ InferSingleValueCollectorType < 'PasswordCollector' >
130
111
> ( ) . toEqualTypeOf < PasswordCollector > ( ) ;
131
112
132
113
expectTypeOf <
133
- InferSingleValueCollectorFromSingleValueCollectorType < 'DropDownCollector '>
134
- > ( ) . toEqualTypeOf < DropDownCollector > ( ) ;
114
+ InferSingleValueCollectorType < 'SingleSelectCollector '>
115
+ > ( ) . toEqualTypeOf < SingleSelectCollector > ( ) ;
135
116
} ) ;
136
117
137
118
it ( 'should handle generic SingleValueCollector type' , ( ) => {
138
- type Generic = InferSingleValueCollectorFromSingleValueCollectorType < 'SingleValueCollector' > ;
119
+ type Generic = InferSingleValueCollectorType < 'SingleValueCollector' > ;
139
120
expectTypeOf < Generic > ( ) . toMatchTypeOf <
140
121
| SingleValueCollectorWithValue < 'SingleValueCollector' >
141
122
| SingleValueCollectorNoValue < 'SingleValueCollector' >
@@ -148,10 +129,7 @@ describe('Collector Types', () => {
148
129
const validTypes : SingleValueCollectorTypes [ ] = [
149
130
'TextCollector' ,
150
131
'PasswordCollector' ,
151
- 'DropDownCollector' ,
152
- 'ComboboxCollector' ,
153
- 'RadioCollector' ,
154
- 'FlowLinkCollector' ,
132
+ 'SingleSelectCollector' ,
155
133
] ;
156
134
157
135
// Type assertion to ensure SingleValueCollectorTypes includes all these values
@@ -245,7 +223,7 @@ describe('Collector Types', () => {
245
223
} ) ;
246
224
describe ( 'InferSingleValueCollectorFromSingleValueCollectorType' , ( ) => {
247
225
it ( 'should correctly infer TextCollector Type' , ( ) => {
248
- const tCollector : InferSingleValueCollectorFromSingleValueCollectorType < 'TextCollector' > = {
226
+ const tCollector : InferSingleValueCollectorType < 'TextCollector' > = {
249
227
category : 'SingleValueCollector' ,
250
228
error : null ,
251
229
type : 'TextCollector' ,
@@ -267,103 +245,78 @@ describe('Collector Types', () => {
267
245
expectTypeOf ( tCollector ) . toMatchTypeOf < TextCollector > ( ) ;
268
246
} ) ;
269
247
it ( 'should correctly infer PasswordCollector Type' , ( ) => {
270
- const tCollector : InferSingleValueCollectorFromSingleValueCollectorType < 'PasswordCollector' > =
271
- {
272
- category : 'SingleValueCollector' ,
273
- error : null ,
274
- type : 'PasswordCollector' ,
275
- id : '' ,
276
- name : '' ,
277
- input : {
278
- key : '' ,
279
- value : '' ,
280
- type : '' ,
281
- } ,
282
- output : {
283
- key : '' ,
284
- label : '' ,
285
- type : '' ,
286
- } ,
287
- } ;
248
+ const tCollector : InferSingleValueCollectorType < 'PasswordCollector' > = {
249
+ category : 'SingleValueCollector' ,
250
+ error : null ,
251
+ type : 'PasswordCollector' ,
252
+ id : '' ,
253
+ name : '' ,
254
+ input : {
255
+ key : '' ,
256
+ value : '' ,
257
+ type : '' ,
258
+ } ,
259
+ output : {
260
+ key : '' ,
261
+ label : '' ,
262
+ type : '' ,
263
+ } ,
264
+ } ;
288
265
289
266
expectTypeOf ( tCollector ) . toMatchTypeOf < PasswordCollector > ( ) ;
290
267
} ) ;
291
268
it ( 'should correctly infer SingleValueCollector Type' , ( ) => {
292
- const tCollector : InferSingleValueCollectorFromSingleValueCollectorType < 'SingleValueCollector' > =
293
- {
294
- category : 'SingleValueCollector' ,
295
- error : null ,
296
- type : 'SingleValueCollector' ,
297
- id : '' ,
298
- name : '' ,
299
- input : {
300
- key : '' ,
301
- value : '' ,
302
- type : '' ,
303
- } ,
304
- output : {
305
- key : '' ,
306
- label : '' ,
307
- type : '' ,
308
- value : '' ,
309
- } ,
310
- } ;
269
+ const tCollector : InferSingleValueCollectorType < 'SingleValueCollector' > = {
270
+ category : 'SingleValueCollector' ,
271
+ error : null ,
272
+ type : 'SingleValueCollector' ,
273
+ id : '' ,
274
+ name : '' ,
275
+ input : {
276
+ key : '' ,
277
+ value : '' ,
278
+ type : '' ,
279
+ } ,
280
+ output : {
281
+ key : '' ,
282
+ label : '' ,
283
+ type : '' ,
284
+ value : '' ,
285
+ } ,
286
+ } ;
311
287
312
288
expectTypeOf ( tCollector ) . toMatchTypeOf <
313
289
SingleValueCollectorWithValue < 'SingleValueCollector' >
314
290
> ( ) ;
315
291
} ) ;
316
- it ( 'should correctly infer ComboboxCollector Type' , ( ) => {
317
- const tCollector : InferSingleValueCollectorFromSingleValueCollectorType < 'ComboboxCollector' > =
318
- {
319
- category : 'SingleValueCollector' ,
320
- error : null ,
321
- type : 'ComboboxCollector' ,
322
- id : '' ,
323
- name : '' ,
324
- input : {
325
- key : '' ,
326
- value : '' ,
327
- type : '' ,
328
- } ,
329
- output : {
330
- key : '' ,
331
- label : '' ,
332
- type : '' ,
333
- value : '' ,
334
- } ,
335
- } ;
336
-
337
- expectTypeOf ( tCollector ) . toMatchTypeOf < ComboboxCollector > ( ) ;
338
- } ) ;
339
- it ( 'should correctly infer DropDownCollector Type' , ( ) => {
340
- const tCollector : InferSingleValueCollectorFromSingleValueCollectorType < 'DropDownCollector' > =
341
- {
342
- category : 'SingleValueCollector' ,
343
- error : null ,
344
- type : 'DropDownCollector' ,
345
- id : '' ,
346
- name : '' ,
347
- input : {
348
- key : '' ,
349
- value : '' ,
350
- type : '' ,
351
- } ,
352
- output : {
353
- key : '' ,
354
- label : '' ,
355
- type : '' ,
356
- value : '' ,
357
- } ,
358
- } ;
292
+ it ( 'should correctly infer MultiSelectCollector Type' , ( ) => {
293
+ const tCollector : InferMultiValueCollectorType < 'MultiSelectCollector' > = {
294
+ category : 'MultiValueCollector' ,
295
+ error : null ,
296
+ type : 'MultiSelectCollector' ,
297
+ id : '' ,
298
+ name : '' ,
299
+ input : {
300
+ key : '' ,
301
+ value : [ '' ] ,
302
+ type : '' ,
303
+ } ,
304
+ output : {
305
+ key : '' ,
306
+ label : '' ,
307
+ type : '' ,
308
+ value : [ '' ] ,
309
+ options : [ { label : '' , value : '' } ] ,
310
+ } ,
311
+ } ;
359
312
360
- expectTypeOf ( tCollector ) . toMatchTypeOf < DropDownCollector > ( ) ;
313
+ expectTypeOf ( tCollector ) . toMatchTypeOf < MultiSelectCollector > ( ) ;
361
314
} ) ;
362
- it ( 'should correctly infer RadioCollector Type' , ( ) => {
363
- const tCollector : InferSingleValueCollectorFromSingleValueCollectorType < 'RadioCollector '> = {
315
+ it ( 'should correctly infer SingleSelectCollector Type' , ( ) => {
316
+ const tCollector : InferSingleValueCollectorType < 'SingleSelectCollector '> = {
364
317
category : 'SingleValueCollector' ,
365
318
error : null ,
366
- type : 'RadioCollector ' ,
319
+ type : 'SingleSelectCollector ' ,
367
320
id : '' ,
368
321
name : '' ,
369
322
input : {
@@ -376,32 +329,27 @@ describe('Collector Types', () => {
376
329
label : '' ,
377
330
type : '' ,
378
331
value : '' ,
332
+ options : [ { label : '' , value : '' } ] ,
379
333
} ,
380
334
} ;
381
335
382
- expectTypeOf ( tCollector ) . toMatchTypeOf < RadioCollector > ( ) ;
336
+ expectTypeOf ( tCollector ) . toMatchTypeOf < SingleSelectCollector > ( ) ;
383
337
} ) ;
384
- it ( 'should correctly infer FlowLinkCollector Type' , ( ) => {
385
- const tCollector : InferSingleValueCollectorFromSingleValueCollectorType < 'FlowLinkCollector' > =
386
- {
387
- category : 'SingleValueCollector' ,
388
- error : null ,
389
- type : 'FlowLinkCollector' ,
390
- id : '' ,
391
- name : '' ,
392
- input : {
393
- key : '' ,
394
- value : '' ,
395
- type : '' ,
396
- } ,
397
- output : {
398
- key : '' ,
399
- label : '' ,
400
- type : '' ,
401
- } ,
402
- } ;
338
+ it ( 'should correctly infer FlowCollector Type' , ( ) => {
339
+ const tCollector : InferActionCollectorType < 'FlowCollector' > = {
340
+ category : 'ActionCollector' ,
341
+ error : null ,
342
+ type : 'FlowCollector' ,
343
+ id : '' ,
344
+ name : '' ,
345
+ output : {
346
+ key : '' ,
347
+ label : '' ,
348
+ type : '' ,
349
+ } ,
350
+ } ;
403
351
404
- expectTypeOf ( tCollector ) . toMatchTypeOf < FlowLinkCollector > ( ) ;
352
+ expectTypeOf ( tCollector ) . toMatchTypeOf < FlowCollector > ( ) ;
405
353
} ) ;
406
354
} ) ;
407
355
} ) ;
0 commit comments