dify/web/app/components/billing/pricing/__tests__/footer.spec.tsx
Stephen Zhou a84c2d36a3
style: format with vp fmt (#38803)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-07-12 15:57:46 +00:00

70 lines
2.0 KiB
TypeScript

import { render, screen } from '@testing-library/react'
import * as React from 'react'
import Footer from '../footer'
import { CategoryEnum } from '../types'
vi.mock('@/next/link', () => ({
default: ({
children,
href,
className,
target,
}: {
children: React.ReactNode
href: string
className?: string
target?: string
}) => (
<a href={href} className={className} target={target} data-testid="pricing-link">
{children}
</a>
),
}))
describe('Footer', () => {
beforeEach(() => {
vi.clearAllMocks()
})
describe('Rendering', () => {
it('should render tax tips and comparison link when in cloud category', () => {
render(
<Footer
pricingPageURL="https://dify.ai/pricing#plans-and-features"
currentCategory={CategoryEnum.CLOUD}
/>,
)
expect(screen.getByText('billing.plansCommon.taxTip')).toBeInTheDocument()
expect(screen.getByText('billing.plansCommon.taxTipSecond')).toBeInTheDocument()
expect(screen.getByTestId('pricing-link')).toHaveAttribute(
'href',
'https://dify.ai/pricing#plans-and-features',
)
expect(screen.getByText('billing.plansCommon.comparePlanAndFeatures')).toBeInTheDocument()
})
})
describe('Props', () => {
it('should hide tax tips when category is self-hosted', () => {
render(
<Footer
pricingPageURL="https://dify.ai/pricing#plans-and-features"
currentCategory={CategoryEnum.SELF}
/>,
)
expect(screen.queryByText('billing.plansCommon.taxTip')).not.toBeInTheDocument()
expect(screen.queryByText('billing.plansCommon.taxTipSecond')).not.toBeInTheDocument()
})
})
describe('Edge Cases', () => {
it('should render link even when pricing URL is empty', () => {
render(<Footer pricingPageURL="" currentCategory={CategoryEnum.CLOUD} />)
expect(screen.getByTestId('pricing-link')).toHaveAttribute('href', '')
})
})
})