@@ -16,38 +16,38 @@ const props: ConfigSelectProps = {
1616} ;
1717
1818describe ( 'ConfigSelect' , ( ) => {
19- it ( 'should call onChange with the new value' , async ( ) => {
20- const fetch = jest . fn ( ) . mockResolvedValue ( [ 'bar' ] ) ;
21- const onChange = jest . fn ( ) ;
22- const label = 'foo-id' ;
23- render ( < ConfigSelect { ...props } label = { label } fetch = { fetch } onChange = { onChange } /> ) ;
24-
25- const selectEl = screen . getByLabelText ( label ) ;
26- expect ( selectEl ) . toBeInTheDocument ( ) ;
27- expect ( selectEl ) . not . toBeDisabled ( ) ;
28- await select ( selectEl , 'bar' , { container : document . body } ) ;
29- expect ( fetch ) . toHaveBeenCalled ( ) ;
30- expect ( onChange ) . toHaveBeenCalledWith ( { label : 'bar' , value : 'bar' } ) ;
31- } ) ;
32-
33- it ( 'should show disabled select if passed disabled as prop' , ( ) => {
34- const label = 'foo-id' ;
35- render ( < ConfigSelect { ...props } disabled = { true } label = { label } /> ) ;
36- const selectEl = screen . getByLabelText ( label ) ;
37-
38- expect ( selectEl ) . toBeDisabled ( ) ;
39- } ) ;
40-
41- it ( 'should show disabled select if passed disabled=false as prop but jsonData.defaultRegion is not set' , ( ) => {
42- const propsWithoutDefaultRegion = {
43- ...props ,
44- options : { ...props . options , jsonData : { ...props . options . jsonData } } ,
45- } ;
46- propsWithoutDefaultRegion . options . jsonData = { } ;
47- const label = 'foo-id' ;
48- render ( < ConfigSelect { ...propsWithoutDefaultRegion } disabled = { false } label = { label } /> ) ;
49- const selectEl = screen . getByLabelText ( label ) ;
50-
51- expect ( selectEl ) . toBeDisabled ( ) ;
52- } ) ;
19+ it ( 'should call onChange with the new value' , async ( ) => {
20+ const fetch = jest . fn ( ) . mockResolvedValue ( [ 'bar' ] ) ;
21+ const onChange = jest . fn ( ) ;
22+ const label = 'foo-id' ;
23+ render ( < ConfigSelect { ...props } label = { label } fetch = { fetch } onChange = { onChange } /> ) ;
24+
25+ const selectEl = screen . getByLabelText ( label ) ;
26+ expect ( selectEl ) . toBeInTheDocument ( ) ;
27+ expect ( selectEl ) . not . toBeDisabled ( ) ;
28+ await select ( selectEl , 'bar' , { container : document . body } ) ;
29+ expect ( fetch ) . toHaveBeenCalled ( ) ;
30+ expect ( onChange ) . toHaveBeenCalledWith ( { label : 'bar' , value : 'bar' } ) ;
31+ } ) ;
32+
33+ it ( 'should show disabled select if passed disabled as prop' , ( ) => {
34+ const label = 'foo-id' ;
35+ render ( < ConfigSelect { ...props } disabled = { true } label = { label } /> ) ;
36+ const selectEl = screen . getByLabelText ( label ) ;
37+
38+ expect ( selectEl ) . toBeDisabled ( ) ;
39+ } ) ;
40+
41+ it ( 'should show disabled select if passed disabled=false as prop but jsonData.defaultRegion is not set' , ( ) => {
42+ const propsWithoutDefaultRegion = {
43+ ...props ,
44+ options : { ...props . options , jsonData : { ...props . options . jsonData } } ,
45+ } ;
46+ propsWithoutDefaultRegion . options . jsonData = { } ;
47+ const label = 'foo-id' ;
48+ render ( < ConfigSelect { ...propsWithoutDefaultRegion } disabled = { false } label = { label } /> ) ;
49+ const selectEl = screen . getByLabelText ( label ) ;
50+
51+ expect ( selectEl ) . toBeDisabled ( ) ;
52+ } ) ;
5353} ) ;
0 commit comments