Skip to content

Commit

Permalink
test(usage_collection): expose a function to mock plugin start (#8235)
Browse files Browse the repository at this point in the history
Signed-off-by: Yulong Ruan <ruanyl@amazon.com>
  • Loading branch information
ruanyl authored Sep 24, 2024
1 parent c8c01fc commit 9fd0f0b
Showing 1 changed file with 12 additions and 1 deletion.
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 @@ const createSetupContract = (): Setup => {
return setupContract;
};

const createStartContract = (): Start => {
const startContract: Start = {
reportUiStats: jest.fn(),
METRIC_TYPE,
};

return startContract;
};

export const usageCollectionPluginMock = {
createSetupContract,
createStartContract,
};

0 comments on commit 9fd0f0b

Please sign in to comment.