Skip to content
Source
Sign inSign up
Open History to see the last commit

menu-placement.test.ts

27 lines962 Bytes

1import { describe, expect, it } from "vite-plus/test";
2​
3import { deriveMenuVerticalPlacement } from "./menu-placement";
4​
5const base = { gap: 6, margin: 12, minHeight: 110 };
6​
7describe("deriveMenuVerticalPlacement", () => {
8 it.each([
9 {
10 name: "anchor taller than the keyboard-free area stays on screen",
11 input: { anchorY: -100, anchorHeight: 1000, overlayHeight: 800, keyboardInset: 300 },
12 expected: { maxHeight: 476, top: 12 },
13 },
14 {
15 name: "room below opens down",
16 input: { anchorY: 100, anchorHeight: 40, overlayHeight: 800, keyboardInset: 300 },
17 expected: { maxHeight: 342, top: 146 },
18 },
19 {
20 name: "room above opens up",
21 input: { anchorY: 400, anchorHeight: 40, overlayHeight: 800, keyboardInset: 300 },
22 expected: { maxHeight: 382, bottom: 406 },
23 },
24 ])("$name", ({ input, expected }) => {
25 expect(deriveMenuVerticalPlacement({ ...base, ...input })).toEqual(expected);
26 });
27});