@@ -179,6 +179,102 @@ void main() {
179179 });
180180 });
181181
182+ group ('SelectOption' , () {
183+ test ('can be created with value only' , () {
184+ const option = SelectOption (value: 42 );
185+ expect (option.value, 42 );
186+ expect (option.label, isNull);
187+ });
188+
189+ test ('can be created with value and label' , () {
190+ const option = SelectOption (value: 512 , label: 'Medium' );
191+ expect (option.value, 512 );
192+ expect (option.label, 'Medium' );
193+ });
194+
195+ test ('works with String type' , () {
196+ const option = SelectOption (value: 'us-central1' , label: 'US Central' );
197+ expect (option.value, 'us-central1' );
198+ expect (option.label, 'US Central' );
199+ });
200+
201+ test ('works with double type' , () {
202+ const option = SelectOption (value: 0.5 , label: 'Half' );
203+ expect (option.value, 0.5 );
204+ expect (option.label, 'Half' );
205+ });
206+
207+ test ('select factory creates options with null labels' , () {
208+ final input = ParamInput .select ([10 , 20 , 30 ]);
209+ for (final option in input.options) {
210+ expect (option.label, isNull);
211+ }
212+ expect (input.options.map ((o) => o.value).toList (), [10 , 20 , 30 ]);
213+ });
214+
215+ test ('selectWithLabels factory maps labels to values' , () {
216+ final input = ParamInput .selectWithLabels ({
217+ 'Small' : 256 ,
218+ 'Medium' : 512 ,
219+ 'Large' : 1024 ,
220+ });
221+ expect (input.options[0 ].label, 'Small' );
222+ expect (input.options[0 ].value, 256 );
223+ expect (input.options[1 ].label, 'Medium' );
224+ expect (input.options[1 ].value, 512 );
225+ expect (input.options[2 ].label, 'Large' );
226+ expect (input.options[2 ].value, 1024 );
227+ });
228+
229+ test ('multiSelect factory creates options with null labels' , () {
230+ final input = ParamInput .multiSelect (['a' , 'b' , 'c' ]);
231+ for (final option in input.options) {
232+ expect (option.label, isNull);
233+ }
234+ expect (input.options.map ((o) => o.value).toList (), ['a' , 'b' , 'c' ]);
235+ });
236+
237+ test ('multiSelectWithLabels factory maps labels to values' , () {
238+ final input = ParamInput .multiSelectWithLabels ({
239+ 'Option A' : 'a' ,
240+ 'Option B' : 'b' ,
241+ 'Option C' : 'c' ,
242+ });
243+ expect (input, isA <MultiSelectParamInput >());
244+ expect (input.options.length, 3 );
245+ expect (input.options[0 ].label, 'Option A' );
246+ expect (input.options[0 ].value, 'a' );
247+ expect (input.options[1 ].label, 'Option B' );
248+ expect (input.options[1 ].value, 'b' );
249+ expect (input.options[2 ].label, 'Option C' );
250+ expect (input.options[2 ].value, 'c' );
251+ });
252+
253+ test ('can be used in SelectParamInput directly' , () {
254+ final input = SelectParamInput <String >(
255+ options: [
256+ SelectOption (value: 'us-central1' , label: 'US Central' ),
257+ SelectOption (value: 'europe-west1' , label: 'Europe West' ),
258+ ],
259+ );
260+ expect (input.options.length, 2 );
261+ expect (input.options[0 ].value, 'us-central1' );
262+ expect (input.options[1 ].label, 'Europe West' );
263+ });
264+
265+ test ('can be used in MultiSelectParamInput directly' , () {
266+ final input = MultiSelectParamInput (
267+ options: [
268+ SelectOption (value: 'read' , label: 'Read Access' ),
269+ SelectOption (value: 'write' , label: 'Write Access' ),
270+ ],
271+ );
272+ expect (input.options.length, 2 );
273+ expect (input.options[0 ].value, 'read' );
274+ expect (input.options[1 ].label, 'Write Access' );
275+ });
276+ });
277+
182278 group ('ParamInput' , () {
183279 test ('select creates SelectParamInput' , () {
184280 final input = ParamInput .select ([1 , 2 , 3 ]);
@@ -204,6 +300,17 @@ void main() {
204300 expect (input.options.length, 3 );
205301 });
206302
303+ test ('multiSelectWithLabels creates MultiSelectParamInput with labels' , () {
304+ final input = ParamInput .multiSelectWithLabels ({
305+ 'Label A' : 'val_a' ,
306+ 'Label B' : 'val_b' ,
307+ });
308+ expect (input, isA <MultiSelectParamInput >());
309+ expect (input.options.length, 2 );
310+ expect (input.options[0 ].label, 'Label A' );
311+ expect (input.options[0 ].value, 'val_a' );
312+ });
313+
207314 test ('bucketPicker is a ResourceInput' , () {
208315 expect (ParamInput .bucketPicker, isA <ResourceInput >());
209316 });
0 commit comments