forked from renovatebot/renovate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
throttle.spec.ts
36 lines (29 loc) · 945 Bytes
/
throttle.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import * as hostRules from '../host-rules';
import { clear, getThrottle } from './throttle';
describe('util/http/throttle', () => {
beforeEach(() => {
clear();
hostRules.clear();
hostRules.add({
matchHost: 'https://example.com',
maxRequestsPerSecond: 143,
});
});
it('returns null for invalid URL', () => {
expect(getThrottle('$#@!', null)).toBeNull();
});
it('returns throttle for valid url', () => {
const t1a = getThrottle('https://example.com', null);
const t1b = getThrottle('https://example.com', null);
const t2a = getThrottle('https://example.com:8080', null);
const t2b = getThrottle('https://example.com:8080', null);
expect(t1a).not.toBeNull();
expect(t1a).toBe(t1b);
expect(t2a).not.toBeNull();
expect(t2a).toBe(t2b);
expect(t1a).not.toBe(t2a);
expect(t1a).not.toBe(t2b);
expect(t1b).not.toBe(t2a);
expect(t1b).not.toBe(t2b);
});
});