/* eslint-env jest */ import { loneImagesAsFigures, withToc } from '../blocks'; // The block API ships as ES modules Jest does not transform; nothing here // parses blocks. jest.mock('@wordpress/blocks', () => ({})); describe('a picture alone in a paragraph', () => { it('becomes a figure, so no empty paragraph is left behind', () => { expect( loneImagesAsFigures( '

Text

\nA skillet\n

' ) ).toBe( '

Text

A skillet
' ); }); it('stays in a paragraph that has words around it', () => { const html = '

Look here

'; expect(loneImagesAsFigures(html)).toBe(html); }); }); describe('the table of contents added from its test', () => { it('goes after the first paragraph, or on top without one', () => { const content = '\n

Lead.

\n\n\n\n

One

\n'; expect(withToc(content)).toBe( '\n

Lead.

\n\n\n\n\n\n

One

\n' ); expect( withToc('\n

One

\n') ).toBe( '\n\n\n

One

\n' ); }); });