mirror of
https://github.com/langgenius/dify.git
synced 2026-04-22 07:46:31 +08:00
47 lines
1.8 KiB
TypeScript
47 lines
1.8 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', '')
|
|
})
|
|
})
|
|
})
|