import { describe, expect, it } from 'vitest';
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( '%s', 'Riad' );
// Type-level test: sprintf return type should be TransformedText
// preserving the format string literal.
const _check: TransformedText< '%s' > = result;
void _check;
// At runtime it's still a regular string.
expect( typeof result ).toBe( 'string' );
expect( result ).toBe( 'Riad' );
} );
} );
} );