import { HtmlToSlate } from '../htmlToSlate'; import defaultPlugins from '../plugins'; import makeSlatePluginsFromDef from '../utils/makeSlatePluginsFromDef'; const htmlToSlate = HtmlToSlate({ plugins: makeSlatePluginsFromDef(defaultPlugins), }); describe('HtmlToSlate', () => { it('parses h1 tags', async () => { expect(await htmlToSlate('
some projects
')).toEqual({ slate: [ { type: 'PARAGRAPH/PARAGRAPH', children: [{ text: 'some projects' }], }, ], }); }); it('parses a list of tags to an array', async () => { expect( await htmlToSlate(`Lorem ipsum
`) ).toEqual({ slate: [ { type: 'HEADINGS/HEADING-ONE', children: [{ text: 'Hello World' }], }, { type: 'PARAGRAPH/PARAGRAPH', children: [{ text: 'Lorem ipsum' }], }, ], }); }); it('parses nested tags with headin', async () => { expect( await htmlToSlate('some projects-foo
') ).toEqual({ slate: [ { children: [ { text: 'some ', }, { 'EMPHASIZE/EM': true, text: 'projects', }, { text: '-' }, { 'EMPHASIZE/STRONG': true, text: 'foo', }, ], type: 'PARAGRAPH/PARAGRAPH', }, ], }); }); it('parses code blocks', async () => { expect( await htmlToSlate( 'abcde
ab
')).toEqual({ slate: [ { type: 'PARAGRAPH/PARAGRAPH', children: [{ text: 'ab' }], data: { align: 'center', }, }, ], }); }); it('parses blockquote', async () => { expect( await htmlToSlate( 'asdfgh' ) ).toEqual({ slate: [ { type: 'BLOCKQUOTE/BLOCKQUOTE', children: [ { text: 'asdfgh', }, ], data: { align: 'center', }, }, ], }); }); });