import createTestEditor from '../testing/createTestEditor'; import createTestEditorWithSerializer from '../testing/createTestEditorWithSerializer'; import detailsPlugin from './detailsPlugin'; describe('detailsPlugin', () => { it('should add jop-noMdConv attributes to
and ', () => { const { toHtml, normalizeHtml } = createTestEditorWithSerializer({ html: `
Test

Test...

`, plugins: [detailsPlugin], }); expect(toHtml()).toBe(normalizeHtml([ '
Test', '

Test...

', '
', ].join(''))); }); it.each([ { initialOpen: false }, { initialOpen: true }, ])('toggling the details element should update its state (%j)', ({ initialOpen }) => { const view = createTestEditor({ html: ` Test summary

Test content.

`, plugins: [detailsPlugin], }); const details = view.dom.querySelector('details'); details.open = !initialOpen; details.dispatchEvent(new Event('toggle')); // The changes to the DOM should be reflected in the editor state expect(view.state.doc.toJSON()).toMatchObject({ content: [ { type: 'details', attrs: { open: !initialOpen }, content: [ { type: 'details_summary' }, { type: 'paragraph' }, ], }, ], }); }); });