✨ 新增回收站审计与八位取件码

This commit is contained in:
orion committed 2026-09-11 16:49:50 +08:00
1 parent 5e71cde60e
commit 6bc1c30797
17 files changed
+6309

No files matched your search

+27
View File
@@ -0,0 +1,27 @@
import assert from 'node:assert/strict'
import test from 'node:test'
const body = { style: { overflow: 'scroll' } }
globalThis.document = { body }
const { lockBodyScroll, unlockBodyScroll } = await import('../src/components/common/scrollLock.ts')
test('restores overflow only after the owning lock is released', () => {
const first = lockBodyScroll()
const second = lockBodyScroll()
unlockBodyScroll(Symbol('unrelated'))
assert.equal(body.style.overflow, 'hidden')
unlockBodyScroll(first)
assert.equal(body.style.overflow, 'hidden')
unlockBodyScroll(second)
assert.equal(body.style.overflow, 'scroll')
})
test('releasing an owner twice cannot unlock another owner', () => {
const first = lockBodyScroll()
const second = lockBodyScroll()
unlockBodyScroll(first)
unlockBodyScroll(first)
assert.equal(body.style.overflow, 'hidden')
unlockBodyScroll(second)
assert.equal(body.style.overflow, 'scroll')
})