implement analytics too
Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
@@ -20,11 +20,7 @@ import { renderHook, act, waitFor } from '@testing-library/react';
|
||||
import { ThemeProvider } from '@material-ui/core/styles';
|
||||
|
||||
import { lightTheme } from '@backstage/theme';
|
||||
import {
|
||||
MockAnalyticsApi,
|
||||
mockApis,
|
||||
TestApiProvider,
|
||||
} from '@backstage/test-utils';
|
||||
import { mockApis, TestApiProvider } from '@backstage/test-utils';
|
||||
import { Entity, CompoundEntityRef } from '@backstage/catalog-model';
|
||||
import {
|
||||
analyticsApiRef,
|
||||
@@ -66,7 +62,7 @@ const techdocsApiMock = {
|
||||
getTechDocsMetadata: jest.fn().mockResolvedValue(mockTechDocsMetadata),
|
||||
};
|
||||
|
||||
const analyticsApiMock = new MockAnalyticsApi();
|
||||
const analyticsApiMock = mockApis.analytics();
|
||||
|
||||
const wrapper = ({
|
||||
entityRef = {
|
||||
@@ -170,12 +166,12 @@ describe('useTechDocsReaderPage', () => {
|
||||
wrapper,
|
||||
});
|
||||
await waitFor(() => {
|
||||
expect(analyticsApiMock.getEvents()[0]).toMatchObject({
|
||||
expect(analyticsApiMock.captureEvent).toHaveBeenCalledWith({
|
||||
action: 'action',
|
||||
subject: 'subject',
|
||||
context: {
|
||||
context: expect.objectContaining({
|
||||
entityRef: 'component:default/test',
|
||||
},
|
||||
}),
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user