Watch
0
0
Fork
You've already forked hyperhive
0
hyperhive/frontend/packages/swarm-ui/test/popover-position.test.mjs

17 lines
703 B
JavaScript

// Where a table's filter popover sits. Run by `npm test`, which Node runs
// with its built-in test runner and type stripping, so the `.ts` module is
// imported as it is.
import assert from "node:assert/strict";
import { test } from "node:test";
import { clampLeft } from "../src/ui/table/popover-position.ts";
test("a popover near the right edge is pulled back on screen", () => {
// 300 wide in a 1000 wide window: the right edge may reach 992.
assert.equal(clampLeft(900, 300, 1000), 692);
assert.equal(clampLeft(100, 300, 1000), 100);
});
test("a popover never goes past the left edge", () => {
assert.equal(clampLeft(5, 300, 1000), 8);
assert.equal(clampLeft(50, 2000, 1000), 8);
});