33 lines
1.5 KiB
TypeScript
33 lines
1.5 KiB
TypeScript
import { windowSizeForLine } from '../src/entities/Font/domain/windowSizeForLine/windowSizeForLine';
|
|
import {
|
|
expect,
|
|
test,
|
|
} from './fixtures';
|
|
|
|
test.describe('preview text', () => {
|
|
test('drives the slider character rendering', async ({ comparison }) => {
|
|
/**
|
|
* Must stay a single unwrapped line of ASCII: the assertion feeds
|
|
* `text.length` (UTF-16 code units) to `windowSizeForLine`, but the
|
|
* renderer feeds it the line's grapheme count. They match only for
|
|
* plain ASCII — emoji/combining marks (length > graphemes) or wrapping
|
|
* (one input string splitting into several lines) silently desync them.
|
|
*/
|
|
const text = 'Sphinx';
|
|
await comparison.pickPair('Inter', 'Roboto');
|
|
await comparison.setPreviewText(text);
|
|
|
|
// Window chars render as `.char-wrap` cells for crossfade. The window
|
|
// size is a pure function of the line's grapheme count — assert against
|
|
// the rule, not a hardcoded constant, so tuning the policy can't silently
|
|
// break this. "Sphinx" is one unwrapped line of 6 graphemes.
|
|
await expect(comparison.slider.locator('.char-wrap')).toHaveCount(windowSizeForLine(text.length));
|
|
});
|
|
|
|
test('preserves the typed value in the input', async ({ comparison }) => {
|
|
const text = 'Sphinx of black quartz';
|
|
await comparison.setPreviewText(text);
|
|
await expect(comparison.previewInput).toHaveValue(text);
|
|
});
|
|
});
|