dify/web/app/components/billing/annotation-full/index.spec.tsx
Stephen Zhou eabdc5f0eb
refactor(web): migrate to Vitest and esm (#29974)
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: yyh <yuanyouhuilyz@gmail.com>
2025-12-22 16:35:22 +08:00

60 lines
1.4 KiB
TypeScript

import { render, screen } from '@testing-library/react'
import AnnotationFull from './index'
vi.mock('./usage', () => ({
__esModule: true,
default: (props: { className?: string }) => {
return (
<div data-testid='usage-component' data-classname={props.className ?? ''}>
usage
</div>
)
},
}))
vi.mock('../upgrade-btn', () => ({
__esModule: true,
default: (props: { loc?: string }) => {
return (
<button type='button' data-testid='upgrade-btn'>
{props.loc}
</button>
)
},
}))
describe('AnnotationFull', () => {
beforeEach(() => {
vi.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()
})
})
})