Chore: fixes React hook betterer for EditDataSource.test.tsx (#110104)

This commit is contained in:
Hugo Häggmark
2025-08-26 06:56:51 +02:00
committed by GitHub
parent bacb5c576c
commit 6b67b394fd
2 changed files with 8 additions and 12 deletions
-4
View File
@@ -2358,10 +2358,6 @@ exports[`better eslint`] = {
[0, 0, 0, "Add noMargin prop to Card components to remove built-in margins. Use layout components like Stack or Grid with the gap prop instead for consistent spacing.", "0"],
[0, 0, 0, "Add noMargin prop to Card components to remove built-in margins. Use layout components like Stack or Grid with the gap prop instead for consistent spacing.", "1"]
],
"public/app/features/datasources/components/EditDataSource.test.tsx:5381": [
[0, 0, 0, "React Hook \\"useEffect\\" is called in function \\"component\\" that is neither a React function component nor a custom React Hook function. React component names must start with an uppercase letter. React Hook names must start with the word \\"use\\".", "0"],
[0, 0, 0, "React Hook \\"useEffect\\" is called in function \\"component\\" that is neither a React function component nor a custom React Hook function. React component names must start with an uppercase letter. React Hook names must start with the word \\"use\\".", "1"]
],
"public/app/features/datasources/components/picker/DataSourceCard.tsx:5381": [
[0, 0, 0, "Add noMargin prop to Card components to remove built-in margins. Use layout components like Stack or Grid with the gap prop instead for consistent spacing.", "0"]
],
@@ -326,7 +326,7 @@ describe('<EditDataSource>', () => {
it('should pass a context prop to the rendered UI extension component', () => {
const message = "I'm a UI extension component!";
const component = jest.fn().mockReturnValue(<div>{message}</div>);
const Component = jest.fn().mockReturnValue(<div>{message}</div>);
setPluginComponentsHook(
jest.fn().mockReturnValue({
@@ -337,7 +337,7 @@ describe('<EditDataSource>', () => {
pluginId: 'grafana-pdc-app',
title: 'Example component',
description: 'Example description',
component,
component: Component,
},
'1'
),
@@ -353,9 +353,9 @@ describe('<EditDataSource>', () => {
},
});
expect(component).toHaveBeenCalled();
expect(Component).toHaveBeenCalled();
const props = component.mock.calls[0][0];
const props = Component.mock.calls[0][0];
expect(props.context).toBeDefined();
expect(props.context.dataSource).toBeDefined();
@@ -368,7 +368,7 @@ describe('<EditDataSource>', () => {
it('should be possible to update the `jsonData` first and `secureJsonData` directly afterwards from the extension component', () => {
const message = "I'm a UI extension component!";
const component = ({ context }: { context: PluginExtensionDataSourceConfigContext }) => {
const Component = ({ context }: { context: PluginExtensionDataSourceConfigContext }) => {
useEffect(() => {
context.setJsonData({ test: 'test' } as unknown as DataSourceJsonData);
context.setSecureJsonData({ test: 'test' });
@@ -387,7 +387,7 @@ describe('<EditDataSource>', () => {
pluginId: 'grafana-pdc-app',
title: 'Example component',
description: 'Example description',
component: component as unknown as React.ComponentType<{}>,
component: Component as unknown as React.ComponentType<{}>,
},
'1'
),
@@ -413,7 +413,7 @@ describe('<EditDataSource>', () => {
it('should be possible to update the `secureJsonData` first and `jsonData` directly afterwards from the extension component', () => {
const message = "I'm a UI extension component!";
const component = ({ context }: { context: PluginExtensionDataSourceConfigContext }) => {
const Component = ({ context }: { context: PluginExtensionDataSourceConfigContext }) => {
useEffect(() => {
context.setSecureJsonData({ test: 'test' });
context.setJsonData({ test: 'test' } as unknown as DataSourceJsonData);
@@ -432,7 +432,7 @@ describe('<EditDataSource>', () => {
pluginId: 'grafana-pdc-app',
title: 'Example component',
description: 'Example description',
component: component as unknown as React.ComponentType<{}>,
component: Component as unknown as React.ComponentType<{}>,
},
'1'
),