/
githubmirror
/
gutenberg
Обзор
Документация
Войти
/
githubmirror
/
gutenberg
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
trunk
packages/components/src/utils/test/get-node-text.js
34 строки
921 B
Marco Ciampini
ESLint: Replace strict config with bulk suppressions (#81248)
07 авг 2026, 14:34
Не верифицирован
07 авг 2026, 14:34
7f43eaf
Код
Авторство
О чём код?
import getNodeText from '../get-node-text'; describe( 'getNodeText', () => { it( 'should return an empty string for null', () => { expect( getNodeText( null ) ).toBe( '' ); } ); it( 'should return the string representation of a string node', () => { expect( getNodeText( 'Hello' ) ).toBe( 'Hello' ); } ); it( 'should return the string representation of a number node', () => { expect( getNodeText( 123 ) ).toBe( '123' ); } ); it( 'should return an empty string for a boolean node', () => { expect( getNodeText( true ) ).toBe( '' ); } ); it( 'should concatenate text from an array of nodes', () => { expect( getNodeText( [ 'Hello', ' ', 'World' ] ) ).toBe( 'Hello World' ); } ); it( 'should return text from a React element with children', () => { const element = ( <div> Hello <span>World</span> </div> ); expect( getNodeText( element ) ).toBe( 'Hello World' ); } ); } );