diff --git a/demos/src/Examples/Tables/React/index.spec.js b/demos/src/Examples/Tables/React/index.spec.js index b541da60..300b37a8 100644 --- a/demos/src/Examples/Tables/React/index.spec.js +++ b/demos/src/Examples/Tables/React/index.spec.js @@ -10,7 +10,6 @@ context('/src/Examples/Tables/React/', () => { }) }) - // TODO: Write tests it('adds a table with three columns and three rows', () => { cy.get('.ProseMirror table') .should('exist') diff --git a/demos/src/Examples/Tables/Vue/index.spec.js b/demos/src/Examples/Tables/Vue/index.spec.js index 093b8439..36bf16b0 100644 --- a/demos/src/Examples/Tables/Vue/index.spec.js +++ b/demos/src/Examples/Tables/Vue/index.spec.js @@ -10,7 +10,6 @@ context('/src/Examples/Tables/Vue/', () => { }) }) - // TODO: Write tests it('adds a table with three columns and three rows', () => { cy.get('.ProseMirror table') .should('exist') diff --git a/demos/src/Examples/Tasks/React/index.spec.js b/demos/src/Examples/Tasks/React/index.spec.js new file mode 100644 index 00000000..12d02ebd --- /dev/null +++ b/demos/src/Examples/Tasks/React/index.spec.js @@ -0,0 +1,25 @@ +context('/src/Examples/Tasks/React/', () => { + before(() => { + cy.visit('/src/Examples/Tasks/React/') + }) + + beforeEach(() => { + cy.get('.ProseMirror').then(([{ editor }]) => { + editor.commands.clearContent() + }) + }) + + it('should always use task items', () => { + cy.get('.ProseMirror input[type="checkbox"]').should('have.length', 1) + }) + + it('should create new tasks', () => { + cy.get('.ProseMirror').type('Cook food{enter}Eat food{enter}Clean dishes') + cy.get('.ProseMirror input[type="checkbox"]').should('have.length', 3) + }) + + it('should check and uncheck tasks on click', () => { + cy.get('.ProseMirror').type('Cook food{enter}Eat food{enter}Clean dishes') + cy.get('.ProseMirror').find('input[type="checkbox"]').then(console.log) + }) +}) diff --git a/demos/src/Experiments/Commands/Vue/index.spec.js b/demos/src/Experiments/Commands/Vue/index.spec.js new file mode 100644 index 00000000..44518e41 --- /dev/null +++ b/demos/src/Experiments/Commands/Vue/index.spec.js @@ -0,0 +1,44 @@ +context('/src/Experiments/Commands/Vue/', () => { + before(() => { + cy.visit('/src/Experiments/Commands/Vue/') + }) + + beforeEach(() => { + cy.get('.ProseMirror').then(([{ editor }]) => { + editor.commands.clearContent() + }) + }) + + it('should open a popup after typing a slash', () => { + const items = [ + { tag: 'h1' }, + { tag: 'h2' }, + { tag: 'strong' }, + { tag: 'em' }, + ] + + items.forEach((item, i) => { + cy.get('.ProseMirror').type('{selectall}{backspace}/') + cy.get('.tippy-content .items').should('exist') + cy.get('.tippy-content .items .item').eq(i).click() + cy.get('.ProseMirror').type(`I am a ${item.tag}`) + cy.get(`.ProseMirror ${item.tag}`).should('exist').should('have.text', `I am a ${item.tag}`) + }) + }) + + it('should close the popup without any command via esc', () => { + cy.get('.ProseMirror').type('{selectall}{backspace}/') + cy.get('.tippy-content .items').should('exist') + cy.get('.ProseMirror').type('{esc}') + cy.get('.tippy-content .items').should('not.exist') + }) + + it('should open the popup when the cursor is after a slash', () => { + cy.get('.ProseMirror').type('{selectall}{backspace}/') + cy.get('.tippy-content .items').should('exist') + cy.get('.ProseMirror').type('{leftArrow}') + cy.get('.tippy-content .items').should('not.exist') + cy.get('.ProseMirror').type('{rightArrow}') + cy.get('.tippy-content .items').should('exist') + }) +})