mirror of
https://github.com/langgenius/dify.git
synced 2026-06-17 23:21:12 +08:00
Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: yyh <yuanyouhuilyz@gmail.com> Co-authored-by: Joel <iamjoel007@gmail.com> Co-authored-by: hjlarry <hjlarry@163.com> Co-authored-by: fatelei <fatelei@gmail.com> Co-authored-by: Asuka Minato <i@asukaminato.eu.org> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Xiyuan Chen <52963600+GareArc@users.noreply.github.com> Co-authored-by: gigglewang <gigglewang@dify.ai> Co-authored-by: Yunlu Wen <yunlu.wen@dify.ai> Co-authored-by: chariri <w@chariri.moe> Co-authored-by: Evan <2869018789@qq.com> Co-authored-by: yyh <92089059+lyzno1@users.noreply.github.com>
38 lines
1.3 KiB
TypeScript
38 lines
1.3 KiB
TypeScript
import type { ReactNode } from 'react'
|
|
import { render, screen } from '@testing-library/react'
|
|
import MainNavLayout from '../layout'
|
|
|
|
vi.mock('@/app/components/header', () => ({
|
|
default: () => <div data-testid="desktop-header">Header</div>,
|
|
}))
|
|
|
|
vi.mock('@/app/components/header/header-wrapper', () => ({
|
|
default: ({ children }: { children: ReactNode }) => <div data-testid="header-wrapper">{children}</div>,
|
|
}))
|
|
|
|
vi.mock('../index', () => ({
|
|
default: ({ className }: { className?: string }) => <aside className={className} data-testid="main-nav">MainNav</aside>,
|
|
}))
|
|
|
|
describe('MainNavLayout', () => {
|
|
beforeEach(() => {
|
|
localStorage.clear()
|
|
})
|
|
|
|
it('renders desktop main nav instead of the desktop header', () => {
|
|
render(<MainNavLayout><div>content</div></MainNavLayout>)
|
|
|
|
expect(screen.getByTestId('main-nav')).toBeInTheDocument()
|
|
expect(screen.queryByTestId('desktop-header')).not.toBeInTheDocument()
|
|
expect(screen.getByText('content')).toBeInTheDocument()
|
|
})
|
|
|
|
it('uses the main nav without the desktop header wrapper', () => {
|
|
render(<MainNavLayout><div>content</div></MainNavLayout>)
|
|
|
|
expect(screen.getByTestId('main-nav')).toBeInTheDocument()
|
|
expect(screen.queryByTestId('header-wrapper')).not.toBeInTheDocument()
|
|
expect(screen.queryByTestId('desktop-header')).not.toBeInTheDocument()
|
|
})
|
|
})
|