Skip to content

Commit

Permalink
[Test] Enable unit test suite: telemetry_service.test.ts (#499) (#502)
Browse files Browse the repository at this point in the history
All the unit tests related to unused telemetry are temporarily
skipped after the fork. Unit tests of the disabled telemetry
functions should also be modified correspondingly. To build
a clean unit test, we decide to modify and enable all the
working unit tests. This PR modifies and enables
telemetry_service.test.ts.

There is one test case left: calls expected URL with 20 minutes
This test case is skipped due to function fetchTelemetry is disabled.
We should enable this test when fetchTelemtry function is restored.

Partially solved issue:
#499

Signed-off-by: Anan Zhuang <[email protected]>
  • Loading branch information
ananzh authored and kavilla committed Jun 26, 2021
1 parent e29040f commit 5c3fe56
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/plugins/telemetry/public/services/telemetry_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ jest.mock('moment', () => {
});
});

describe.skip('TelemetryService', () => {
describe('TelemetryService', () => {
// TODO: enable this unit test when fetchTelemtry function is restored
describe.skip('fetchTelemetry', () => {
it('calls expected URL with 20 minutes - now', async () => {
const telemetryService = mockTelemetryService();
Expand All @@ -70,7 +71,7 @@ describe.skip('TelemetryService', () => {
});
});

describe.skip('fetchExample', () => {
describe('fetchExample', () => {
it('calls fetchTelemetry with unencrupted: true', async () => {
const telemetryService = mockTelemetryService();
telemetryService.fetchTelemetry = jest.fn();
Expand All @@ -79,7 +80,7 @@ describe.skip('TelemetryService', () => {
});
});

describe.skip('setOptIn', () => {
describe('setOptIn', () => {
it('does not call the api if canChangeOptInStatus==false', async () => {
const telemetryService = mockTelemetryService({
reportOptInStatusChange: false,
Expand Down Expand Up @@ -183,7 +184,7 @@ describe.skip('TelemetryService', () => {
});
});

describe.skip('getTelemetryUrl', () => {
describe('getTelemetryUrl', () => {
it('should return the config.url parameter', async () => {
const url = 'http://test.com';
const telemetryService = mockTelemetryService({
Expand All @@ -194,7 +195,7 @@ describe.skip('TelemetryService', () => {
});
});

describe.skip('setUserHasSeenNotice', () => {
describe('setUserHasSeenNotice', () => {
it('should hit the API and change the config', async () => {
const telemetryService = mockTelemetryService({
config: { telemetryNotifyUserAboutOptInDefault: undefined, userCanChangeSettings: true },
Expand Down Expand Up @@ -229,7 +230,7 @@ describe.skip('TelemetryService', () => {
});
});

describe.skip('getUserShouldSeeOptInNotice', () => {
describe('getUserShouldSeeOptInNotice', () => {
it('returns whether the user can update the telemetry config (has SavedObjects access)', () => {
const telemetryService = mockTelemetryService({
config: { userCanChangeSettings: undefined },
Expand Down

0 comments on commit 5c3fe56

Please sign in to comment.