优化
This commit is contained in:
@@ -92,6 +92,25 @@ describe('AppLayout', () => {
|
||||
expect(menuButton.attributes('aria-expanded')).toBe('true')
|
||||
})
|
||||
|
||||
it('closes the mobile menu when returning to the desktop breakpoint and removes the listener', async () => {
|
||||
mockViewport(true)
|
||||
const { wrapper } = await mountLayout()
|
||||
const menuButton = wrapper.get('.shell-menu-button')
|
||||
const mediaQuery = vi.mocked(window.matchMedia).mock.results[0]?.value as MediaQueryList
|
||||
const changeHandler = vi.mocked(mediaQuery.addEventListener).mock.calls[0]?.[1] as ((event: MediaQueryListEvent) => void)
|
||||
|
||||
await menuButton.trigger('click')
|
||||
expect(menuButton.attributes('aria-expanded')).toBe('true')
|
||||
|
||||
changeHandler({ matches: false } as MediaQueryListEvent)
|
||||
await wrapper.vm.$nextTick()
|
||||
expect(menuButton.attributes('aria-label')).toBe('收起导航')
|
||||
expect(menuButton.attributes('aria-expanded')).toBe('true')
|
||||
|
||||
wrapper.unmount()
|
||||
expect(mediaQuery.removeEventListener).toHaveBeenCalledWith('change', changeHandler)
|
||||
})
|
||||
|
||||
it('shows the authenticated identity without a role preview switcher', async () => {
|
||||
const { wrapper } = await mountLayout()
|
||||
expect(wrapper.text()).toContain('登录身份:平台管理员(admin)')
|
||||
|
||||
Reference in New Issue
Block a user