improve the hardbreak demo and add tests

This commit is contained in:
Hans Pagel
2020-09-10 12:11:42 +02:00
parent 72d262c9fc
commit c2570d6adc
4 changed files with 30 additions and 2 deletions

View File

@@ -1,5 +1,30 @@
context('/api/extensions/hard-break', () => {
beforeEach(() => {
cy.visit('/api/extensions/hard-break')
cy.get('.ProseMirror').window().then(window => {
const { editor } = window
editor.setContent('<p>Example Text</p>')
})
})
describe('hard-break', () => {
it('the button should add a line break', () => {
cy.get('.ProseMirror br').should('not.exist')
cy.get('.demo__preview button:first').click({ force: true })
cy.get('.ProseMirror br').should('exist')
})
it('the default keyboard shortcut should add a line break', () => {
cy.get('.ProseMirror br').should('not.exist')
cy.get('.ProseMirror').type('{shift}{enter}', {force: true})
cy.get('.ProseMirror br').should('exist')
})
it('the alternative keyboard shortcut should add a line break', () => {
cy.get('.ProseMirror br').should('not.exist')
cy.get('.ProseMirror').type('{meta}{enter}', {force: true})
cy.get('.ProseMirror br').should('exist')
})
})
})

View File

@@ -1,5 +1,9 @@
<template>
<div v-if="editor">
<button @click="editor.focus().hardBreak()">
hardBreak
</button>
<editor-content :editor="editor" />
</div>
</template>