Skip to content

Commit

Permalink
test(CenterPopup): closeIcon
Browse files Browse the repository at this point in the history
  • Loading branch information
guoyunhe committed Apr 17, 2024
1 parent b327bfd commit 5bd18db
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/components/center-popup/tests/center-popup.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import React from 'react'
import { render, screen, testA11y } from 'testing'
import ConfigProvider from '../../config-provider'
import { CenterPopup } from '../center-popup'

describe('center-popup', () => {
test('a11y', async () => {
await testA11y(<CenterPopup visible>foobar</CenterPopup>)
})

describe('closeIcon', () => {
it('default', () => {
const { baseElement } = render(
<CenterPopup visible showCloseButton>
foobar
</CenterPopup>
)
expect(baseElement.querySelector('.antd-mobile-icon')).toBeTruthy()
})

it('custom', () => {
render(
<CenterPopup visible showCloseButton closeIcon='bamboo'>
foobar
</CenterPopup>
)
expect(screen.getByText('bamboo')).toBeVisible()
})

it('context', () => {
render(
<ConfigProvider popup={{ closeIcon: 'little' }}>
<CenterPopup visible showCloseButton>
foobar
</CenterPopup>
</ConfigProvider>
)

expect(screen.getByText('little')).toBeVisible()
})
})
})

0 comments on commit 5bd18db

Please sign in to comment.