Skip to content

Commit

Permalink
[Test] Enable unit test suite: telemetry_sender.test.ts
Browse files Browse the repository at this point in the history
Remove all the original comment out lines. If needs
restore the unit test, can revert this commit.

Signed-off-by: Anan Zhuang <[email protected]>
  • Loading branch information
ananzh committed Jun 24, 2021
1 parent 4a0ad4a commit 506ffb7
Showing 1 changed file with 0 additions and 18 deletions.
18 changes: 0 additions & 18 deletions src/plugins/telemetry/public/services/telemetry_sender.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ describe('TelemetrySender', () => {
const shouldSendRerpot = telemetrySender['shouldSendReport']();

expect(telemetrySender['lastReported']).toBeUndefined();
// expect(shouldSendRerpot).toBe(true);
expect(shouldSendRerpot).toBe(false);
});

Expand All @@ -120,7 +119,6 @@ describe('TelemetrySender', () => {
const telemetrySender = new TelemetrySender(telemetryService);
telemetrySender['lastReported'] = `${lastReported}`;
const shouldSendRerpot = telemetrySender['shouldSendReport']();
// expect(shouldSendRerpot).toBe(true);
expect(shouldSendRerpot).toBe(false);
});

Expand All @@ -141,7 +139,6 @@ describe('TelemetrySender', () => {
const telemetrySender = new TelemetrySender(telemetryService);
telemetrySender['lastReported'] = `random_malformed_string`;
const shouldSendRerpot = telemetrySender['shouldSendReport']();
// expect(shouldSendRerpot).toBe(true);
expect(shouldSendRerpot).toBe(false);
});

Expand Down Expand Up @@ -192,17 +189,8 @@ describe('TelemetrySender', () => {
telemetrySender['isSending'] = false;
await telemetrySender['sendIfDue']();

// expect(telemetryService.fetchTelemetry).toBeCalledTimes(1);
expect(telemetryService.fetchTelemetry).toBeCalledTimes(0);
// expect(mockFetch).toBeCalledTimes(1);
expect(mockFetch).toBeCalledTimes(0);
// expect(mockFetch).toBeCalledWith(mockTelemetryUrl, {
// method: 'POST',
// headers: {
// 'Content-Type': 'application/json',
// },
// body: mockTelemetryPayload[0],
// });
});

it('sends report separately for every cluster', async () => {
Expand All @@ -217,9 +205,7 @@ describe('TelemetrySender', () => {
telemetrySender['isSending'] = false;
await telemetrySender['sendIfDue']();

// expect(telemetryService.fetchTelemetry).toBeCalledTimes(1);
expect(telemetryService.fetchTelemetry).toBeCalledTimes(0);
// expect(mockFetch).toBeCalledTimes(2);
expect(mockFetch).toBeCalledTimes(0);
});

Expand All @@ -236,7 +222,6 @@ describe('TelemetrySender', () => {

await telemetrySender['sendIfDue']();

// expect(mockFetch).toBeCalledTimes(1);
expect(mockFetch).toBeCalledTimes(0);
expect(telemetrySender['lastReported']).toBeDefined();
expect(telemetrySender['saveToBrowser']).toBeCalledTimes(1);
Expand All @@ -251,7 +236,6 @@ describe('TelemetrySender', () => {
throw Error('Error fetching usage');
});
await telemetrySender['sendIfDue']();
// expect(telemetryService.fetchTelemetry).toBeCalledTimes(1);
expect(telemetryService.fetchTelemetry).toBeCalledTimes(0);
expect(telemetrySender['lastReported']).toBeUndefined();
expect(telemetrySender['isSending']).toBe(false);
Expand All @@ -267,9 +251,7 @@ describe('TelemetrySender', () => {
throw Error('Error sending usage');
});
await telemetrySender['sendIfDue']();
// expect(telemetryService.fetchTelemetry).toBeCalledTimes(1);
expect(telemetryService.fetchTelemetry).toBeCalledTimes(0);
// expect(mockFetch).toBeCalledTimes(2);
expect(mockFetch).toBeCalledTimes(0);
expect(telemetrySender['lastReported']).toBeUndefined();
expect(telemetrySender['isSending']).toBe(false);
Expand Down

0 comments on commit 506ffb7

Please sign in to comment.