/
githubmirror
/
gutenberg
Обзор
Документация
Войти
/
githubmirror
/
gutenberg
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
trunk
packages/fields/src/components/create-template-part-modal/test/utils.js
57 строк
1 KB
Marco Ciampini
ESLint: Replace strict config with bulk suppressions (#81248)
07 авг 2026, 14:34
Не верифицирован
07 авг 2026, 14:34
7f43eaf
Код
Авторство
О чём код?
import { getUniqueTemplatePartTitle, getCleanTemplatePartSlug } from '../utils'; describe( 'getUniqueTemplatePartTitle', () => { it( 'should return the title if it is unique', () => { const title = 'My Template Part'; const templateParts = [ { title: { rendered: 'Template Part With Another Title', }, }, ]; expect( getUniqueTemplatePartTitle( title, templateParts ) ).toBe( title ); } ); it( 'should return the title with a suffix if it is not unique', () => { const title = 'My Template Part'; const templateParts = [ { title: { rendered: 'My Template Part', }, }, { title: { rendered: 'My Template Part 2', }, }, ]; expect( getUniqueTemplatePartTitle( title, templateParts ) ).toBe( 'My Template Part 3' ); } ); } ); describe( 'getCleanTemplatePartSlug', () => { it( 'should return a slug with only latin chars', () => { const title = 'Myɶ Template Partɮ'; expect( getCleanTemplatePartSlug( title ) ).toBe( 'my-template-part' ); } ); it( 'should return a slug with only latin chars and numbers', () => { const title = 'My Template Part 2'; expect( getCleanTemplatePartSlug( title ) ).toBe( 'my-template-part-2' ); } ); it( 'should default the slug to wp-custom-part', () => { const title = ''; expect( getCleanTemplatePartSlug( title ) ).toBe( 'wp-custom-part' ); } ); } );