Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 2.x] test(usage_collection): expose a function to mock plugin start #8314

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/plugins/usage_collection/public/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@
* under the License.
*/

import { UsageCollectionSetup, METRIC_TYPE } from '.';
import { UsageCollectionSetup, UsageCollectionStart, METRIC_TYPE } from '.';

export type Setup = jest.Mocked<UsageCollectionSetup>;
export type Start = jest.Mocked<UsageCollectionStart>;

const createSetupContract = (): Setup => {
const setupContract: Setup = {
Expand All @@ -45,6 +46,16 @@
return setupContract;
};

const createStartContract = (): Start => {
const startContract: Start = {

Check warning on line 50 in src/plugins/usage_collection/public/mocks.ts

View check run for this annotation

Codecov / codecov/patch

src/plugins/usage_collection/public/mocks.ts#L50

Added line #L50 was not covered by tests
reportUiStats: jest.fn(),
METRIC_TYPE,
};

return startContract;

Check warning on line 55 in src/plugins/usage_collection/public/mocks.ts

View check run for this annotation

Codecov / codecov/patch

src/plugins/usage_collection/public/mocks.ts#L55

Added line #L55 was not covered by tests
};

export const usageCollectionPluginMock = {
createSetupContract,
createStartContract,
};
Loading