@@ -8,42 +8,42 @@ const getDefaultProps = (overrides?: Partial<RunQueryButtonsProps<DataQuery>>) =
88 return {
99 onRunQuery : jest . fn ( ) ,
1010 onCancelQuery : jest . fn ( ) ,
11- isQueryValid : jest . fn ( ) ,
11+ enableRun : true ,
1212 query : { refId : 'refId' } ,
1313 ...overrides ,
1414 } ;
1515} ;
1616
1717describe ( 'RunQueryButtons' , ( ) => {
18- it ( 'disable the run button if the query is invalid ' , ( ) => {
19- const props = getDefaultProps ( { isQueryValid : jest . fn ( ) . mockReturnValue ( false ) } ) ;
18+ it ( 'disable the run button if the if the enableRun button is false ' , ( ) => {
19+ const props = getDefaultProps ( { enableRun : false } ) ;
2020 render ( < RunQueryButtons { ...props } /> ) ;
21- const runButton = screen . getByRole ( 'button' , { name : 'Run' } ) ;
21+ const runButton = screen . getByRole ( 'button' , { name : 'Run query ' } ) ;
2222 expect ( runButton ) . toBeDisabled ( ) ;
2323 } ) ;
2424
25- it ( 'run button should be enabled if the query is valid ' , ( ) => {
26- const props = getDefaultProps ( { isQueryValid : jest . fn ( ) . mockReturnValue ( true ) } ) ;
25+ it ( 'run button should be enabled if the enableRun button is true ' , ( ) => {
26+ const props = getDefaultProps ( { enableRun : true } ) ;
2727 render ( < RunQueryButtons { ...props } /> ) ;
28- const runButton = screen . getByRole ( 'button' , { name : 'Run' } ) ;
28+ const runButton = screen . getByRole ( 'button' , { name : 'Run query ' } ) ;
2929 expect ( runButton ) . not . toBeDisabled ( ) ;
3030 } ) ;
3131
3232 it ( 'only renders the `Run` button if onCancelQuery is undefined' , ( ) => {
3333 const props = getDefaultProps ( { onCancelQuery : undefined } ) ;
3434 render ( < RunQueryButtons { ...props } /> ) ;
35- const runButton = screen . getByRole ( 'button' , { name : 'Run' } ) ;
35+ const runButton = screen . getByRole ( 'button' , { name : 'Run query ' } ) ;
3636 expect ( runButton ) . toBeInTheDocument ( ) ;
37- const stopButton = screen . queryByRole ( 'button' , { name : 'Stop' } ) ;
37+ const stopButton = screen . queryByRole ( 'button' , { name : 'Stop query ' } ) ;
3838 expect ( stopButton ) . not . toBeInTheDocument ( ) ;
3939 } ) ;
4040
4141 it ( 'renders the `Run` and `Stop` buttons if onCancelQuery defined' , ( ) => {
4242 const props = getDefaultProps ( ) ;
4343 render ( < RunQueryButtons { ...props } /> ) ;
44- const runButton = screen . getByRole ( 'button' , { name : 'Run' } ) ;
44+ const runButton = screen . getByRole ( 'button' , { name : 'Run query ' } ) ;
4545 expect ( runButton ) . toBeInTheDocument ( ) ;
46- const stopButton = screen . queryByRole ( 'button' , { name : 'Stop' } ) ;
46+ const stopButton = screen . queryByRole ( 'button' , { name : 'Stop query ' } ) ;
4747 expect ( stopButton ) . toBeInTheDocument ( ) ;
4848 } ) ;
4949} ) ;
0 commit comments