Skip to content

Commit e86492d

Browse files
committed
test: update page-header test
1 parent edcc8b7 commit e86492d

File tree

5 files changed

+26
-11
lines changed

5 files changed

+26
-11
lines changed

components/_util/props-util/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,10 @@ export function isFragment(c) {
333333
return c.length === 1 && c[0].type === Fragment;
334334
}
335335

336+
export function isEmptyContent(c) {
337+
return c === undefined || c === null || c === '' || (Array.isArray(c) && c.length === 0);
338+
}
339+
336340
export function isEmptyElement(c) {
337341
return (
338342
c.type === Comment ||

components/page-header/__tests__/__snapshots__/index.test.js.snap

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,20 @@ exports[`PageHeader pageHeader should support class 1`] = `
1919
<div
2020
class="ant-page-header-heading"
2121
>
22-
<!---->
23-
<!---->
24-
<span
25-
class="ant-page-header-heading-title"
22+
<div
23+
class="ant-page-header-heading-left"
2624
>
27-
Page Title
28-
</span>
29-
<!---->
30-
<!---->
25+
<!---->
26+
<!---->
27+
<span
28+
class="ant-page-header-heading-title"
29+
title="Page Title"
30+
>
31+
Page Title
32+
</span>
33+
<!---->
34+
<!---->
35+
</div>
3136
<!---->
3237
</div>
3338
<!---->

components/page-header/index.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { defineComponent, ExtractPropTypes, ref, computed } from 'vue';
22
import PropTypes from '../_util/vue-types';
3-
import { flattenChildren } from '../_util/props-util';
3+
import { filterEmpty, flattenChildren, isEmptyContent } from '../_util/props-util';
44
import ArrowLeftOutlined from '@ant-design/icons-vue/ArrowLeftOutlined';
55
import ArrowRightOutlined from '@ant-design/icons-vue/ArrowRightOutlined';
66
import Breadcrumb from '../breadcrumb';
@@ -39,7 +39,7 @@ const PageHeader = defineComponent({
3939
const onResize = ({ width }: { width: number }) => {
4040
compact.value = width < 768;
4141
};
42-
const ghost = computed(() => props.ghost ?? pageHeader.value?.ghost ?? false);
42+
const ghost = computed(() => props.ghost ?? pageHeader.value?.ghost ?? true);
4343

4444
const getBackIcon = () => {
4545
return (
@@ -123,7 +123,10 @@ const PageHeader = defineComponent({
123123
};
124124

125125
const renderFooter = () => {
126-
return <div class={`${prefixCls.value}-footer`}>{props.footer ?? slots.footer?.()}</div>;
126+
const footer = props.footer ?? filterEmpty(slots.footer?.());
127+
return isEmptyContent(footer) ? null : (
128+
<div class={`${prefixCls.value}-footer`}>{footer}</div>
129+
);
127130
};
128131

129132
const renderChildren = (children: any) => {

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@
160160
"querystring": "^0.2.0",
161161
"raw-loader": "^4.0.2",
162162
"reqwest": "^2.0.5",
163+
"resize-observer-polyfill": "^1.5.1",
163164
"rimraf": "^3.0.0",
164165
"rucksack-css": "^1.0.2",
165166
"selenium-server": "^3.0.1",

tests/setup.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ if (typeof window !== 'undefined') {
2323
}
2424
}
2525

26+
global.ResizeObserver = require('resize-observer-polyfill');
27+
2628
// The built-in requestAnimationFrame and cancelAnimationFrame not working with jest.runFakeTimes()
2729
// https://github.com/facebook/jest/issues/5147
2830
global.requestAnimationFrame = function(cb) {

0 commit comments

Comments
 (0)