|
| 1 | +import {Schema} from 'prosemirror-model'; |
| 2 | + |
| 3 | +import {isNodeEmpty} from './nodes'; |
| 4 | + |
| 5 | +const schema = new Schema({ |
| 6 | + nodes: { |
| 7 | + doc: {content: 'block+'}, |
| 8 | + yfm_cut_content: {content: 'block+'}, |
| 9 | + paragraph: {content: 'inline*', group: 'block'}, |
| 10 | + text: {group: 'inline'}, |
| 11 | + code_block: {content: 'inline*', group: 'block'}, |
| 12 | + }, |
| 13 | +}); |
| 14 | + |
| 15 | +describe('isNodeEmpty', () => { |
| 16 | + it('yfm_cut_content with an empty paragraph', () => { |
| 17 | + const emptyParagraph = schema.nodes.paragraph.create(); |
| 18 | + const yfmCutContent = schema.nodes.yfm_cut_content.create(null, emptyParagraph); |
| 19 | + |
| 20 | + expect(isNodeEmpty(yfmCutContent)).toBe(true); |
| 21 | + }); |
| 22 | + |
| 23 | + it('yfm_cut_content with a paragraph containing text', () => { |
| 24 | + const textNode = schema.text('Hello, world!'); |
| 25 | + const paragraphWithText = schema.nodes.paragraph.create(null, textNode); |
| 26 | + const yfmCutContent = schema.nodes.yfm_cut_content.create(null, paragraphWithText); |
| 27 | + |
| 28 | + expect(isNodeEmpty(yfmCutContent)).toBe(false); |
| 29 | + }); |
| 30 | + |
| 31 | + it('fm_cut_content with a non-paragraph block', () => { |
| 32 | + const codeBlock = schema.nodes.code_block.create(); |
| 33 | + const yfmCutContent = schema.nodes.yfm_cut_content.create(null, codeBlock); |
| 34 | + |
| 35 | + expect(isNodeEmpty(yfmCutContent)).toBe(false); |
| 36 | + }); |
| 37 | +}); |
0 commit comments