Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
test(design): add test cases (#2674)
白熱0db9c3692f37
diff --git a/common/shared/vite/index.js b/common/shared/vite/index.jsindex 590b6e0007..305617cc87 100644--- a/common/shared/vite/index.js+++ b/common/shared/vite/index.js@@ -77,6 +77,11 @@ function createViteConfig(overrideConfig, /** @type {IOptions} */ options) {'process.env.BUNDLE_TYPE': JSON.stringify(process.env.BUNDLE_TYPE ?? ''),},test: {+ css: {+ modules: {+ classNameStrategy: 'non-scoped',+ },+ },coverage: {reporter: ['html', 'json'],provider: 'custom',diff --git a/packages/design/src/components/avatar/Avatar.tsx b/packages/design/src/components/avatar/Avatar.tsxindex 10a4aea395..c7e49d3b95 100644--- a/packages/design/src/components/avatar/Avatar.tsx+++ b/packages/design/src/components/avatar/Avatar.tsx@@ -83,8 +83,8 @@ export function Avatar(props: IAvatarProps) {const sizeStyle =typeof size === 'number'? {- width: size,- height: size,+ width: `${size}px`,+ height: `${size}px`,lineHeight: `${size}px`,}: {};@@ -97,7 +97,7 @@ export function Avatar(props: IAvatarProps) {[styles.avatarSmall]: size === 'small',});- const fitStyle = fit ? { objectFit: fit } : {};+ const fitStyle = { objectFit: fit };if (src) {return (diff --git a/packages/design/src/components/avatar/__tests__/index.spec.tsx b/packages/design/src/components/avatar/__tests__/index.spec.tsxindex 703ffe9a80..6f2f96b4ef 100644--- a/packages/design/src/components/avatar/__tests__/index.spec.tsx+++ b/packages/design/src/components/avatar/__tests__/index.spec.tsx@@ -14,13 +14,15 @@* limitations under the License.*/-import { render } from '@testing-library/react';+import { afterEach, describe, expect, it } from 'vitest';+import { cleanup, render } from '@testing-library/react';import React from 'react';-import { describe, expect, it } from 'vitest';import { Avatar } from '../Avatar';describe('Avatar', () => {+ afterEach(cleanup);+it('renders correctly', () => {const { container } = render(<Avatar size="small">Jane Doe</Avatar>);expect(container);@@ -37,4 +39,18 @@ describe('Avatar', () => {expect(container.querySelector('img')).not.toBeNull();});++ it('renders the image with fit', () => {+ const { container } = render(<Avatar src="test.png" fit="contain" />);++ expect(container.innerHTML).contains('object-fit: contain');+ });++ it('renders the size with number', () => {+ const { container } = render(<Avatar size={100} />);++ expect(container.innerHTML).contains('width: 100px');+ expect(container.innerHTML).contains('height: 100px');+ expect(container.innerHTML).contains('line-height: 100px');+ });});diff --git a/packages/design/src/components/cascader-list/CascaderList.tsx b/packages/design/src/components/cascader-list/CascaderList.tsxindex 0c6f6c89a4..ea809864d7 100644--- a/packages/design/src/components/cascader-list/CascaderList.tsx+++ b/packages/design/src/components/cascader-list/CascaderList.tsx@@ -16,8 +16,9 @@import { CheckMarkSingle } from '@univerjs/icons';import clsx from 'clsx';-import React, { useMemo } from 'react';+import React, { useContext, useMemo } from 'react';+import { ConfigContext } from '../config-provider/ConfigProvider';import styles from './index.module.less';interface IOption {@@ -48,6 +49,8 @@ export interface ICascaderListProps {export function CascaderList(props: ICascaderListProps) {const { value, options = [], onChange } = props;+ const { locale } = useContext(ConfigContext);+const activeOptions = useMemo(() => {const activeOptions = [options];value.forEach((item, index) => {@@ -62,19 +65,19 @@ export function CascaderList(props: ICascaderListProps) {}, [value]);function handleChange(index: number, v: string) {- if (v === props.value[index]) {+ if (v === value[index]) {return;}- if (props.value[index + 1]) {- const newValue = props.value.slice(0, index + 1);+ if (value[index + 1]) {+ const newValue = value.slice(0, index + 1);newValue[index] = v;onChange(newValue);return;}- const newValue = [...props.value];+ const newValue = [...value];newValue[index] = v;onChange(newValue);@@ -108,11 +111,11 @@ export function CascaderList(props: ICascaderListProps) {): (<section key={index} className={styles.cascaderListEmpty}>- 无+ {locale?.CascaderList.empty}</section>))}- {value.length <= 0 && <section className={styles.cascaderListEmpty}>无</section>}+ {value.length <= 0 && <section className={styles.cascaderListEmpty}>{locale?.CascaderList.empty}</section>}</section>);}diff --git a/packages/design/src/components/cascader-list/__tests__/index.spec.tsx b/packages/design/src/components/cascader-list/__tests__/index.spec.tsxnew file mode 100644index 0000000000..371a74f446--- /dev/null+++ b/packages/design/src/components/cascader-list/__tests__/index.spec.tsx@@ -0,0 +1,49 @@+/**+ * Copyright 2023-present DreamNum Inc.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import { afterEach, describe, expect, it } from 'vitest';+import React from 'react';+import { cleanup, render } from '@testing-library/react';+import { CascaderList } from '../CascaderList';++describe('CascaderList', () => {+ afterEach(cleanup);++ // const options: ICascaderListProps['options'] = [+ // {+ // label: 'Option 1',+ // value: 'option1',+ // children: [+ // { label: 'Option 1-1', value: 'option1-1' },+ // { label: 'Option 1-2', value: 'option1-2' },+ // ],+ // },+ // {+ // label: 'Option 2',+ // value: 'option2',+ // children: [+ // { label: 'Option 2-1', value: 'option2-1' },+ // { label: 'Option 2-2', value: 'option2-2' },+ // ],+ // },+ // ];++ it('renders correctly with default props', () => {+ const { container } = render(<CascaderList value={[]} onChange={() => {}} />);++ expect(container).toBeTruthy();+ });+});diff --git a/packages/design/src/components/container/Container.stories.tsx b/packages/design/src/components/container/Container.stories.tsxdeleted file mode 100644index dc2629c5b0..0000000000--- a/packages/design/src/components/container/Container.stories.tsx+++ /dev/null@@ -1,37 +0,0 @@-/**- * Copyright 2023-present DreamNum Inc.- *- * Licensed under the Apache License, Version 2.0 (the "License");- * you may not use this file except in compliance with the License.- * You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing, software- * distributed under the License is distributed on an "AS IS" BASIS,- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.- * See the License for the specific language governing permissions and- * limitations under the License.- */--import type { Meta } from '@storybook/react';-import React from 'react';--import { Container } from './Container';--const meta: Meta<typeof Container> = {- title: 'Components / Container',- component: Container,- parameters: {- layout: 'centered',- },- tags: ['autodocs'],-};--export default meta;--export const Playground = {- render() {- return <Container>main container</Container>;- },-};diff --git a/packages/design/src/components/container/Container.tsx b/packages/design/src/components/container/Container.tsxdeleted file mode 100644index fbdf792824..0000000000--- a/packages/design/src/components/container/Container.tsx+++ /dev/null@@ -1,47 +0,0 @@-/**- * Copyright 2023-present DreamNum Inc.- *- * Licensed under the Apache License, Version 2.0 (the "License");- * you may not use this file except in compliance with the License.- * You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing, software- * distributed under the License is distributed on an "AS IS" BASIS,- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.- * See the License for the specific language governing permissions and- * limitations under the License.- */--import type { Ref } from 'react';-import React, { forwardRef } from 'react';--export interface IContainerProps {- children?: React.ReactNode;-- /** Semantic DOM class */- className?: string;-- /** Semantic DOM style */- style?: React.CSSProperties;-- /** Set the handler to handle `click` event */- onClick?: (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;-- /** Set the handler to handle `onContextMenu` event */- onContextMenu?: (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;-}--/**- * Container Component- */-export const Container = forwardRef((props: IContainerProps, ref: Ref<HTMLDivElement>) => {- const { children, className, style, onClick, onContextMenu } = props;-- return (- <section ref={ref} className={className} style={style} onClick={onClick} onContextMenu={onContextMenu}>- {children}- </section>- );-});diff --git a/packages/design/src/components/container/index.module.less b/packages/design/src/components/container/index.module.lessdeleted file mode 100644index 7248021105..0000000000--- a/packages/design/src/components/container/index.module.less+++ /dev/null@@ -1,4 +0,0 @@-.container-wrapper {- width: 100%;- height: 100%;-}diff --git a/packages/design/src/components/container/index.ts b/packages/design/src/components/container/index.tsdeleted file mode 100644index d6e3636273..0000000000--- a/packages/design/src/components/container/index.ts+++ /dev/null@@ -1,17 +0,0 @@-/**- * Copyright 2023-present DreamNum Inc.- *- * Licensed under the Apache License, Version 2.0 (the "License");- * you may not use this file except in compliance with the License.- * You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing, software- * distributed under the License is distributed on an "AS IS" BASIS,- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.- * See the License for the specific language governing permissions and- * limitations under the License.- */--export { Container, type IContainerProps } from './Container';diff --git a/packages/design/src/components/design-token/Palette.stories.tsx b/packages/design/src/components/design-token/Palette.stories.tsxindex 3c668f7de8..1b5f5948d4 100644--- a/packages/design/src/components/design-token/Palette.stories.tsx+++ b/packages/design/src/components/design-token/Palette.stories.tsx@@ -18,7 +18,8 @@ import type { Meta, StoryObj } from '@storybook/react';import React from 'react';import { defaultTheme, greenTheme } from '../../themes';-import { Palette } from './Palette';++import styles from './index.module.less';const themes: Record<string, Record<string, string>> = {default: defaultTheme,@@ -36,6 +37,208 @@ const meta: Meta = {export default meta;+interface IProps {+ theme: Record<string, string>;+}++const levelMap = ['50', '100', '200', '300', '400', '500', '600', '700', '800', '900'];++function convertToCSSVar(input: string): string {+ const dashCase = input.replace(/([A-Z])/g, (match) => `-${match.toLowerCase()}`).replace(/(\d+)/g, '-$1');++ return `--${dashCase}`;+}++export function Palette(props: IProps) {+ const { theme } = props;++ function generateColors(name: string, maxLevel: number) {+ const colors = [];+ for (let i = 0; i < maxLevel; i++) {+ colors.push(`${name}${levelMap[i]}`);+ }++ return colors;+ }++ const palettes = [+ {+ title: 'Brand / 品牌',+ colors: ['primaryColor', 'primaryColorHover'],+ },+ {+ title: 'Functional / 功能',+ colors: ['infoColor', 'successColor', 'warningColor', 'errorColor'],+ },+ {+ title: 'Text Color',+ colors: ['textColor', 'textColorSecondary', 'textColorSecondaryDarker', 'textColorTertiary'],+ },+ {+ title: 'Link',+ colors: ['linkColor'],+ },+ {+ title: 'Background',+ colors: ['bgColor', 'bgColorHover', 'bgColorSecondary'],+ },+ {+ title: 'Font Size',+ colors: ['fontSizeXs', 'fontSizeSm', 'fontSizeBase', 'fontSizeLg', 'fontSizeXl', 'fontSizeXxl'],+ },+ {+ title: 'Margin',+ colors: ['marginXs', 'marginXxs', 'marginSm', 'marginBase', 'marginLg', 'marginXl'],+ },+ {+ title: 'Padding',+ colors: ['paddingXs', 'paddingSm', 'paddingBase', 'paddingLg', 'paddingXl'],+ },+ {+ title: 'Border Color',+ colors: ['borderColor'],+ },+ {+ title: 'Scrollbar Color',+ colors: ['scrollbarColor', 'scrollbarColorHover', 'scrollbarColorActive'],+ },+ {+ title: 'Border Radius',+ colors: ['borderRadiusBase', 'borderRadiusLg', 'borderRadiusXl'],+ },+ {+ title: 'Box Shadow',+ colors: ['boxShadowBase', 'boxShadowLg'],+ },+ {+ title: 'Breakpoint',+ colors: ['breakpointXs', 'breakpointSm', 'breakpointBase', 'breakpointLg'],+ },+ {+ title: 'Loop Color',+ colors: [+ 'loopColor1',+ 'loopColor2',+ 'loopColor3',+ 'loopColor4',+ 'loopColor5',+ 'loopColor6',+ 'loopColor7',+ 'loopColor8',+ 'loopColor9',+ 'loopColor10',+ 'loopColor11',+ 'loopColor12',+ ],+ },+ {+ title: 'Ramu / 瑞木 / Red',+ colors: generateColors('red', 9),+ },+ {+ title: 'Hemerocallis / 萱草 / Orange',+ colors: generateColors('orange', 9),+ },+ {+ title: 'Marigold / 万寿菊 / Gold',+ colors: generateColors('gold', 9),+ },+ {+ title: 'Forsythia Suspensa / 连翘 / Yellow',+ colors: generateColors('yellow', 9),+ },+ {+ title: 'Eustoma Grandiflorum / 洋桔梗 / Verdancy',+ colors: generateColors('verdancy', 9),+ },+ {+ title: 'Asparagus Fern / 文竹 / Green',+ colors: generateColors('green', 9),+ },+ {+ title: '霁 / Jiqing',+ colors: generateColors('jiqing', 9),+ },+ {+ title: 'Cornflower / 矢车菊 / Blue',+ colors: generateColors('blue', 9),+ },+ {+ title: 'Hyacinth / 风信子 / Hyacinth Blue',+ colors: generateColors('hyacinth', 9),+ },+ {+ title: 'Violet / 紫罗兰 / Purple',+ colors: generateColors('purple', 9),+ },+ {+ title: 'Sorrel pulp / 酢浆 / Magenta',+ colors: generateColors('magenta', 9),+ },+ {+ title: '灰 / Grey',+ colors: generateColors('grey', 9),+ },+ {+ title: '黑 / 白 / Black / White',+ colors: ['colorBlack', 'colorWhite'],+ },+ ];++ return (+ <section className={styles.palette}>+ {palettes.map((palette) => (+ <section key={palette.title}>+ <h3>{palette.title}</h3>+ <table>+ <thead>+ <tr>+ <th>name</th>+ <th>value</th>+ <th>CSS variable</th>+ </tr>+ </thead>++ <tbody>+ {palette.colors.map((color) => (+ <tr key={color}>+ <td>+ <div+ style={{+ display: 'flex',+ alignItems: 'center',+ gap: '6px',+ }}+ >+ {theme[color].startsWith('#') && (+ <div+ style={{+ display: 'inline-block',+ width: '16px',+ height: '16px',+ backgroundColor: theme[color],+ }}+ />+ )}+ <code>{color}</code>+ </div>+ </td>+ <td>+ <code>{theme[color]}</code>+ </td>+ <td>+ <code>{convertToCSSVar(color)}</code>+ </td>+ </tr>+ ))}+ </tbody>+ </table>+ </section>+ ))}+ </section>+ );+}+export const Playground: StoryObj = {render: (_, context) => <Palette theme={themes[context.globals.theme]} />,};diff --git a/packages/design/src/components/design-token/Palette.tsx b/packages/design/src/components/design-token/Palette.tsxdeleted file mode 100644index 3097d8d93b..0000000000--- a/packages/design/src/components/design-token/Palette.tsx+++ /dev/null@@ -1,221 +0,0 @@-/**- * Copyright 2023-present DreamNum Inc.- *- * Licensed under the Apache License, Version 2.0 (the "License");- * you may not use this file except in compliance with the License.- * You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing, software- * distributed under the License is distributed on an "AS IS" BASIS,- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.- * See the License for the specific language governing permissions and- * limitations under the License.- */--import React from 'react';--import styles from './index.module.less';--interface IProps {- theme: Record<string, string>;-}--const levelMap = ['50', '100', '200', '300', '400', '500', '600', '700', '800', '900'];--function convertToCSSVar(input: string): string {- const dashCase = input.replace(/([A-Z])/g, (match) => `-${match.toLowerCase()}`).replace(/(\d+)/g, '-$1');-- return `--${dashCase}`;-}--export function Palette(props: IProps) {- const { theme } = props;-- function generateColors(name: string, maxLevel: number) {- const colors = [];- for (let i = 0; i < maxLevel; i++) {- colors.push(`${name}${levelMap[i]}`);- }-- return colors;- }-- const palettes = [- {- title: 'Brand / 品牌',- colors: ['primaryColor', 'primaryColorHover'],- },- {- title: 'Functional / 功能',- colors: ['infoColor', 'successColor', 'warningColor', 'errorColor'],- },- {- title: 'Text Color',- colors: ['textColor', 'textColorSecondary', 'textColorSecondaryDarker', 'textColorTertiary'],- },- {- title: 'Link',- colors: ['linkColor'],- },- {- title: 'Background',- colors: ['bgColor', 'bgColorHover', 'bgColorSecondary'],- },- {- title: 'Font Size',- colors: ['fontSizeXs', 'fontSizeSm', 'fontSizeBase', 'fontSizeLg', 'fontSizeXl', 'fontSizeXxl'],- },- {- title: 'Margin',- colors: ['marginXs', 'marginXxs', 'marginSm', 'marginBase', 'marginLg', 'marginXl'],- },- {- title: 'Padding',- colors: ['paddingXs', 'paddingSm', 'paddingBase', 'paddingLg', 'paddingXl'],- },- {- title: 'Border Color',- colors: ['borderColor'],- },- {- title: 'Scrollbar Color',- colors: ['scrollbarColor', 'scrollbarColorHover', 'scrollbarColorActive'],- },- {- title: 'Border Radius',- colors: ['borderRadiusBase', 'borderRadiusLg', 'borderRadiusXl'],- },- {- title: 'Box Shadow',- colors: ['boxShadowBase', 'boxShadowLg'],- },- {- title: 'Breakpoint',- colors: ['breakpointXs', 'breakpointSm', 'breakpointBase', 'breakpointLg'],- },- {- title: 'Loop Color',- colors: [- 'loopColor1',- 'loopColor2',- 'loopColor3',- 'loopColor4',- 'loopColor5',- 'loopColor6',- 'loopColor7',- 'loopColor8',- 'loopColor9',- 'loopColor10',- 'loopColor11',- 'loopColor12',- ],- },- {- title: 'Ramu / 瑞木 / Red',- colors: generateColors('red', 9),- },- {- title: 'Hemerocallis / 萱草 / Orange',- colors: generateColors('orange', 9),- },- {- title: 'Marigold / 万寿菊 / Gold',- colors: generateColors('gold', 9),- },- {- title: 'Forsythia Suspensa / 连翘 / Yellow',- colors: generateColors('yellow', 9),- },- {- title: 'Eustoma Grandiflorum / 洋桔梗 / Verdancy',- colors: generateColors('verdancy', 9),- },- {- title: 'Asparagus Fern / 文竹 / Green',- colors: generateColors('green', 9),- },- {- title: '霁 / Jiqing',- colors: generateColors('jiqing', 9),- },- {- title: 'Cornflower / 矢车菊 / Blue',- colors: generateColors('blue', 9),- },- {- title: 'Hyacinth / 风信子 / Hyacinth Blue',- colors: generateColors('hyacinth', 9),- },- {- title: 'Violet / 紫罗兰 / Purple',- colors: generateColors('purple', 9),- },- {- title: 'Sorrel pulp / 酢浆 / Magenta',- colors: generateColors('magenta', 9),- },- {- title: '灰 / Grey',- colors: generateColors('grey', 9),- },- {- title: '黑 / 白 / Black / White',- colors: ['colorBlack', 'colorWhite'],- },- ];-- return (- <section className={styles.palette}>- {palettes.map((palette) => (- <section key={palette.title}>- <h3>{palette.title}</h3>- <table>- <thead>- <tr>- <th>name</th>- <th>value</th>- <th>CSS variable</th>- </tr>- </thead>-- <tbody>- {palette.colors.map((color) => (- <tr key={color}>- <td>- <div- style={{- display: 'flex',- alignItems: 'center',- gap: '6px',- }}- >- {theme[color].startsWith('#') && (- <div- style={{- display: 'inline-block',- width: '16px',- height: '16px',- backgroundColor: theme[color],- }}- />- )}- <code>{color}</code>- </div>- </td>- <td>- <code>{theme[color]}</code>- </td>- <td>- <code>{convertToCSSVar(color)}</code>- </td>- </tr>- ))}- </tbody>- </table>- </section>- ))}- </section>- );-}diff --git a/packages/design/src/components/input/__tests__/Input.spec.tsx b/packages/design/src/components/input/__tests__/Input.spec.tsxnew file mode 100644index 0000000000..b0dd44df6e--- /dev/null+++ b/packages/design/src/components/input/__tests__/Input.spec.tsx@@ -0,0 +1,72 @@+/**+ * Copyright 2023-present DreamNum Inc.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import { afterEach, describe, expect, it } from 'vitest';+import React from 'react';+import { cleanup, fireEvent, render } from '@testing-library/react';+import { Input } from '../Input';++describe('Input', () => {+ afterEach(cleanup);++ it('renders correctly', () => {+ const { container } = render(<Input />);++ expect(container);+ });++ it('renders the placeholder', () => {+ const { getByPlaceholderText } = render(<Input placeholder="Test" />);+ const inputElement = getByPlaceholderText('Test');++ expect(inputElement).not.toBeNull();+ });++ it('renders the value', () => {+ const { getByDisplayValue } = render(<Input value="Test" />);+ const inputElement = getByDisplayValue('Test');++ expect(inputElement).not.toBeNull();+ });++ it('renders the disabled', () => {+ const { container } = render(<Input disabled />);++ expect(container.querySelector('input')?.disabled).toBeTruthy();+ });++ it('renders the size', () => {+ const { container } = render(<Input size="large" />);++ expect(container.innerHTML).contains('inputAffixWrapperLarge');+ });++ it('renders the clearable', () => {+ const { container } = render(<Input allowClear />);++ expect(container.innerHTML).contains('input-clear-icon');+ });++ it('change the value', () => {+ const { container } = render(<Input />);++ const inputElement = container.querySelector('input')!;++ fireEvent.change(inputElement, { target: { value: 'Test' } });++ expect(inputElement.value).toBe('Test');+ });+});diff --git a/packages/design/src/components/container/__tests__/index.spec.tsx b/packages/design/src/components/input/__tests__/InputWithSlot.spec.tsxsimilarity index 62%rename from packages/design/src/components/container/__tests__/index.spec.tsxrename to packages/design/src/components/input/__tests__/InputWithSlot.spec.tsxindex 7a7679cfe1..7d5c50811a 100644--- a/packages/design/src/components/container/__tests__/index.spec.tsx+++ b/packages/design/src/components/input/__tests__/InputWithSlot.spec.tsx@@ -14,16 +14,17 @@* limitations under the License.*/-import { render } from '@testing-library/react';+import { afterEach, describe, expect, it } from 'vitest';import React from 'react';-import { describe, expect, it } from 'vitest';+import { cleanup, render } from '@testing-library/react';+import { InputWithSlot } from '../InputWithSlot';-import { Container } from '../Container';+describe('InputWithSlot', () => {+ afterEach(cleanup);-describe('Container', () => {- it('should display initial Container', () => {- const { container } = render(<Container>container content Text</Container>);+ it('renders correctly', () => {+ const { container } = render(<InputWithSlot slot="prefix" />);- expect(container.textContent).toMatch('container content Text');+ expect(container.innerHTML).toContain('prefix');});});diff --git a/packages/design/src/components/switch/__tests__/index.spec.tsx b/packages/design/src/components/switch/__tests__/index.spec.tsxnew file mode 100644index 0000000000..06355284e9--- /dev/null+++ b/packages/design/src/components/switch/__tests__/index.spec.tsx@@ -0,0 +1,48 @@+/**+ * Copyright 2023-present DreamNum Inc.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import { afterEach, describe, expect, it } from 'vitest';+import { cleanup, render } from '@testing-library/react';+import React from 'react';++import { Switch } from '../Switch';++describe('Switch', () => {+ afterEach(cleanup);++ it('renders correctly', () => {+ const { container } = render(<Switch />);+ expect(container);+ });++ it('renders the checked', () => {+ const { container } = render(<Switch defaultChecked />);++ const checkboxElement = container.querySelector('[type="checkbox"]')! as HTMLInputElement;++ expect(checkboxElement.checked).toBeTruthy();+ });++ it('change the checked', () => {+ const { container } = render(<Switch defaultChecked />);++ const checkboxElement = container.querySelector('[type="checkbox"]')! as HTMLInputElement;++ checkboxElement.click();++ expect(checkboxElement.checked).toBeFalsy();+ });+});diff --git a/packages/design/src/components/textarea/__tests__/index.spec.tsx b/packages/design/src/components/textarea/__tests__/index.spec.tsxnew file mode 100644index 0000000000..9b931dc2bc--- /dev/null+++ b/packages/design/src/components/textarea/__tests__/index.spec.tsx@@ -0,0 +1,40 @@+/**+ * Copyright 2023-present DreamNum Inc.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import { afterEach, describe, expect, it } from 'vitest';+import React from 'react';+import { cleanup, fireEvent, render } from '@testing-library/react';+import { Textarea } from '../Textarea';++describe('Textarea', () => {+ afterEach(cleanup);++ it('renders correctly', () => {+ const { container } = render(<Textarea />);++ expect(container).toBeTruthy();+ });++ it('change the value', () => {+ const { container } = render(<Textarea />);++ const inputElement = container.querySelector('textarea')!;++ fireEvent.change(inputElement, { target: { value: 'Test' } });++ expect(inputElement.value).toBe('Test');+ });+});diff --git a/packages/design/src/index.ts b/packages/design/src/index.tsindex 7a8d389a6c..6d973320d0 100644--- a/packages/design/src/index.ts+++ b/packages/design/src/index.ts@@ -37,7 +37,6 @@ export { CheckboxGroup, type ICheckboxGroupProps } from './components/checkbox-gexport { ColorPicker, type IColorPickerProps } from './components/color-picker';export { ConfigContext, ConfigProvider, type IConfigProviderProps } from './components/config-provider';export { Confirm, type IConfirmProps } from './components/confirm';-export { Container, type IContainerProps } from './components/container';export { DatePicker, type IDatePickerProps, DatePanel, type IDatePanelProps } from './components/date-picker';export { Dialog, type IDialogProps } from './components/dialog';export { Dropdown, type IDropdownProps } from './components/dropdown';diff --git a/packages/design/src/locale/en-US.ts b/packages/design/src/locale/en-US.tsindex 39628ffec9..fe8b3d903a 100644--- a/packages/design/src/locale/en-US.ts+++ b/packages/design/src/locale/en-US.ts@@ -31,6 +31,9 @@ const locale: ILocale = {...dajsEnUS,...PickerEnUs,},+ CascaderList: {+ empty: 'None',+ },},};diff --git a/packages/design/src/locale/interface.ts b/packages/design/src/locale/interface.tsindex 4015e43d34..01858ededd 100644--- a/packages/design/src/locale/interface.ts+++ b/packages/design/src/locale/interface.ts@@ -21,5 +21,6 @@ export interface ILocale {Confirm: Record<string, any>;Slider: Record<string, any>;Picker: typeof PickerZhCN;+ CascaderList: Record<string, any>;};}diff --git a/packages/design/src/locale/ru-RU.ts b/packages/design/src/locale/ru-RU.tsindex 4394a395de..4074f9285d 100644--- a/packages/design/src/locale/ru-RU.ts+++ b/packages/design/src/locale/ru-RU.ts@@ -31,6 +31,9 @@ const locale: ILocale = {...dajsRuRU,...PickerRuRU,},+ CascaderList: {+ empty: 'Нет',+ },},};diff --git a/packages/design/src/locale/zh-CN.ts b/packages/design/src/locale/zh-CN.tsindex 198f78dc81..25e7446119 100644--- a/packages/design/src/locale/zh-CN.ts+++ b/packages/design/src/locale/zh-CN.ts@@ -31,6 +31,9 @@ const locale: ILocale = {...dajsZhCN,...PickerZhCN,},+ CascaderList: {+ empty: '无',+ },},};