Skip to content

Commit

Permalink
fix: test case fix
Browse files Browse the repository at this point in the history
  • Loading branch information
TinaPeach committed Dec 26, 2023
1 parent 7f1f878 commit 03a84c3
Show file tree
Hide file tree
Showing 5 changed files with 323 additions and 221 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ describe('ImagePreview', () => {
expect(onImageDoubleClick.mock.calls).toHaveLength(1);
});

it('should support thumb bounds', () => {
it('should support thumb bounds', async () => {
const props = {
staticLabel: true,
images: [
Expand Down Expand Up @@ -152,6 +152,24 @@ describe('ImagePreview', () => {
});
pureDelay(1000);
expect(document.querySelectorAll('.image-preview-fake-rect')).toHaveLength(0);
loadImage(document.querySelector(`.${imagePrefix}`), {
top: 0,
bottom: 700,
left: 0,
right: 375,
width: 375,
height: 700,
});
expect(document.querySelector(`.${prefix}`)).not.toBeNull();
fireEvent.click(document.querySelector('.image-container img'));
pureDelay(300);
expect(document.querySelector('.closing-animation')).not.toBeNull();
await waitFor(
() => {
expect(document.querySelector(`.${prefix}`)).toBeNull();
},
{ timeout: 1000 },
);
});

it('should support touch event correctly', () => {
Expand Down Expand Up @@ -197,14 +215,18 @@ describe('ImagePreview', () => {

it('should support `ImagePreview.open`', async () => {
const onClose = jest.fn();
window.instance = ImagePreview.open({ staticLabel: true, onClose, images: demoImages });
// TODO: ReactDOM.render 不生效,待升级 react 18 版本对应的rtl
// pureDelay(1100);
// expect(document.querySelectorAll(`.${imagePrefix}`)).toHaveLength(2);
window.instance = ImagePreview.open({
staticLabel: true,
onClose,
images: demoImages,
openIndex: 0,
});
pureDelay(1100);
expect(document.querySelectorAll(`.${imagePrefix}`)).toHaveLength(2);
expect(typeof window.instance.close).toBe('function');
expect(typeof window.instance.update).toBe('function');
window.instance.close();
// pureDelay(1100);
// expect(onClose.mock.calls).toHaveLength(1);
pureDelay(1100);
expect(onClose.mock.calls).toHaveLength(1);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ exports[`pagination demo test pagination demo: icon.md renders correctly 1`] = `
<svg
fill="none"
height="14"
viewBox="0 0 8 14"
width="8"
style="overflow: visible;"
viewBox="3 0 2 14"
width="2"
>
<path
clip-rule="evenodd"
Expand Down Expand Up @@ -62,8 +63,9 @@ exports[`pagination demo test pagination demo: icon.md renders correctly 1`] = `
<svg
fill="none"
height="14"
viewBox="0 0 8 14"
width="8"
style="overflow: visible;"
viewBox="3 0 2 14"
width="2"
>
<path
clip-rule="evenodd"
Expand Down Expand Up @@ -96,8 +98,9 @@ exports[`pagination demo test pagination demo: icon2.md renders correctly 1`] =
<svg
fill="none"
height="14"
viewBox="0 0 8 14"
width="8"
style="overflow: visible;"
viewBox="3 0 2 14"
width="2"
>
<path
clip-rule="evenodd"
Expand Down Expand Up @@ -131,8 +134,9 @@ exports[`pagination demo test pagination demo: icon2.md renders correctly 1`] =
<svg
fill="none"
height="14"
viewBox="0 0 8 14"
width="8"
style="overflow: visible;"
viewBox="3 0 2 14"
width="2"
>
<path
clip-rule="evenodd"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ exports[`search-bar demo test search-bar demo: action-btn.md renders correctly 1
/>
</div>
<span
style="margin-left: 16px; color: rgb(22, 93, 255); font-size: 15px;"
class="demo-search-btn"
>
Search
</span>
Expand Down Expand Up @@ -163,13 +163,12 @@ exports[`search-bar demo test search-bar demo: custom-pend.md renders correctly
role="search"
>
<div
style="display: flex; align-items: center; font-size: 14px; margin-right: 10px;"
class="demo-search-pend-wrapper"
>
City
<svg
class="arco-icon arco-icon-arrow-down "
class="arco-icon arco-icon-arrow-down demo-search-pend-icon"
height="1em"
style="margin-left: 5px; font-size: 10px;"
viewBox="0 0 1024 1024"
width="1em"
xmlns="http://www.w3.org/2000/svg"
Expand Down Expand Up @@ -207,8 +206,7 @@ exports[`search-bar demo test search-bar demo: custom-pend.md renders correctly
/>
</div>
<div
class="arco-avatar-wrapper ultra-small circle arco-avatar-wrapper-shape-circle"
style="margin-left: 13px;"
class="arco-avatar-wrapper demo-search-pend-avatar ultra-small circle arco-avatar-wrapper-shape-circle"
>
<div
class="arco-avatar arco-avatar-size-ultra-small ultra-small arco-avatar-shape-circle circle arco-avatar-default-overlap default-overlap"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,86 @@ exports[`slider demo test slider demo: custom-icon.md renders correctly 1`] = `
</DocumentFragment>
`;

exports[`slider demo test slider demo: custom-popover.md renders correctly 1`] = `
<DocumentFragment>
<div
aria-disabled="false"
aria-valuemax="100"
aria-valuemin="0"
aria-valuenow="10"
class="arco-slider is-horizontal show-tooltip"
role="slider"
style="padding-top: 60px;"
>
<div
class="arco-slider-wrapper"
>
<div
class="arco-slider-marks"
/>
<div
class="arco-slider-line"
style="height: 2px;"
>
<div
class="arco-slider-line is-activated is-transferable"
style="height: 2px; left: 0px; width: 0px;"
>
<div
class="arco-slider-thumb-wrapper is-start"
>
<div
class="arco-slider-thumb"
/>
</div>
<div
class="arco-slider-thumb-wrapper is-end"
>
<div
class="arco-popover black-theme follow-mode"
>
<div
class="popover-child-inner"
>
<div
class="arco-slider-thumb"
/>
</div>
<div
class="arco-popover-inner popover-inner all-border-box follow-mode black-theme"
style="min-width: 10px; max-width: 90vw; transform-origin: 0 0;"
>
<div
class="popover-bg"
>
<div
class="popover-arrow topRight"
style="width: 9px; height: 9px;"
>
<div
class="popover-arrow-content"
/>
</div>
</div>
<div
class="popover-content topRight"
>
<div
class="content-text"
>
value: 60
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</DocumentFragment>
`;

exports[`slider demo test slider demo: custom-size.md renders correctly 1`] = `
<DocumentFragment>
<div
Expand Down
Loading

0 comments on commit 03a84c3

Please sign in to comment.