Files
dify/web/app/components/billing/annotation-full/index.spec.tsx
yyh 9812dc2cb2 chore: add some jest tests (#29800)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-12-18 10:00:11 +08:00

60 lines
1.4 KiB
TypeScript

import { render, screen } from '@testing-library/react'
import AnnotationFull from './index'
jest.mock('./usage', () => ({
__esModule: true,
default: (props: { className?: string }) => {
return (
<div data-testid='usage-component' data-classname={props.className ?? ''}>
usage
</div>
)
},
}))
jest.mock('../upgrade-btn', () => ({
__esModule: true,
default: (props: { loc?: string }) => {
return (
<button type='button' data-testid='upgrade-btn'>
{props.loc}
</button>
)
},
}))
describe('AnnotationFull', () => {
beforeEach(() => {
jest.clearAllMocks()
})
// Rendering marketing copy with action button
describe('Rendering', () => {
it('should render tips when rendered', () => {
// Act
render(<AnnotationFull />)
// Assert
expect(screen.getByText('billing.annotatedResponse.fullTipLine1')).toBeInTheDocument()
expect(screen.getByText('billing.annotatedResponse.fullTipLine2')).toBeInTheDocument()
})
it('should render upgrade button when rendered', () => {
// Act
render(<AnnotationFull />)
// Assert
expect(screen.getByTestId('upgrade-btn')).toBeInTheDocument()
})
it('should render Usage component when rendered', () => {
// Act
render(<AnnotationFull />)
// Assert
const usageComponent = screen.getByTestId('usage-component')
expect(usageComponent).toBeInTheDocument()
})
})
})