From b783e7576cee8cc05e80a05243be1f97cde2bf5f Mon Sep 17 00:00:00 2001 From: mortalYoung Date: Fri, 17 Sep 2021 14:08:05 +0800 Subject: [PATCH] fix: renderPane exec twice --- .../__snapshots__/tabs.test.tsx.snap | 22 ------- src/components/tabs/__tests__/tabs.test.tsx | 22 +------ src/components/tabs/index.tsx | 26 +------- .../__snapshots__/workbench.test.tsx.snap | 13 ---- .../__snapshots__/panel.test.tsx.snap | 63 ------------------- src/workbench/panel/__tests__/panel.test.tsx | 4 +- 6 files changed, 4 insertions(+), 146 deletions(-) diff --git a/src/components/tabs/__tests__/__snapshots__/tabs.test.tsx.snap b/src/components/tabs/__tests__/__snapshots__/tabs.test.tsx.snap index 1a44951be..459e268c7 100644 --- a/src/components/tabs/__tests__/__snapshots__/tabs.test.tsx.snap +++ b/src/components/tabs/__tests__/__snapshots__/tabs.test.tsx.snap @@ -44,27 +44,5 @@ exports[`The Tabs Components The snapshot 1`] = ` -
-
-
- test1 -
-
-
-
- test2 -
-
-
`; diff --git a/src/components/tabs/__tests__/tabs.test.tsx b/src/components/tabs/__tests__/tabs.test.tsx index 8d288ebb5..02168a6c7 100644 --- a/src/components/tabs/__tests__/tabs.test.tsx +++ b/src/components/tabs/__tests__/tabs.test.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { cleanup, fireEvent, render, waitFor } from '@testing-library/react'; import renderer from 'react-test-renderer'; import '@testing-library/jest-dom'; -import { Tabs, tabsClassName, tabsContentActiveClassName } from '..'; +import { Tabs, tabsClassName } from '..'; import { ITabProps, tabItemActiveClassName } from '../tab'; import { dragToTargetNode } from '@test/utils'; @@ -32,10 +32,8 @@ describe('The Tabs Components', () => { test('Should render nothing', () => { const { container } = render(); - const content = container.querySelector('.mo-tabs__content'); const header = container.querySelector('.mo-tabs__header'); - expect(content?.childElementCount).toBe(0); expect(header?.childElementCount).toBe(0); }); @@ -49,18 +47,6 @@ describe('The Tabs Components', () => { expect(body.classList).toContain('test-tabs'); }); - test('Should support to renderPane via function', () => { - const data = mockData.concat(); - data.push({ - id: '3', - name: 'test-title-3', - renderPane: () =>
test3
, - closable: true, - }); - const { getByTestId } = render(); - expect(getByTestId('test3')).toBeInTheDocument(); - }); - test('Should render card type', () => { const { container } = render(); @@ -69,13 +55,9 @@ describe('The Tabs Components', () => { }); test('Should active specific tab', () => { - const { getByText, getByTestId } = render( - - ); + const { getByText } = render(); const testHeader = getByText('test-title-1'); - const testContent = getByTestId('test1').parentElement; expect(testHeader?.classList).toContain(tabItemActiveClassName); - expect(testContent?.classList).toContain(tabsContentActiveClassName); }); test('Should trigger events', async () => { diff --git a/src/components/tabs/index.tsx b/src/components/tabs/index.tsx index 1043c93cb..4ffc2a851 100644 --- a/src/components/tabs/index.tsx +++ b/src/components/tabs/index.tsx @@ -9,7 +9,7 @@ import { classNames, } from 'mo/common/className'; -import { Tab, ITabProps, tabItemClassName } from './tab'; +import { Tab, ITabProps } from './tab'; import DragAndDrop from './dragAndDrop'; export type TabsType = 'line' | 'card'; @@ -28,13 +28,6 @@ export interface ITabsProps extends React.ComponentProps { export const tabsClassName = prefixClaName('tabs'); export const tabsHeader = getBEMElement(tabsClassName, 'header'); -export const tabsContent = getBEMElement(tabsClassName, 'content'); -export const tabsContentItem = getBEMElement(tabsContent, 'item'); -export const tabsContentActiveClassName = getBEMModifier( - tabsContentItem, - 'active' -); -export const tabItemCloseClassName = getBEMElement(tabItemClassName, 'close'); export function Tabs(props: ITabsProps) { const { @@ -88,23 +81,6 @@ export function Tabs(props: ITabsProps) { ); })} -
- {data?.map((tab: ITabProps) => { - return ( -
- {tab.renderPane instanceof Function - ? tab.renderPane(tab) - : tab.renderPane} -
- ); - })} -
); diff --git a/src/workbench/__tests__/__snapshots__/workbench.test.tsx.snap b/src/workbench/__tests__/__snapshots__/workbench.test.tsx.snap index 296d048a2..99a5b22ff 100644 --- a/src/workbench/__tests__/__snapshots__/workbench.test.tsx.snap +++ b/src/workbench/__tests__/__snapshots__/workbench.test.tsx.snap @@ -433,19 +433,6 @@ exports[`Test Workbench Component Match The WorkbenchView snapshot 1`] = ` 问题 -
-
-
- 未在工作区检测到问题 -
-
-
-
-
-
-
-
-
-
-
-
-
-
- 未在工作区检测到问题 -
-
-
-
-
-
-
-
{ expect( container.querySelector('.mo-monaco-editor') ).not.toBeInTheDocument(); - // The customizedPane element are rendered in two places(mo-panel__container/mo-tabs__content), - // so the expect value is 2 - expect(getAllByText('customizedPane').length).toBe(2); + expect(getAllByText('customizedPane').length).toBe(1); }); test('Sort the Panel ', () => {