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

41 lines
1.3 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-11 23:51:57 +08:00
beforeEach((done) => {
2020-09-12 00:06:13 +08:00
cy.get('.ProseMirror').then(([{ editor }]) => {
editor.setContent('<p>Example Text</p>')
2020-09-11 21:57:33 +08:00
editor.selectAll()
2020-09-11 23:51:57 +08:00
done()
})
})
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 })
cy.get('.ProseMirror').contains('s', 'Example Text')
})
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 })
cy.get('.ProseMirror').contains('s', 'Example Text')
})
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 })
.contains('s', 'Strike')
2020-09-10 17:53:03 +08:00
})
})