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

42 lines
1.4 KiB
JavaScript
Raw Normal View History

2020-09-10 17:53:03 +08:00
context('/api/extensions/strike', () => {
2020-09-11 23:51:57 +08:00
before(() => {
2020-09-10 17:53:03 +08:00
cy.visit('/api/extensions/strike')
2020-09-11 23:51:57 +08:00
})
2020-09-12 03:56:08 +08:00
beforeEach(() => {
2020-09-12 00:06:13 +08:00
cy.get('.ProseMirror').then(([{ editor }]) => {
editor.setContent('<p>Example Text</p>')
2020-09-12 00:35:25 +08:00
editor.focus()
2020-09-11 21:57:33 +08:00
editor.selectAll()
})
})
2020-09-11 21:57:33 +08:00
it('the button should strike the selected text', () => {
cy.get('.demo__preview button:first').click({ force: true })
2020-09-12 03:56:08 +08:00
cy.get('.ProseMirror').find('s').should('contain', 'Example Text')
2020-09-11 21:57:33 +08:00
})
2020-09-11 21:57:33 +08:00
it('the button should toggle the selected text striked', () => {
cy.get('.demo__preview button:first').click({ force: true })
cy.get('.ProseMirror').type('{selectall}', { force: true })
cy.get('.demo__preview button:first').click({ force: true })
cy.get('.ProseMirror s').should('not.exist')
})
2020-09-11 21:57:33 +08:00
it('the keyboard shortcut should strike the selected text', () => {
cy.get('.ProseMirror').type('{meta}d', { force: true })
2020-09-12 03:56:08 +08:00
cy.get('.ProseMirror').find('s').should('contain', 'Example Text')
2020-09-11 21:57:33 +08:00
})
2020-09-11 21:57:33 +08:00
it('the keyboard shortcut should toggle the selected text striked', () => {
cy.get('.ProseMirror').type('{meta}d', { force: true }).type('{meta}d', { force: true })
cy.get('.ProseMirror s').should('not.exist')
})
2020-09-11 21:57:33 +08:00
it('should make a striked text from the markdown shortcut', () => {
cy.get('.ProseMirror')
.type('~Strike~', { force: true })
2020-09-12 03:56:08 +08:00
.find('s')
.should('contain', 'Strike')
2020-09-10 17:53:03 +08:00
})
})