tests.FontTable
The fonts a test measures text with, so its layouts come out the same on every machine or match a device's.
Utilisation
Configure font measurements for tests.
// Configure font measurements for tests.
import { Text, VStack } from 'kuito';
import { assert, render, screen, test, type FontTable } from 'kuito/tests';
// Regular and bold faces of the system font, as a device measured them.
const fonts: FontTable = {
faces: [
{ weight: 400, size: 17, lineHeight: 22, advances: { ' ': 4.3 }, fallback: 9.5 },
{ weight: 700, size: 17, lineHeight: 22, advances: { ' ': 4.5 }, fallback: 10.2 },
],
};
test('a bold title wraps onto two lines', async () => {
await render(
<VStack width={160}>
<Text fontWeight="bold">Weekly summary report</Text>
</VStack>,
{ fonts },
);
assert.equal(screen.getByText('Weekly summary report').frame.height, 44);
});Déclaration du type
export interface FontTable {
faces: readonly FontFace[];
}Membres 1
| Nom | Type | Requis | Description |
|---|---|---|---|
faces | readonly FontFace[] | Oui | — |
Généré depuis les déclarations TypeScript publiques : signatures, props et valeurs par défaut viennent de la source vérifiée, les descriptions de sa JSDoc. Aucune valeur par défaut n'est inventée.