-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bluetooth-classic.health.spec.ts
35 lines (28 loc) · 1.1 KB
/
bluetooth-classic.health.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
import { BluetoothClassicHealthIndicator } from './bluetooth-classic.health';
import { HealthCheckError } from '@nestjs/terminus';
describe('BluetoothClassicHealthIndicator', () => {
let healthIndicator: BluetoothClassicHealthIndicator;
beforeEach(() => {
healthIndicator = new BluetoothClassicHealthIndicator();
});
it('should report healthy by default', () => {
const result = healthIndicator.successiveErrorCheck(3);
expect(result['bt_successive_errors'].status).toEqual('up');
});
it('should report unhealthy after meeting the threshold', () => {
healthIndicator.reportError();
healthIndicator.reportError();
healthIndicator.reportError();
expect(() => healthIndicator.successiveErrorCheck(3)).toThrow(
HealthCheckError
);
});
it('should reset the error count on success', () => {
healthIndicator.reportError();
healthIndicator.reportError();
healthIndicator.reportError();
healthIndicator.reportSuccess();
const result = healthIndicator.successiveErrorCheck(3);
expect(result['bt_successive_errors'].status).toEqual('up');
});
});