5180 fichiers 38.5 Mo 0 téléchargements 199 vues mis à jour il y a 5 heures ui
nitro-v36-with-renderer-v36 / src / common / native-text / fitNativeText.test.ts
fitNativeText.test.ts 784 o Télécharger le fichier
import { describe, expect, it } from 'vitest';
import { fitNativeText } from './fitNativeText';

// Every character 5 px wide.
const measure = (text: string) => text.length * 5;

describe('fitNativeText', () => {
    it('keeps text that fits', () => {
        expect(fitNativeText('Normale muren', 65, measure)).toBe('Normale muren');
    });

    it('cuts text that does not fit and ends it in dots', () => {
        expect(fitNativeText('Normale muren', 50, measure)).toBe('Normale...');
    });

    it('drops the space before the dots', () => {
        expect(fitNativeText('Free Flow style', 40, measure)).toBe('Free...');
    });

    it('leaves only the dots when nothing else fits', () => {
        expect(fitNativeText('Normale muren', 10, measure)).toBe('...');
    });
});
15Sujets
1Dépôts
20Membres
2En ligne
Profile
Inscrit
Dernière visite
Messages
0
Votes positifs
0
Votes négatifs
0

Nous utilisons des cookies pour assurer le bon fonctionnement du site et améliorer votre expérience. en savoir plus

Autoriser