Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ exports[`test BlockHeader render should render BlockHeader success render 1`] =
<div>
<div
class="dtc-block-header"
style="margin-bottom: 16px;"
>
<div
class="dtc-block-header__title dtc-block-header__title--middle dtc-block-header__title--background"
Expand Down Expand Up @@ -35,7 +34,6 @@ exports[`test BlockHeader render should render BlockHeader success render 1`] =
"container": <div>
<div
class="dtc-block-header"
style="margin-bottom: 16px;"
>
<div
class="dtc-block-header__title dtc-block-header__title--middle dtc-block-header__title--background"
Expand Down
12 changes: 6 additions & 6 deletions src/blockHeader/__tests__/blockHeader.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
test('should render BlockHeader props default in BlockHeader', () => {
const { container } = render(<BlockHeader title="测试" background />);
const wrap = container.firstChild;
expect(wrap!.firstChild!.firstChild!.firstChild).toHaveClass('title__addon-before');

Check warning on line 47 in src/blockHeader/__tests__/blockHeader.test.tsx

View workflow job for this annotation

GitHub Actions / setup

Forbidden non-null assertion

Check warning on line 47 in src/blockHeader/__tests__/blockHeader.test.tsx

View workflow job for this annotation

GitHub Actions / setup

Forbidden non-null assertion

Check warning on line 47 in src/blockHeader/__tests__/blockHeader.test.tsx

View workflow job for this annotation

GitHub Actions / setup

Forbidden non-null assertion
fireEvent.click(document.getElementsByClassName(`${prefixCls}__title`)[0]);
});
test('should render BlockHeader test click event', () => {
Expand Down Expand Up @@ -88,7 +88,7 @@
const { container, getByText } = render(<BlockHeader {...props2} />);
const wrap = container.firstChild;
expect(wrap).toHaveClass(`${prefixCls} test__className`);
expect(wrap).toHaveStyle({ height: '100px', marginBottom: '16px' });
expect(wrap).toHaveStyle({ height: '100px' });
expect(getByText('标题2')).toHaveClass('title__text');
expect(getByText('说明文字')).toHaveClass('title__description');
expect(getByText('Icon')).toBeTruthy();
Expand All @@ -97,11 +97,11 @@
const props = { title: '测试1', background: false };
const { container } = render(<BlockHeader {...props} />);
const wrap = container.firstChild;
expect(wrap!.firstChild).not.toHaveClass(`dtc-block-header__title--background`);

Check warning on line 100 in src/blockHeader/__tests__/blockHeader.test.tsx

View workflow job for this annotation

GitHub Actions / setup

Forbidden non-null assertion
});
test('should render BlockHeader className when size is small', () => {
const { container, getByText } = render(<BlockHeader {...props2} />);
const wrap = container.firstChild!;

Check warning on line 104 in src/blockHeader/__tests__/blockHeader.test.tsx

View workflow job for this annotation

GitHub Actions / setup

Forbidden non-null assertion
expect(wrap).toHaveClass(`${prefixCls} test__className`);
expect(wrap.firstChild).toHaveClass(
`dtc-block-header__title dtc-block-header__title--small dtc-block-header__title--background`
Expand All @@ -113,14 +113,14 @@

test('should render BlockHeader tooltip success', () => {
const { container } = render(<BlockHeader {...props3} />);
const wrap = container.firstChild!;

Check warning on line 116 in src/blockHeader/__tests__/blockHeader.test.tsx

View workflow job for this annotation

GitHub Actions / setup

Forbidden non-null assertion
const tooltipWrap = wrap.firstChild!.firstChild!.lastChild;

Check warning on line 117 in src/blockHeader/__tests__/blockHeader.test.tsx

View workflow job for this annotation

GitHub Actions / setup

Forbidden non-null assertion

Check warning on line 117 in src/blockHeader/__tests__/blockHeader.test.tsx

View workflow job for this annotation

GitHub Actions / setup

Forbidden non-null assertion
expect(tooltipWrap!.firstChild).toHaveAttribute('data-mock-icon', 'QuestionOutlined');

Check warning on line 118 in src/blockHeader/__tests__/blockHeader.test.tsx

View workflow job for this annotation

GitHub Actions / setup

Forbidden non-null assertion
});

test('should render BlockHeader description success', () => {
const { container } = render(<BlockHeader {...props4} />);
const wrap = container.firstChild!;

Check warning on line 123 in src/blockHeader/__tests__/blockHeader.test.tsx

View workflow job for this annotation

GitHub Actions / setup

Forbidden non-null assertion
const description = wrap.firstChild!.firstChild!.lastChild;
expect(description).toHaveTextContent('说明文字');
});
Expand All @@ -138,12 +138,12 @@
});

test('should render BlockHeader correct margin-bottom', () => {
const { container: haveStyle } = render(<BlockHeader title="分类级别" addonBefore="" />);
expect(haveStyle.querySelector('.dtc-block-header')).toHaveAttribute('style');
const { container: defaultBottom } = render(
<BlockHeader title="分类级别" addonBefore="" />
const { container: noStyle } = render(<BlockHeader title="分类级别" addonBefore="" />);
expect(noStyle.querySelector('.dtc-block-header')).not.toHaveAttribute('style');
const { container: hasBottom } = render(
<BlockHeader title="分类级别" addonBefore="" spaceBottom={16} />
);
expect(defaultBottom.querySelector('.dtc-block-header')).toHaveStyle({ marginBottom: 16 });
expect(hasBottom.querySelector('.dtc-block-header')).toHaveStyle({ marginBottom: 16 });
const { container: customizeBottom } = render(
<BlockHeader title="分类级别" addonBefore="" spaceBottom={10} />
);
Expand Down
2 changes: 1 addition & 1 deletion src/blockHeader/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ demo:
| background | 是否显示背景 | `boolean` | `true` |
| defaultExpand | 是否默认展开内容 | `boolean` | `-` |
| expand | 当前展开状态 | `boolean` | |
| spaceBottom | 自定义下边距,优先级高于 hasBottom | `number` | `16` |
| spaceBottom | 自定义下边距,优先级高于 hasBottom | `number` | `0` |
| children | 展开/收起的内容 | `React.ReactNode` | - |
| onExpand | 展开/收起时的回调 | `(expand: boolean) => void` | - |
2 changes: 1 addition & 1 deletion src/blockHeader/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const BlockHeader: React.FC<IBlockHeaderProps> = function (props) {
description = '',
tooltip,
size = 'middle',
spaceBottom = 16,
spaceBottom = 0,
className = '',
contentClassName = '',
style = {},
Expand Down
Loading