File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
packages/block-tools/test/html-to-blocks Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ import { JSDOM } from 'jsdom'
2+ import { describe , expect , test } from 'vitest'
3+ import { htmlToBlocks } from '../../src'
4+ import defaultSchema from '../fixtures/defaultSchema'
5+ import { createTestKeyGenerator } from '../test-key-generator'
6+
7+ const blockContentType = defaultSchema
8+ . get ( 'blogPost' )
9+ . fields . find ( ( field : any ) => field . name === 'body' ) . type
10+
11+ describe ( htmlToBlocks . name , ( ) => {
12+ test ( 'span with space' , ( ) => {
13+ expect (
14+ htmlToBlocks ( `a<span> </span>b` , blockContentType , {
15+ parseHtml : ( html ) => new JSDOM ( html ) . window . document ,
16+ keyGenerator : createTestKeyGenerator ( ) ,
17+ } ) ,
18+ ) . toEqual ( [
19+ {
20+ _key : 'randomKey0' ,
21+ _type : 'block' ,
22+ children : [
23+ {
24+ _key : 'randomKey1' ,
25+ _type : 'span' ,
26+ marks : [ ] ,
27+ text : 'a b' ,
28+ } ,
29+ ] ,
30+ markDefs : [ ] ,
31+ style : 'normal' ,
32+ } ,
33+ ] )
34+ } )
35+ } )
You can’t perform that action at this time.
0 commit comments