/
bluetooth.health.spec.ts
35 lines (28 loc) · 1.06 KB
/
bluetooth.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 { BluetoothHealthIndicator } from './bluetooth.health';
import { HealthCheckError } from '@nestjs/terminus';
describe('BluetoothHealthIndicator', () => {
let healthIndicator: BluetoothHealthIndicator;
beforeEach(() => {
healthIndicator = new BluetoothHealthIndicator();
});
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');
});
});