admin/lib/visualViewportKeyboardInset.test.ts
alisaza e1eaf5eff5 feat: initial ghabilee-admin backoffice app
Extract admin dashboard from ghabilee-frontend2 into a dedicated Next.js
app for backoffice.ghabilee.ir (no SEO indexing / Clarity).
2026-09-05 13:12:59 +03:30

22 lines
720 B
TypeScript

import { describe, expect, it } from 'vitest'
import { computeKeyboardInset } from '@/lib/visualViewportKeyboardInset'
describe('computeKeyboardInset', () => {
it('returns 0 when visual viewport matches the layout viewport', () => {
expect(computeKeyboardInset(800, 800, 0)).toBe(0)
})
it('ignores small chrome/zoom deltas below the keyboard threshold', () => {
expect(computeKeyboardInset(800, 760, 0)).toBe(0)
})
it('returns the occluded height when a keyboard-sized inset appears', () => {
expect(computeKeyboardInset(800, 480, 0)).toBe(320)
})
it('subtracts visualViewport.offsetTop (iOS scroll-while-focused)', () => {
expect(computeKeyboardInset(800, 480, 40)).toBe(280)
})
})