Skip to content

Commit 116c8e4

Browse files
committed
test: update snap
1 parent e86492d commit 116c8e4

File tree

23 files changed

+812
-802
lines changed

23 files changed

+812
-802
lines changed

components/anchor/Anchor.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export default defineComponent({
8888
scrollEvent: null,
8989
animating: false,
9090
});
91-
const activeLink = ref();
91+
const activeLink = ref(null);
9292
const getContainer = computed(() => {
9393
const { getContainer } = props;
9494
return getContainer || getTargetContainer.value || getDefaultContainer;
@@ -122,7 +122,7 @@ export default defineComponent({
122122
};
123123
const setCurrentActiveLink = (link: string) => {
124124
const { getCurrentAnchor } = props;
125-
if (activeLink.value !== link) {
125+
if (activeLink.value === link) {
126126
return;
127127
}
128128
activeLink.value = typeof getCurrentAnchor === 'function' ? getCurrentAnchor() : link;

components/avatar/__tests__/Avatar.test.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ describe('Avatar Render', () => {
186186
});
187187
});
188188

189-
it('fallback', async () => {
189+
it('fallback', () => {
190190
const div = global.document.createElement('div');
191191
global.document.body.appendChild(div);
192192
const wrapper = mount(
@@ -201,11 +201,9 @@ describe('Avatar Render', () => {
201201
},
202202
{ attachTo: div },
203203
);
204-
await asyncExpect(async () => {
205-
await wrapper.find('img').trigger('error');
206-
expect(wrapper.html()).toMatchSnapshot();
207-
wrapper.unmount();
208-
global.document.body.removeChild(div);
209-
}, 0);
204+
wrapper.find('img').trigger('error');
205+
expect(wrapper.html()).toMatchSnapshot();
206+
wrapper.unmount();
207+
global.document.body.removeChild(div);
210208
});
211209
});

components/avatar/__tests__/__snapshots__/Avatar.test.js.snap

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`Avatar Render adjusts component size to 24 when window size is xs 1`] = `<span class="ant-avatar" style="width: 24px; height: 24px; line-height: 24px; font-size: 18px;"><span class="ant-avatar-string" style="transform: scale(0.32) translateX(-50%);"><!----></span></span>`;
3+
exports[`Avatar Render adjusts component size to 24 when window size is xs 1`] = `<span class="ant-avatar ant-avatar-circle" style="width: 24px; height: 24px; line-height: 24px; font-size: 18px;"><span class="ant-avatar-string" style="transform: scale(0.32) translateX(-50%);"><!----></span></span>`;
44

5-
exports[`Avatar Render adjusts component size to 32 when window size is sm 1`] = `<span class="ant-avatar" style="width: 32px; height: 32px; line-height: 32px; font-size: 18px;"><span class="ant-avatar-string" style="transform: scale(0.32) translateX(-50%);"><!----></span></span>`;
5+
exports[`Avatar Render adjusts component size to 32 when window size is sm 1`] = `<span class="ant-avatar ant-avatar-circle" style="width: 32px; height: 32px; line-height: 32px; font-size: 18px;"><span class="ant-avatar-string" style="transform: scale(0.32) translateX(-50%);"><!----></span></span>`;
66

7-
exports[`Avatar Render adjusts component size to 40 when window size is md 1`] = `<span class="ant-avatar" style="width: 40px; height: 40px; line-height: 40px; font-size: 18px;"><span class="ant-avatar-string" style="transform: scale(0.32) translateX(-50%);"><!----></span></span>`;
7+
exports[`Avatar Render adjusts component size to 40 when window size is md 1`] = `<span class="ant-avatar ant-avatar-circle" style="width: 40px; height: 40px; line-height: 40px; font-size: 18px;"><span class="ant-avatar-string" style="transform: scale(0.32) translateX(-50%);"><!----></span></span>`;
88

9-
exports[`Avatar Render adjusts component size to 64 when window size is lg 1`] = `<span class="ant-avatar" style="width: 64px; height: 64px; line-height: 64px; font-size: 18px;"><span class="ant-avatar-string" style="transform: scale(0.32) translateX(-50%);"><!----></span></span>`;
9+
exports[`Avatar Render adjusts component size to 64 when window size is lg 1`] = `<span class="ant-avatar ant-avatar-circle" style="width: 64px; height: 64px; line-height: 64px; font-size: 18px;"><span class="ant-avatar-string" style="transform: scale(0.32) translateX(-50%);"><!----></span></span>`;
1010

11-
exports[`Avatar Render adjusts component size to 80 when window size is xl 1`] = `<span class="ant-avatar" style="width: 80px; height: 80px; line-height: 80px; font-size: 18px;"><span class="ant-avatar-string" style="transform: scale(0.32) translateX(-50%);"><!----></span></span>`;
11+
exports[`Avatar Render adjusts component size to 80 when window size is xl 1`] = `<span class="ant-avatar ant-avatar-circle" style="width: 80px; height: 80px; line-height: 80px; font-size: 18px;"><span class="ant-avatar-string" style="transform: scale(0.32) translateX(-50%);"><!----></span></span>`;
1212

13-
exports[`Avatar Render adjusts component size to 100 when window size is xxl 1`] = `<span class="ant-avatar" style="width: 100px; height: 100px; line-height: 100px; font-size: 18px;"><span class="ant-avatar-string" style="transform: scale(0.32) translateX(-50%);"><!----></span></span>`;
13+
exports[`Avatar Render adjusts component size to 100 when window size is xxl 1`] = `<span class="ant-avatar ant-avatar-circle" style="width: 100px; height: 100px; line-height: 100px; font-size: 18px;"><span class="ant-avatar-string" style="transform: scale(0.32) translateX(-50%);"><!----></span></span>`;
1414

15-
exports[`Avatar Render fallback 1`] = `<span class="ant-avatar ant-avatar-circle"><span class="ant-avatar-string" style="transform: scale(0.32) translateX(-50%);">A</span></span>`;
15+
exports[`Avatar Render fallback 1`] = `<span class="ant-avatar ant-avatar-circle ant-avatar-image"><img draggable="false" src="http://error.url"></span>`;
1616
1717
exports[`Avatar Render should calculate scale of avatar children correctly 1`] = `
1818
DOMWrapper {
@@ -40,4 +40,4 @@ DOMWrapper {
4040
}
4141
`;
4242
43-
exports[`Avatar Render should calculate scale of avatar children correctly with gap 1`] = `<span class="ant-avatar"><span class="ant-avatar-string" style="transform: scale(0.36) translateX(-50%);">Avatar</span></span>`;
43+
exports[`Avatar Render should calculate scale of avatar children correctly with gap 1`] = `<span class="ant-avatar ant-avatar-circle"><span class="ant-avatar-string" style="transform: scale(0.36) translateX(-50%);">Avatar</span></span>`;

components/back-top/__tests__/index.test.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,19 @@ describe('BackTop', () => {
88
props: {
99
visibilityHeight: -1,
1010
},
11+
attachTo: 'body',
1112
});
1213
const scrollToSpy = jest.spyOn(window, 'scrollTo').mockImplementation((x, y) => {
1314
window.scrollY = y;
1415
window.pageYOffset = y;
16+
document.documentElement.scrollTop = y;
1517
});
1618
window.scrollTo(0, 400);
17-
// trigger scroll manually
18-
wrapper.vm.handleScroll();
19-
await sleep();
19+
expect(document.documentElement.scrollTop).toBe(400);
20+
await sleep(10);
2021
wrapper.find('.ant-back-top').trigger('click');
2122
await sleep(500);
22-
expect(window.pageYOffset).toBe(0);
23+
expect(document.documentElement.scrollTop).toBe(0);
2324
scrollToSpy.mockRestore();
2425
});
2526
it('support onClick', async () => {
@@ -29,15 +30,15 @@ describe('BackTop', () => {
2930
visibilityHeight: -1,
3031
onClick,
3132
},
33+
attachTo: 'body',
3234
});
3335
const scrollToSpy = jest.spyOn(window, 'scrollTo').mockImplementation((x, y) => {
3436
window.scrollY = y;
3537
window.pageYOffset = y;
3638
});
39+
document.dispatchEvent(new Event('scroll'));
3740
window.scrollTo(0, 400);
38-
// trigger scroll manually
39-
wrapper.vm.handleScroll();
40-
await sleep();
41+
await sleep(10);
4142
wrapper.find('.ant-back-top').trigger('click');
4243
expect(onClick).toHaveBeenCalled();
4344
scrollToSpy.mockRestore();

components/badge/Badge.tsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,16 @@ export default defineComponent({
157157
visible || !text ? null : <span class={`${pre}-status-text`}>{text}</span>;
158158

159159
// >>> Display Component
160-
const displayNode = cloneElement(
161-
slots.count?.(),
162-
{
163-
style: mergedStyle,
164-
},
165-
false,
166-
);
160+
const displayNode =
161+
typeof count === 'object' || (count === undefined && slots.count)
162+
? cloneElement(
163+
count ?? slots.count?.(),
164+
{
165+
style: mergedStyle,
166+
},
167+
false,
168+
)
169+
: null;
167170

168171
const badgeClassName = classNames(
169172
pre,

0 commit comments

Comments
 (0)