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

33 lines
1.2 KiB
JavaScript
Raw Normal View History

2020-09-09 22:12:39 +08:00
context('/api/extensions/paragraph', () => {
2020-09-11 21:57:33 +08:00
before(() => {
2020-09-09 22:12:39 +08:00
cy.visit('/api/extensions/paragraph')
2020-09-11 21:57:33 +08:00
})
2020-09-11 18:12:15 +08:00
2020-09-11 22:24:37 +08:00
beforeEach((done) => {
2020-09-11 18:12:15 +08:00
cy.get('.ProseMirror').window().then(window => {
const { editor } = window
editor.clearContent()
2020-09-11 22:24:37 +08:00
done()
2020-09-11 18:12:15 +08:00
})
})
2020-09-11 21:57:33 +08:00
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)
})
2020-09-11 18:12:15 +08:00
2020-09-11 21:57:33 +08:00
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')
})
2020-09-11 18:12:15 +08:00
2020-09-11 21:57:33 +08:00
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
})
})