Skip to content

Commit db8591a

Browse files
committed
[PROF-13798] 👌 Fix lint: use typed helper to avoid unsafe-return in quotaCheck.spec.ts
1 parent 0c10968 commit db8591a

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

‎packages/rum/src/domain/profiling/quotaCheck.spec.ts‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ const backendResponse =
1010
json: () => Promise.resolve({ data: { attributes: { admitted, reason } } }),
1111
})
1212

13+
const unparseableResponse =
14+
(status: number): (() => Promise<unknown>) =>
15+
() =>
16+
Promise.resolve({ status, json: () => Promise.reject(new Error('invalid json')) })
17+
1318
describe('checkProfilingQuota', () => {
1419
let interceptor: ReturnType<typeof interceptRequests>
1520

@@ -63,17 +68,13 @@ describe('checkProfilingQuota', () => {
6368
})
6469

6570
it('returns quota_ok with api-error reason when response body is unparseable and status is 200', async () => {
66-
interceptor.withFetch(
67-
() => Promise.resolve({ status: 200, json: () => Promise.reject(new Error('invalid json')) }) as any
68-
)
71+
interceptor.withFetch(unparseableResponse(200))
6972
const result = await checkProfilingQuota(mockRumConfiguration(), 'session-123')
7073
expect(result).toEqual({ decision: 'quota_ok', reason: 'api-error' })
7174
})
7275

7376
it('returns quota_ko with quota_exceeded reason when response body is unparseable and status is 429', async () => {
74-
interceptor.withFetch(
75-
() => Promise.resolve({ status: 429, json: () => Promise.reject(new Error('invalid json')) }) as any
76-
)
77+
interceptor.withFetch(unparseableResponse(429))
7778
const result = await checkProfilingQuota(mockRumConfiguration(), 'session-123')
7879
expect(result).toEqual({ decision: 'quota_ko', reason: 'quota_exceeded' })
7980
})

0 commit comments

Comments
 (0)