archivo del paquete→ .shtukbase/packages/shtukbase-ui-react/test/overflow.test.ts
test/overflow.test.ts
24 líneas, 1.5 KB.
El archivo tal como está en el paquete: el código y sus comentarios no se traducen.
- // Text never leaves a component, as React draws it: every state of every React component, rendered to markup, with its
- // texts replaced by long Russian text, measured in headless Chrome by the overflow page of shtukbase-ui-html (the look is
- // its ui.css). Skipped where no Chrome or Chromium is installed (set CHROME to its path).
- import { describe, expect, test } from 'bun:test';
- import { readFileSync } from 'node:fs';
- import { join } from 'node:path';
- import { type Cell, findChrome, MEASURED_LEVELS, overflowPage, runChrome } from '../../shtukbase-ui-html/lib/overflow.ts';
- import { HTML_PACKAGE, libraryComponents, load, renderState } from './lib.ts';
- const chrome = findChrome();
- const DESIGN = join(HTML_PACKAGE, 'pages', 'design', 'shtukbase-ui-html');
- describe.skipIf(!chrome)('no text overflows in a React state, with long Russian text', async () => {
- const css = readFileSync(join(DESIGN, 'demo-tokens.css'), 'utf8') + readFileSync(join(DESIGN, 'ui.css'), 'utf8');
- const loaded = (await Promise.all(libraryComponents().map((c) => load(c.id)))).filter((c) => MEASURED_LEVELS.includes(c.header.level));
- const cells: Cell[] = loaded.flatMap((c) =>
- c.states.names.map((state) => ({ id: c.id, state, level: c.header.level, markup: renderState(c, state) })));
- const failures = runChrome(chrome!, overflowPage(cells, css));
- for (const c of loaded) {
- test(c.id, () => {
- expect(failures.filter((f) => f.id === c.id).map((f) => `${f.state}: ${f.what}`)).toEqual([]);
- });
- }
- });