From cb588bf6e0b8539d24d5063bc48dec026f2903e0 Mon Sep 17 00:00:00 2001 From: Hans Pagel Date: Wed, 23 Sep 2020 12:14:00 +0200 Subject: [PATCH] add more bullet list tests --- .../demos/Extensions/BulletList/index.spec.js | 106 +++++++++++++++++- 1 file changed, 102 insertions(+), 4 deletions(-) diff --git a/docs/src/demos/Extensions/BulletList/index.spec.js b/docs/src/demos/Extensions/BulletList/index.spec.js index c3615e94..f58bb113 100644 --- a/docs/src/demos/Extensions/BulletList/index.spec.js +++ b/docs/src/demos/Extensions/BulletList/index.spec.js @@ -10,13 +10,68 @@ context('/api/extensions/bullet-list', () => { }) }) - it('should make a bullet list from different markdown shortcuts', () => { + it('the button should make the selected line a bullet list item', () => { + cy.get('.ProseMirror ul') + .should('not.exist') + + cy.get('.ProseMirror ul li') + .should('not.exist') + + cy.get('.demo__preview button:nth-child(1)') + .click() + + cy.get('.ProseMirror') + .find('ul') + .should('contain', 'Example Text') + + cy.get('.ProseMirror') + .find('ul li') + .should('contain', 'Example Text') + }) + + it('the button should toggle the bullet list', () => { + cy.get('.ProseMirror ul') + .should('not.exist') + + cy.get('.demo__preview button:nth-child(1)') + .click() + + cy.get('.ProseMirror') + .find('ul') + .should('contain', 'Example Text') + + cy.get('.demo__preview button:nth-child(1)') + .click() + + cy.get('.ProseMirror ul') + .should('not.exist') + }) + + it('should leave the list with double enter', () => { cy.get('.ProseMirror').then(([{ editor }]) => { editor.clearContent() }) cy.get('.ProseMirror') - .type('* List Item 1{enter}{enter}+ List Item 2{enter}{enter}- List Item 3') + .type('- List Item 1{enter}{enter}Paragraph') + + cy.get('.ProseMirror') + .find('li') + .its('length') + .should('eq', 1) + + cy.get('.ProseMirror') + .find('p') + .should('contain', 'Paragraph') + }) + + it('should make a bullet list from an asterisk', () => { + cy.get('.ProseMirror').then(([{ editor }]) => { + editor.clearContent() + }) + + cy.get('.ProseMirror') + .type('* List Item 1{enter}List Item 2') cy.get('.ProseMirror') .find('li:nth-child(1)') @@ -25,9 +80,52 @@ context('/api/extensions/bullet-list', () => { cy.get('.ProseMirror') .find('li:nth-child(2)') .should('contain', 'List Item 2') + }) + + it('should make a bullet list from a dash', () => { + cy.get('.ProseMirror').then(([{ editor }]) => { + editor.clearContent() + }) cy.get('.ProseMirror') - .find('li:nth-child(3)') - .should('contain', 'List Item 3') + .type('- List Item 1{enter}List Item 2') + + cy.get('.ProseMirror') + .find('li:nth-child(1)') + .should('contain', 'List Item 1') + + cy.get('.ProseMirror') + .find('li:nth-child(2)') + .should('contain', 'List Item 2') + }) + + it('should make a bullet list from a plus', () => { + cy.get('.ProseMirror').then(([{ editor }]) => { + editor.clearContent() + }) + + cy.get('.ProseMirror') + .type('+ List Item 1{enter}List Item 2') + + cy.get('.ProseMirror') + .find('li:nth-child(1)') + .should('contain', 'List Item 1') + + cy.get('.ProseMirror') + .find('li:nth-child(2)') + .should('contain', 'List Item 2') + }) + + it('should remove the bullet list after pressing backspace', () => { + cy.get('.ProseMirror').then(([{ editor }]) => { + editor.clearContent() + }) + + cy.get('.ProseMirror') + .type('* {backspace}Example') + + cy.get('.ProseMirror') + .find('p') + .should('contain', '* Example') }) }) \ No newline at end of file