diff --git a/packages/block-tools/test/html-to-blocks/list.test.ts b/packages/block-tools/test/html-to-blocks/list.test.ts new file mode 100644 index 000000000..796860b9a --- /dev/null +++ b/packages/block-tools/test/html-to-blocks/list.test.ts @@ -0,0 +1,53 @@ +import {JSDOM} from 'jsdom' +import {describe, expect, test} from 'vitest' +import {htmlToBlocks} from '../../src' +import defaultSchema from '../fixtures/defaultSchema' +import {createTestKeyGenerator} from '../test-key-generator' + +const blockContentType = defaultSchema + .get('blogPost') + .fields.find((field: any) => field.name === 'body').type + +describe(htmlToBlocks.name, () => { + test('list items without parent', () => { + expect( + htmlToBlocks(`
  • foo bar
  • baz
  • `, blockContentType, { + parseHtml: (html) => new JSDOM(html).window.document, + keyGenerator: createTestKeyGenerator(), + }), + ).toEqual([ + { + _key: 'randomKey0', + _type: 'block', + children: [ + { + _key: 'randomKey1', + _type: 'span', + marks: [], + text: 'foo bar', + }, + ], + markDefs: [], + style: 'normal', + listItem: 'bullet', + level: 1, + }, + { + _key: 'randomKey2', + _type: 'block', + children: [ + { + _key: 'randomKey3', + _type: 'span', + marks: [], + text: 'baz', + }, + ], + markDefs: [], + style: 'normal', + listItem: 'bullet', + level: 1, + }, + ]) + }) +})