Skip to content

Commit

Permalink
test(useResultIcon): icon
Browse files Browse the repository at this point in the history
  • Loading branch information
guoyunhe committed Apr 17, 2024
1 parent cea8c00 commit c2a2388
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import React from 'react'
import { render, screen } from 'testing'
import Result from '..'
import ConfigProvider from '../../config-provider'
import { useResultIcon } from '../use-result-icon'

const ResultIcon = (props: any) => {
const icon = useResultIcon(props.status)
return <div>{icon}</div>
}

const classPrefix = `adm-result`

describe('ResultIcon', () => {
describe('useResultIcon', () => {
test('renders with success status', () => {
render(<ResultIcon status='success' />)
expect(document.querySelector('.antd-mobile-icon')).toBeTruthy()
Expand All @@ -35,4 +33,12 @@ describe('ResultIcon', () => {
render(<ResultIcon />)
expect(document.querySelector('.antd-mobile-icon')).toBeFalsy()
})
test('renders with context', () => {
render(
<ConfigProvider result={{ successIcon: 'foobar' }}>
<ResultIcon status='success' />
</ConfigProvider>
)
expect(screen.getByTestId('foobar')).toBeTruthy()
})
})

0 comments on commit c2a2388

Please sign in to comment.