mirror of
https://github.com/XiaoDaiGua-Ray/ray-template.git
synced 2026-11-18 00:23:36 +08:00
Share workspace packages between Ray Admin and the interactive docs. BREAKING CHANGE: v6 is a new major line. v5 stays on legacy/v5.
38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
import type { LayoutInst } from 'naive-ui'
|
|
import type { Ref } from 'vue'
|
|
import {
|
|
LAYOUT_CONTENT_REF,
|
|
LAYOUT_SIDER_REF,
|
|
} from '../../apps/admin/src/app-config'
|
|
import { useContentScroll } from '../../apps/admin/src/hooks/template/useContentScroll'
|
|
import { useSiderScroll } from '../../apps/admin/src/hooks/template/useSiderScroll'
|
|
|
|
describe.each([
|
|
[useContentScroll, LAYOUT_CONTENT_REF],
|
|
[useSiderScroll, LAYOUT_SIDER_REF],
|
|
] as const)('layout scrolling', (useScroll, target) => {
|
|
const writable = target as Ref<LayoutInst | null>
|
|
|
|
afterEach(() => {
|
|
writable.value = null
|
|
})
|
|
|
|
it('can be created before mount and follows replacement layout instances', () => {
|
|
writable.value = null
|
|
const scroll = useScroll()
|
|
|
|
expect(() => scroll({ top: 0 })).not.toThrow()
|
|
const first = vi.fn()
|
|
|
|
writable.value = { scrollTo: first } as unknown as LayoutInst
|
|
scroll({ top: 10 })
|
|
expect(first).toHaveBeenCalledWith({ top: 10 })
|
|
const second = vi.fn()
|
|
|
|
writable.value = { scrollTo: second } as unknown as LayoutInst
|
|
scroll(0, 300)
|
|
expect(second).toHaveBeenCalledWith(0, 300)
|
|
expect(first).toHaveBeenCalledTimes(1)
|
|
})
|
|
})
|