2020-09-09 22:12:39 +08:00
|
|
|
context('/api/extensions/paragraph', () => {
|
2020-09-11 23:51:57 +08:00
|
|
|
before(() => {
|
2020-09-09 22:12:39 +08:00
|
|
|
cy.visit('/api/extensions/paragraph')
|
2020-09-11 23:51:57 +08:00
|
|
|
})
|
2020-09-11 18:12:15 +08:00
|
|
|
|
2020-09-12 00:52:18 +08:00
|
|
|
beforeEach(done => {
|
2020-09-12 00:06:13 +08:00
|
|
|
cy.get('.ProseMirror').then(([{ editor }]) => {
|
2020-09-12 00:52:18 +08:00
|
|
|
editor.focus()
|
2020-09-11 18:12:15 +08:00
|
|
|
editor.clearContent()
|
2020-09-12 00:52:18 +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 })
|
2020-09-12 03:04:55 +08:00
|
|
|
cy.get('.ProseMirror').find('p').should('contain', 'Example Text')
|
2020-09-11 21:57:33 +08:00
|
|
|
})
|
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)
|
2020-09-12 03:04:55 +08:00
|
|
|
cy.get('.ProseMirror').find('p:first').should('contain', 'First Paragraph')
|
|
|
|
cy.get('.ProseMirror').find('p:nth-child(2)').should('contain', 'Second Paragraph')
|
2020-09-11 21:57:33 +08:00
|
|
|
})
|
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
|
|
|
})
|
|
|
|
})
|