@@ -336,30 +336,35 @@ describe('PoolFormComponent', () => {
336336 it ( 'validates minBlobSize to be only valid between 0 and maxBlobSize' , ( ) => {
337337 formHelper . expectErrorChange ( 'minBlobSize' , - 1 , 'min' ) ;
338338 formHelper . expectValidChange ( 'minBlobSize' , 0 ) ;
339- formHelper . setValue ( 'maxBlobSize' , '2 KiB' ) ;
340- formHelper . expectErrorChange ( 'minBlobSize' , '3 KiB' , 'maximum' ) ;
341- formHelper . expectValidChange ( 'minBlobSize' , '1.9 KiB' ) ;
339+ formHelper . setValue ( 'minBlobSizeUnit' , 'KiB' ) ;
340+ formHelper . setValue ( 'maxBlobSize' , '2' ) ;
341+ formHelper . setValue ( 'maxBlobSizeUnit' , 'KiB' ) ;
342+ formHelper . expectErrorChange ( 'minBlobSize' , '3' , 'maximum' ) ;
343+ formHelper . expectValidChange ( 'minBlobSize' , '1.9' ) ;
342344 } ) ;
343345
344346 it ( 'validates minBlobSize converts numbers' , ( ) => {
345347 const control = formHelper . setValue ( 'minBlobSize' , '1' ) ;
348+ const controlUnit = formHelper . setValue ( 'minBlobSizeUnit' , 'KiB' ) ;
346349 fixture . detectChanges ( ) ;
347350 formHelper . expectValid ( control ) ;
348- expect ( control . value ) . toBe ( '1 KiB' ) ;
351+ expect ( control . value ) . toBe ( '1' ) ;
352+ expect ( controlUnit . value ) . toBe ( 'KiB' ) ;
349353 } ) ;
350354
351355 it ( 'validates maxBlobSize to be only valid bigger than minBlobSize' , ( ) => {
352356 formHelper . expectErrorChange ( 'maxBlobSize' , - 1 , 'min' ) ;
353- formHelper . setValue ( 'minBlobSize' , '1 KiB' ) ;
354- formHelper . expectErrorChange ( 'maxBlobSize' , '0.5 KiB' , 'minimum' ) ;
355- formHelper . expectValidChange ( 'maxBlobSize' , '1.5 KiB' ) ;
357+ formHelper . setValue ( 'minBlobSize' , '1' ) ;
358+ formHelper . setValue ( 'minBlobSizeUnit' , 'MiB' ) ;
359+ formHelper . expectErrorChange ( 'maxBlobSize' , '0.5' , 'minimum' ) ;
360+ formHelper . expectValidChange ( 'maxBlobSize' , '1.5' ) ;
356361 } ) ;
357362
358363 it ( 's valid to only use one blob size' , ( ) => {
359- formHelper . expectValid ( formHelper . setValue ( 'minBlobSize' , '1 KiB ' ) ) ;
364+ formHelper . expectValid ( formHelper . setValue ( 'minBlobSize' , '1' ) ) ;
360365 formHelper . expectValid ( formHelper . setValue ( 'maxBlobSize' , '' ) ) ;
361366 formHelper . expectValid ( formHelper . setValue ( 'minBlobSize' , '' ) ) ;
362- formHelper . expectValid ( formHelper . setValue ( 'maxBlobSize' , '1 KiB ' ) ) ;
367+ formHelper . expectValid ( formHelper . setValue ( 'maxBlobSize' , '1' ) ) ;
363368 } ) ;
364369
365370 it ( 'dismisses any size error if one of the blob sizes is changed into a valid state' , ( ) => {
@@ -378,19 +383,22 @@ describe('PoolFormComponent', () => {
378383
379384 it ( 'validates maxBlobSize converts numbers' , ( ) => {
380385 const control = formHelper . setValue ( 'maxBlobSize' , '2' ) ;
386+ const controlUnit = formHelper . setValue ( 'maxBlobSizeUnit' , 'KiB' ) ;
381387 fixture . detectChanges ( ) ;
382- expect ( control . value ) . toBe ( '2 KiB' ) ;
388+ expect ( control . value ) . toBe ( '2' ) ;
389+ expect ( controlUnit . value ) . toBe ( 'KiB' ) ;
383390 } ) ;
384391
385392 it ( 'validates that odd size validator works as expected' , ( ) => {
386- const odd = ( min : string , max : string ) => component [ 'oddBlobSize' ] ( min , max ) ;
387- expect ( odd ( '10' , '8' ) ) . toBe ( true ) ;
388- expect ( odd ( '8' , '-' ) ) . toBe ( false ) ;
389- expect ( odd ( '8' , '10' ) ) . toBe ( false ) ;
390- expect ( odd ( null , '8' ) ) . toBe ( false ) ;
391- expect ( odd ( '10' , '' ) ) . toBe ( false ) ;
392- expect ( odd ( '10' , null ) ) . toBe ( false ) ;
393- expect ( odd ( null , null ) ) . toBe ( false ) ;
393+ const odd = ( min : string , minUnit : string , max : string , maxUnit : string ) =>
394+ component [ 'oddBlobSize' ] ( min , minUnit , max , maxUnit ) ;
395+ expect ( odd ( '10' , 'KiB' , '8' , 'KiB' ) ) . toBe ( true ) ;
396+ expect ( odd ( '8' , 'KiB' , '-' , 'KiB' ) ) . toBe ( false ) ;
397+ expect ( odd ( '8' , 'KiB' , '10' , 'KiB' ) ) . toBe ( false ) ;
398+ expect ( odd ( null , 'KiB' , '8' , 'KiB' ) ) . toBe ( false ) ;
399+ expect ( odd ( '10' , 'KiB' , '' , 'KiB' ) ) . toBe ( false ) ;
400+ expect ( odd ( '10' , 'KiB' , null , 'KiB' ) ) . toBe ( false ) ;
401+ expect ( odd ( null , 'KiB' , null , 'KiB' ) ) . toBe ( false ) ;
394402 } ) ;
395403
396404 it ( 'validates ratio to be only valid between 0 and 1' , ( ) => {
@@ -1149,10 +1157,13 @@ describe('PoolFormComponent', () => {
11491157 setMultipleValues ( {
11501158 mode : 'passive' ,
11511159 algorithm : 'lz4' ,
1152- minBlobSize : '4 K' ,
1153- maxBlobSize : '4 M' ,
1160+ minBlobSize : '4' ,
1161+ minBlobSizeUnit : 'KiB' ,
1162+ maxBlobSize : '4' ,
1163+ maxBlobSizeUnit : 'MiB' ,
11541164 ratio : 0.7
11551165 } ) ;
1166+ fixture . detectChanges ( ) ;
11561167 expectEcSubmit ( {
11571168 compression_mode : 'passive' ,
11581169 compression_algorithm : 'lz4' ,
@@ -1237,7 +1248,8 @@ describe('PoolFormComponent', () => {
12371248
12381249 it ( 'creates a pool with quotas' , ( ) => {
12391250 setMultipleValues ( {
1240- max_bytes : 1024 * 1024 ,
1251+ max_bytes : 1 ,
1252+ maxBytesUnit : 'MiB' ,
12411253 max_objects : 3000
12421254 } ) ;
12431255 component . data . applications . selected = [ 'cephfs' , 'rgw' ] ;
@@ -1343,10 +1355,13 @@ describe('PoolFormComponent', () => {
13431355 expect ( form . getValue ( 'pgNum' ) ) . toBe ( pool . pg_num ) ;
13441356 expect ( form . getValue ( 'mode' ) ) . toBe ( pool . options . compression_mode ) ;
13451357 expect ( form . getValue ( 'algorithm' ) ) . toBe ( pool . options . compression_algorithm ) ;
1346- expect ( form . getValue ( 'minBlobSize' ) ) . toBe ( '512 KiB' ) ;
1347- expect ( form . getValue ( 'maxBlobSize' ) ) . toBe ( '1 MiB' ) ;
1358+ expect ( form . getValue ( 'minBlobSize' ) ) . toBe ( '512' ) ;
1359+ expect ( form . getValue ( 'minBlobSizeUnit' ) ) . toBe ( 'KiB' ) ;
1360+ expect ( form . getValue ( 'maxBlobSize' ) ) . toBe ( '1' ) ;
1361+ expect ( form . getValue ( 'maxBlobSizeUnit' ) ) . toBe ( 'MiB' ) ;
13481362 expect ( form . getValue ( 'ratio' ) ) . toBe ( pool . options . compression_required_ratio ) ;
1349- expect ( form . getValue ( 'max_bytes' ) ) . toBe ( '1 GiB' ) ;
1363+ expect ( form . getValue ( 'max_bytes' ) ) . toBe ( '1' ) ;
1364+ expect ( form . getValue ( 'maxBytesUnit' ) ) . toBe ( 'GiB' ) ;
13501365 expect ( form . getValue ( 'max_objects' ) ) . toBe ( pool . quota_max_objects ) ;
13511366 } ) ;
13521367
0 commit comments