From 003f992b9e11bb0aab6cbbf5f0fb2c243d821f4a Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Wed, 8 Jan 2025 18:15:35 -0800 Subject: [PATCH] fixing --- .../spec/helpers/{theming.ts => theming.tsx} | 7 ++++++- .../src/components/ErrorMessage/ErrorAlert.test.tsx | 2 +- .../src/utils/{testUtils.tsx => testUtils.ts} | 10 ++-------- 3 files changed, 9 insertions(+), 10 deletions(-) rename superset-frontend/spec/helpers/{theming.ts => theming.tsx} (85%) rename superset-frontend/src/utils/{testUtils.tsx => testUtils.ts} (82%) diff --git a/superset-frontend/spec/helpers/theming.ts b/superset-frontend/spec/helpers/theming.tsx similarity index 85% rename from superset-frontend/spec/helpers/theming.ts rename to superset-frontend/spec/helpers/theming.tsx index e364b413457f9..c54d46a384d3f 100644 --- a/superset-frontend/spec/helpers/theming.ts +++ b/superset-frontend/spec/helpers/theming.tsx @@ -18,9 +18,11 @@ */ import { shallow as enzymeShallow, mount as enzymeMount } from 'enzyme'; // eslint-disable-next-line no-restricted-imports -import { supersetTheme } from '@superset-ui/core'; import { ReactElement } from 'react'; +import { render } from '@testing-library/react'; +import { ThemeProvider, supersetTheme } from '@superset-ui/core'; import { ProviderWrapper } from './ProviderWrapper'; +import '@testing-library/jest-dom'; type optionsType = { wrappingComponentProps?: any; @@ -55,3 +57,6 @@ export function styledShallow( }, }); } + +export const renderWithTheme = (component: JSX.Element) => + render({component}); diff --git a/superset-frontend/src/components/ErrorMessage/ErrorAlert.test.tsx b/superset-frontend/src/components/ErrorMessage/ErrorAlert.test.tsx index aa208f6669c68..740792787552f 100644 --- a/superset-frontend/src/components/ErrorMessage/ErrorAlert.test.tsx +++ b/superset-frontend/src/components/ErrorMessage/ErrorAlert.test.tsx @@ -18,7 +18,7 @@ */ import { screen, fireEvent } from '@testing-library/react'; -import { renderWithTheme } from 'src/utils/testUtils'; +import { renderWithTheme } from 'spec/helpers/theming'; import ErrorAlert from './ErrorAlert'; describe('ErrorAlert', () => { diff --git a/superset-frontend/src/utils/testUtils.tsx b/superset-frontend/src/utils/testUtils.ts similarity index 82% rename from superset-frontend/src/utils/testUtils.tsx rename to superset-frontend/src/utils/testUtils.ts index f3c6e2b9a4ba5..c62ce741a2889 100644 --- a/superset-frontend/src/utils/testUtils.tsx +++ b/superset-frontend/src/utils/testUtils.ts @@ -16,16 +16,11 @@ * specific language governing permissions and limitations * under the License. */ -import { ThemeProvider, supersetTheme, JsonObject } from '@superset-ui/core'; -import { render } from '@testing-library/react'; -import '@testing-library/jest-dom'; +import { JsonObject } from '@superset-ui/core'; type TestWithIdType = T extends string ? string : { 'data-test': string }; -export const renderWithTheme = (component: JSX.Element) => - render({component}); - -// using bem standard +// Using bem standard export const testWithId = ( prefix?: string, @@ -42,7 +37,6 @@ export const testWithId = return (resultIdOnly ? id : { 'data-test': id }) as TestWithIdType; } if (!id && !prefix) { - // eslint-disable-next-line no-console console.warn('testWithId function has missed "prefix" and "id" params'); return (resultIdOnly ? '' : { 'data-test': '' }) as TestWithIdType; }