Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: imagepreview taro 增加缩放, 优化代码 #2941

Open
wants to merge 4 commits into
base: next
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
test: fixed
xiaoyatong committed Jan 14, 2025
commit 03236a315ff87b52726eb5e6f5630b9e9cbc3aca
16 changes: 6 additions & 10 deletions src/packages/imagepreview/__test__/imagepreview.spec.tsx
Original file line number Diff line number Diff line change
@@ -49,7 +49,6 @@ function sleep(delay = 0): Promise<void> {

test('basic usage test', () => {
const { container } = render(<ImagePreview images={images} visible />)

const element = container.querySelector(
'.nut-imagepreview-pop'
) as HTMLElement
@@ -59,24 +58,22 @@ test('basic usage test', () => {
test('test autoPlay', async () => {
let _container: any
act(() => {
const { container } = render(
<ImagePreview images={images} visible autoPlay={1000} />
)
const { container } = render(<ImagePreview images={images} visible />)
_container = container
})

const element = _container.querySelector(
'.nut-imagepreview-pop .nut-imagepreview-index'
) as HTMLElement
expect(element).toHaveTextContent('1')
expect(element).toHaveTextContent('1/4')

await waitFor(
async () => {
await sleep(1100)
expect(element).toHaveTextContent('2')
await sleep(4600)
expect(element).toHaveTextContent('1/4')
},
{
timeout: 2000,
timeout: 5000,
}
)
})
@@ -100,7 +97,7 @@ test('customize indicator and color', async () => {
const swiperIndicator = container.querySelector('.nut-imagepreview-swiper')
expect(swiperIndicator).toHaveAttribute(
'style',
'--nutui-indicator-color: red;'
'--nutui-indicator-color: red; --nutui-swiper-indicator-bottom: 100px;'
)
})

@@ -142,7 +139,6 @@ test('closeIconPosition', async () => {
closeIconPosition="bottom"
/>
)

const closeIcon = container.querySelector('.nut-imagepreview-close')
expect(closeIcon?.classList).toContain('bottom')
})
Loading