Do not unpack arguments directly on exported items
Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
@@ -120,11 +120,13 @@ export class TestApiRegistry implements ApiHolder {
|
||||
*
|
||||
* @public
|
||||
**/
|
||||
export const TestApiProvider = <T extends any[]>({
|
||||
apis,
|
||||
children,
|
||||
}: TestApiProviderProps<T>) => {
|
||||
export const TestApiProvider = <T extends any[]>(
|
||||
props: TestApiProviderProps<T>,
|
||||
) => {
|
||||
return (
|
||||
<ApiProvider apis={TestApiRegistry.from(...apis)} children={children} />
|
||||
<ApiProvider
|
||||
apis={TestApiRegistry.from(...props.apis)}
|
||||
children={props.children}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -19,18 +19,15 @@ import { AnalyticsApi, AnalyticsEvent } from '@backstage/core-plugin-api';
|
||||
/**
|
||||
* Mock implementation of {@link core-plugin-api#AnalyticsApi} with helpers to ensure that events are sent correctly.
|
||||
* Use getEvents in tests to verify captured events.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export class MockAnalyticsApi implements AnalyticsApi {
|
||||
private events: AnalyticsEvent[] = [];
|
||||
|
||||
captureEvent({
|
||||
action,
|
||||
subject,
|
||||
value,
|
||||
attributes,
|
||||
context,
|
||||
}: AnalyticsEvent) {
|
||||
captureEvent(event: AnalyticsEvent) {
|
||||
const { action, subject, value, attributes, context } = event;
|
||||
|
||||
this.events.push({
|
||||
action,
|
||||
subject,
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* This is a mocking method suggested in the Jest Doc's, as it is not implemented in JSDOM yet.
|
||||
* It can be used to mock values when the MUI `useMediaQuery` hook if it is used in a tested component.
|
||||
* This is a mocking method suggested in the Jest docs, as it is not implemented in JSDOM yet.
|
||||
* It can be used to mock values for the MUI `useMediaQuery` hook if it is used in a tested component.
|
||||
*
|
||||
* For issues checkout the documentation:
|
||||
* https://jestjs.io/docs/manual-mocks#mocking-methods-which-are-not-implemented-in-jsdom
|
||||
@@ -26,11 +26,11 @@
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export default function mockBreakpoint({ matches = false }) {
|
||||
export default function mockBreakpoint(options: { matches: boolean }) {
|
||||
Object.defineProperty(window, 'matchMedia', {
|
||||
writable: true,
|
||||
value: jest.fn().mockImplementation(query => ({
|
||||
matches: matches,
|
||||
matches: options.matches ?? false,
|
||||
media: query,
|
||||
onchange: null,
|
||||
addListener: jest.fn(), // deprecated
|
||||
|
||||
Reference in New Issue
Block a user