/
githubmirror
/
gutenberg
Обзор
Документация
Войти
/
githubmirror
/
gutenberg
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
trunk
packages/i18n/src/test/sprintf.ts
31 строка
925 B
Marco Ciampini
ESLint: Replace strict config with bulk suppressions (#81248)
07 авг 2026, 14:34
Не верифицирован
07 авг 2026, 14:34
7f43eaf
Код
Авторство
О чём код?
import { sprintf } from '../sprintf'; import type { TransformedText } from '../types'; describe( 'i18n', () => { describe( 'sprintf', () => { it( 'replaces placeholders', () => { const result = sprintf( 'bonjour %s', 'Riad' ); expect( result ).toBe( 'bonjour Riad' ); } ); it( 'replaces named placeholders', () => { const result = sprintf( 'bonjour %(name)s', { name: 'Riad' } ); expect( result ).toBe( 'bonjour Riad' ); } ); it( 'preserves format string literal in return type', () => { const result = sprintf( '<Name>%s</Name>', 'Riad' ); // Type-level test: sprintf return type should be TransformedText // preserving the format string literal. const _check: TransformedText< '<Name>%s</Name>' > = result; void _check; // At runtime it's still a regular string. expect( typeof result ).toBe( 'string' ); expect( result ).toBe( '<Name>Riad</Name>' ); } ); } ); } );