Files
Supra4E8C df252e39ea test: merge overlapping suites and drop brittle assertions
Fold single-purpose files into their topic suites, parameterize the
per-provider copies, and remove source-grep, constant and duplicated
assertions plus locale presence checks now covered by localeParity.
2026-11-23 18:46:10 +08:00

33 lines
1.3 KiB
TypeScript

import { describe, expect, test } from 'bun:test';
import { resolveDropdownStyle } from '@/components/ui/selectPosition';
describe('Select dropdown positioning', () => {
const viewport = { width: 390, height: 844 };
const trigger = { left: 300, right: 366, top: 19, bottom: 51, width: 66 };
test('keeps the trigger width when no minimum is requested', () => {
const style = resolveDropdownStyle(trigger, viewport.width, viewport.height);
expect(style.width).toBe(66);
expect(style.left).toBe(300);
});
test('widens to the minimum and right-aligns with a trigger near the right edge', () => {
const style = resolveDropdownStyle(trigger, viewport.width, viewport.height, 180);
expect(style.width).toBe(180);
expect(style.left).toBe(366 - 180);
});
test('never exceeds the viewport', () => {
const style = resolveDropdownStyle(trigger, 160, viewport.height, 180);
expect(style.width).toBe(160 - 16);
expect(style.left).toBe(8);
});
test('left-aligns when there is room to the right', () => {
const left = { left: 24, right: 90, top: 19, bottom: 51, width: 66 };
const style = resolveDropdownStyle(left, viewport.width, viewport.height, 180);
expect(style.left).toBe(24);
expect(style.width).toBe(180);
});
});