tiptap/docs/src/demos/Extensions/Paragraph/index.spec.js

32 lines
1.2 KiB
JavaScript
Raw Normal View History

2020-09-09 22:12:39 +08:00
context('/api/extensions/paragraph', () => {
beforeEach(() => {
cy.visit('/api/extensions/paragraph')
2020-09-11 18:12:15 +08:00
cy.get('.ProseMirror').window().then(window => {
const { editor } = window
editor.clearContent()
})
})
describe('paragraph', () => {
it('text should be wrapped in a paragraph by default', () => {
cy.get('.ProseMirror').type('Example Text', {force: true})
cy.get('.ProseMirror').contains('p', 'Example Text')
cy.get('.ProseMirror').find('p').should('have.length', 1)
})
it('enter should make a new paragraph', () => {
cy.get('.ProseMirror').type('First Paragraph{enter}Second Paragraph', {force: true})
cy.get('.ProseMirror').find('p').should('have.length', 2)
cy.get('.ProseMirror').contains('p:first', 'First Paragraph')
cy.get('.ProseMirror').contains('p:nth-child(2)', 'Second Paragraph')
})
it('backspace should remove the second paragraph', () => {
cy.get('.ProseMirror').type('{enter}', {force: true})
cy.get('.ProseMirror').find('p').should('have.length', 2)
cy.get('.ProseMirror').type('{backspace}', {force: true})
cy.get('.ProseMirror').find('p').should('have.length', 1)
})
2020-09-09 22:12:39 +08:00
})
})