@@ -197,3 +197,35 @@ describe('updateRateLimits()', () => {
197197 expect ( updatedRateLimits . all ) . toEqual ( 60_000 ) ;
198198 } ) ;
199199} ) ;
200+
201+ describe ( 'data category "metric_bucket"' , ( ) => {
202+ test ( 'should add limit for `metric_bucket` category when namespaces contain "custom"' , ( ) => {
203+ const rateLimits : RateLimits = { } ;
204+ const headers = {
205+ 'retry-after' : null ,
206+ 'x-sentry-rate-limits' : '42:metric_bucket:::custom' ,
207+ } ;
208+ const updatedRateLimits = updateRateLimits ( rateLimits , { headers } , 0 ) ;
209+ expect ( updatedRateLimits . metric_bucket ) . toEqual ( 42 * 1000 ) ;
210+ } ) ;
211+
212+ test ( 'should not add limit for `metric_bucket` category when namespaces do not contain "custom"' , ( ) => {
213+ const rateLimits : RateLimits = { } ;
214+ const headers = {
215+ 'retry-after' : null ,
216+ 'x-sentry-rate-limits' : '42:metric_bucket:::namespace1;namespace2' ,
217+ } ;
218+ const updatedRateLimits = updateRateLimits ( rateLimits , { headers } , 0 ) ;
219+ expect ( updatedRateLimits . metric_bucket ) . toBeUndefined ( ) ;
220+ } ) ;
221+
222+ test ( 'should add limit for `metric_bucket` category when namespaces are empty' , ( ) => {
223+ const rateLimits : RateLimits = { } ;
224+ const headers = {
225+ 'retry-after' : null ,
226+ 'x-sentry-rate-limits' : '42:metric_bucket' ,
227+ } ;
228+ const updatedRateLimits = updateRateLimits ( rateLimits , { headers } , 0 ) ;
229+ expect ( updatedRateLimits . metric_bucket ) . toEqual ( 42 * 1000 ) ;
230+ } ) ;
231+ } ) ;
0 commit comments