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 03:56:08 +08:00
|
|
|
beforeEach(() => {
|
2020-09-12 00:06:13 +08:00
|
|
|
cy.get('.ProseMirror').then(([{ editor }]) => {
|
2020-09-11 18:12:15 +08:00
|
|
|
editor.clearContent()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-10-08 20:15:02 +08:00
|
|
|
it('should parse paragraphs correctly', () => {
|
|
|
|
cy.get('.ProseMirror').then(([{ editor }]) => {
|
|
|
|
editor.setContent('<p>Example Text</p>')
|
|
|
|
expect(editor.html()).to.eq('<p>Example Text</p>')
|
|
|
|
|
|
|
|
editor.setContent('<p><x-unknown>Example Text</x-unknown></p>')
|
|
|
|
expect(editor.html()).to.eq('<p>Example Text</p>')
|
|
|
|
|
|
|
|
editor.setContent('<p style="display: block;">Example Text</p>')
|
|
|
|
expect(editor.html()).to.eq('<p>Example Text</p>')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-09-11 21:57:33 +08:00
|
|
|
it('text should be wrapped in a paragraph by default', () => {
|
2020-09-15 06:07:00 +08:00
|
|
|
cy.get('.ProseMirror')
|
2020-09-15 15:03:08 +08:00
|
|
|
.type('Example Text')
|
2020-09-15 06:07:00 +08:00
|
|
|
.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', () => {
|
2020-09-15 06:07:00 +08:00
|
|
|
cy.get('.ProseMirror')
|
2020-09-15 15:03:08 +08:00
|
|
|
.type('First Paragraph{enter}Second Paragraph')
|
2020-09-15 06:07:00 +08:00
|
|
|
.find('p')
|
|
|
|
.should('have.length', 2)
|
|
|
|
|
|
|
|
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', () => {
|
2020-09-15 06:07:00 +08:00
|
|
|
cy.get('.ProseMirror')
|
2020-09-15 15:03:08 +08:00
|
|
|
.type('{enter}')
|
2020-09-15 06:07:00 +08:00
|
|
|
.find('p')
|
|
|
|
.should('have.length', 2)
|
|
|
|
|
|
|
|
cy.get('.ProseMirror')
|
2020-09-15 15:03:08 +08:00
|
|
|
.type('{backspace}')
|
2020-09-15 06:07:00 +08:00
|
|
|
.find('p')
|
|
|
|
.should('have.length', 1)
|
2020-09-09 22:12:39 +08:00
|
|
|
})
|
2020-09-24 05:38:11 +08:00
|
|
|
})
|