42 lines
1.4 KiB
TypeScript
42 lines
1.4 KiB
TypeScript
import { render, screen } from '@testing-library/react'
|
|
import WorkspacePlaceholder from './WorkspacePlaceholder'
|
|
|
|
jest.mock('next-auth/react', () => ({
|
|
useSession: () => ({ data: { user: { name: '本地超级管理员' } } }),
|
|
signOut: jest.fn(),
|
|
}))
|
|
|
|
describe('WorkspacePlaceholder', () => {
|
|
it('清楚标注二级框架状态并提供返回入口', () => {
|
|
render(
|
|
<WorkspacePlaceholder
|
|
title="业务经营"
|
|
description="围绕品牌、新品、创意与转化,组织跨团队经营工作。"
|
|
capabilities={['新品上新', '品牌塑造']}
|
|
accent="#e98722"
|
|
accentSoft="#fff4e7"
|
|
accentText="#9a4d08"
|
|
/>
|
|
)
|
|
|
|
expect(screen.getByRole('heading', { level: 1, name: '业务经营' })).toBeInTheDocument()
|
|
expect(screen.getByText('二级页面框架已建立')).toBeInTheDocument()
|
|
expect(screen.getByRole('link', { name: /返回部门看板/ })).toHaveAttribute('href', '/')
|
|
})
|
|
|
|
it('直接显示小项内容,不重复渲染面包屑', () => {
|
|
render(
|
|
<WorkspacePlaceholder
|
|
title="核心指标"
|
|
description="当前先建立独立二级页面框架。"
|
|
accent="#e73b32"
|
|
accentSoft="#fff0ee"
|
|
accentText="#b4231c"
|
|
/>
|
|
)
|
|
|
|
expect(screen.queryByRole('navigation', { name: '面包屑' })).not.toBeInTheDocument()
|
|
expect(screen.getByRole('heading', { level: 1, name: '核心指标' })).toBeInTheDocument()
|
|
})
|
|
})
|