@@ -5,7 +5,12 @@ import {
5
5
LoadingState ,
6
6
PanelProps ,
7
7
} from '@grafana/data' ;
8
- import { getBackendSrv , getDataSourceSrv , SystemJS } from '@grafana/runtime' ;
8
+ import {
9
+ getBackendSrv ,
10
+ getDataSourceSrv ,
11
+ getTemplateSrv ,
12
+ SystemJS ,
13
+ } from '@grafana/runtime' ;
9
14
import { Button , HorizontalGroup , VerticalGroup } from '@grafana/ui' ;
10
15
import { shallow } from 'enzyme' ;
11
16
import React from 'react' ;
@@ -64,6 +69,10 @@ describe('button panel', () => {
64
69
] ;
65
70
wrapper . setProps ( { options : { buttons : buttons } } ) ;
66
71
72
+ const mockTemplate = jest . fn ( ) . mockReturnValue ( '{}' ) ;
73
+ ( getTemplateSrv as jest . Mock < any > ) . mockImplementation ( ( ) => ( {
74
+ replace : mockTemplate ,
75
+ } ) ) ;
67
76
const mockGet = jest . fn ( ) . mockReturnValue ( { id : 1 } ) ;
68
77
( getDataSourceSrv as jest . Mock < any > ) . mockImplementation ( ( ) => ( {
69
78
get : mockGet ,
@@ -88,6 +97,7 @@ describe('button panel', () => {
88
97
expect ( b . text ( ) ) . toBe ( buttons [ i ] . text ) ;
89
98
b . simulate ( 'click' ) ;
90
99
setImmediate ( ( ) => {
100
+ expect ( mockTemplate ) . toHaveBeenCalled ( ) ;
91
101
expect ( mockGet ) . toHaveBeenCalledWith ( buttons [ i ] . datasource ) ;
92
102
expect ( mockDataSourceRequest ) . toHaveBeenCalled ( ) ;
93
103
expect ( mockEmit ) . toHaveBeenCalledWith ( AppEvents . alertSuccess , [
@@ -108,6 +118,10 @@ describe('button panel', () => {
108
118
( getDataSourceSrv as jest . Mock < any > ) . mockImplementation ( ( ) => ( {
109
119
get : mockGet ,
110
120
} ) ) ;
121
+ const mockTemplate = jest . fn ( ) . mockReturnValue ( '{}' ) ;
122
+ ( getTemplateSrv as jest . Mock < any > ) . mockImplementation ( ( ) => ( {
123
+ replace : mockTemplate ,
124
+ } ) ) ;
111
125
const msg = 'msg' ;
112
126
const mockDataSourceRequest = jest . fn ( ) . mockRejectedValue ( {
113
127
status : statusError ,
0 commit comments