/
githubmirror
/
gutenberg
Обзор
Документация
Войти
/
githubmirror
/
gutenberg
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
trunk
packages/rich-text/src/test/remove-format.js
70 строк
1 KB
Marco Ciampini
ESLint: Replace strict config with bulk suppressions (#81248)
07 авг 2026, 14:34
Не верифицирован
07 авг 2026, 14:34
7f43eaf
Код
Авторство
О чём код?
import deepFreeze from 'deep-freeze'; import { removeFormat } from '../remove-format'; import { getSparseArrayLength } from './helpers'; describe( 'removeFormat', () => { const strong = { type: 'strong' }; const em = { type: 'em' }; it( 'should remove format', () => { const record = { formats: [ , , , [ strong ], [ em, strong ], [ em, strong ], [ em ], , , , , , , ], text: 'one two three', }; const expected = { formats: [ , , , , [ em ], [ em ], [ em ], , , , , , , ], activeFormats: [], text: 'one two three', }; const result = removeFormat( deepFreeze( record ), 'strong', 3, 6 ); expect( result ).toEqual( expected ); expect( result ).not.toBe( record ); expect( getSparseArrayLength( result.formats ) ).toBe( 3 ); } ); it( 'should remove format for collapsed selection', () => { const record = { formats: [ , , , [ strong ], [ em, strong ], [ em, strong ], [ em ], , , , , , , ], text: 'one two three', }; const expected = { formats: [ , , , , [ em ], [ em ], [ em ], , , , , , , ], activeFormats: [], text: 'one two three', }; const result = removeFormat( deepFreeze( record ), 'strong', 4, 4 ); expect( result ).toEqual( expected ); expect( result ).not.toBe( record ); expect( getSparseArrayLength( result.formats ) ).toBe( 3 ); } ); } );