@@ -18,10 +18,6 @@ const gauge = {
18
18
labels : jest . fn ( ) . mockImplementation ( ( ) => ( { set : gaugeSet } ) ) ,
19
19
} ;
20
20
21
- const isResultFoundCallback = ( result : Awaited < number [ ] > ) : boolean => {
22
- return result . length > 0 ;
23
- } ;
24
-
25
21
jest . mock ( 'prom-client' , ( ) => ( {
26
22
Histogram : jest . fn ( ) . mockImplementation ( ( ) => histogram ) ,
27
23
Counter : jest . fn ( ) . mockImplementation ( ( ) => counter ) ,
@@ -68,60 +64,6 @@ describe('PrometheusPlugin', () => {
68
64
expect ( counterInc ) . toHaveBeenCalledWith ( 1 ) ;
69
65
expect ( counter . labels ) . toHaveBeenCalledWith ( { result : 'success' } ) ;
70
66
expect ( counterInc ) . toHaveBeenCalledWith ( 1 ) ;
71
- expect ( counter . labels ) . not . toHaveBeenCalledWith ( { result : 'found' } ) ;
72
- expect ( counter . labels ) . not . toHaveBeenCalledWith ( { result : 'notFound' } ) ;
73
- expect ( histogram . labels ) . toHaveBeenCalledWith ( { result : 'success' } ) ;
74
- expect ( histogramObserve ) . toHaveBeenCalledWith ( expect . any ( Number ) ) ;
75
- } ) ;
76
-
77
- it ( 'reports result found on onSuccess' , ( ) => {
78
- monitor . monitored ( 'abc' , ( ) => [ 1 , 2 , 3 ] , { shouldMonitorResultFound : isResultFoundCallback } ) ;
79
-
80
- expect ( Counter ) . toHaveBeenCalledWith ( {
81
- name : `abc_count` ,
82
- help : `abc_count` ,
83
- labelNames : [ 'result' ] ,
84
- } ) ;
85
-
86
- expect ( Histogram ) . toHaveBeenCalledWith ( {
87
- name : `abc_execution_time` ,
88
- help : `abc_execution_time` ,
89
- buckets : DEFAULT_BUCKETS ,
90
- labelNames : [ 'result' ] ,
91
- } ) ;
92
-
93
- expect ( counter . labels ) . toHaveBeenCalledWith ( { result : 'start' } ) ;
94
- expect ( counterInc ) . toHaveBeenCalledWith ( 1 ) ;
95
- expect ( counter . labels ) . toHaveBeenCalledWith ( { result : 'success' } ) ;
96
- expect ( counterInc ) . toHaveBeenCalledWith ( 1 ) ;
97
- expect ( counter . labels ) . toHaveBeenCalledWith ( { result : 'found' } ) ;
98
- expect ( counterInc ) . toHaveBeenCalledWith ( 1 ) ;
99
- expect ( histogram . labels ) . toHaveBeenCalledWith ( { result : 'success' } ) ;
100
- expect ( histogramObserve ) . toHaveBeenCalledWith ( expect . any ( Number ) ) ;
101
- } ) ;
102
-
103
- it ( 'reports result not found on onSuccess' , ( ) => {
104
- monitor . monitored ( 'abc' , ( ) => [ ] , { shouldMonitorResultFound : isResultFoundCallback } ) ;
105
-
106
- expect ( Counter ) . toHaveBeenCalledWith ( {
107
- name : `abc_count` ,
108
- help : `abc_count` ,
109
- labelNames : [ 'result' ] ,
110
- } ) ;
111
-
112
- expect ( Histogram ) . toHaveBeenCalledWith ( {
113
- name : `abc_execution_time` ,
114
- help : `abc_execution_time` ,
115
- buckets : DEFAULT_BUCKETS ,
116
- labelNames : [ 'result' ] ,
117
- } ) ;
118
-
119
- expect ( counter . labels ) . toHaveBeenCalledWith ( { result : 'start' } ) ;
120
- expect ( counterInc ) . toHaveBeenCalledWith ( 1 ) ;
121
- expect ( counter . labels ) . toHaveBeenCalledWith ( { result : 'success' } ) ;
122
- expect ( counterInc ) . toHaveBeenCalledWith ( 1 ) ;
123
- expect ( counter . labels ) . toHaveBeenCalledWith ( { result : 'notFound' } ) ;
124
- expect ( counterInc ) . toHaveBeenCalledWith ( 1 ) ;
125
67
expect ( histogram . labels ) . toHaveBeenCalledWith ( { result : 'success' } ) ;
126
68
expect ( histogramObserve ) . toHaveBeenCalledWith ( expect . any ( Number ) ) ;
127
69
} ) ;
@@ -137,30 +79,6 @@ describe('PrometheusPlugin', () => {
137
79
expect ( counterInc ) . toHaveBeenCalledWith ( 1 ) ;
138
80
expect ( counter . labels ) . toHaveBeenCalledWith ( { result : 'failure' } ) ;
139
81
expect ( counterInc ) . toHaveBeenCalledWith ( 1 ) ;
140
- expect ( counter . labels ) . not . toHaveBeenCalledWith ( { result : 'found' } ) ;
141
- expect ( counter . labels ) . not . toHaveBeenCalledWith ( { result : 'notFound' } ) ;
142
- } ) ;
143
-
144
- it ( 'not to report result found onFailure' , ( ) => {
145
- expect ( ( ) =>
146
- monitor . monitored (
147
- 'abc' ,
148
- ( ) => {
149
- if ( false ) {
150
- return [ 1 , 2 ] ;
151
- }
152
- throw new Error ( '123' ) ;
153
- } ,
154
- { shouldMonitorResultFound : isResultFoundCallback }
155
- )
156
- ) . toThrow ( ) ;
157
-
158
- expect ( counter . labels ) . toHaveBeenCalledWith ( { result : 'start' } ) ;
159
- expect ( counterInc ) . toHaveBeenCalledWith ( 1 ) ;
160
- expect ( counter . labels ) . toHaveBeenCalledWith ( { result : 'failure' } ) ;
161
- expect ( counterInc ) . toHaveBeenCalledWith ( 1 ) ;
162
- expect ( counter . labels ) . not . toHaveBeenCalledWith ( { result : 'found' } ) ;
163
- expect ( counter . labels ) . not . toHaveBeenCalledWith ( { result : 'notFound' } ) ;
164
82
} ) ;
165
83
166
84
it ( 'should call registry' , ( ) => {
0 commit comments