mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-06-13 05:11:04 +08:00
57 lines
1.0 KiB
JavaScript
57 lines
1.0 KiB
JavaScript
context('/src/Examples/Menus/React/', () => {
|
|
before(() => {
|
|
cy.visit('/src/Examples/Menus/React/')
|
|
})
|
|
|
|
beforeEach(() => {
|
|
cy.get('.tiptap').then(([{ editor }]) => {
|
|
editor.chain().focus().clearContent().run()
|
|
})
|
|
})
|
|
|
|
it('should show menu when the editor is empty', () => {
|
|
cy.get('#app')
|
|
.find('[data-tippy-root]')
|
|
})
|
|
|
|
it('should show menu when text is selected', () => {
|
|
cy.get('.tiptap')
|
|
.type('Test')
|
|
.type('{selectall}')
|
|
|
|
cy.get('#app')
|
|
.find('[data-tippy-root]')
|
|
})
|
|
|
|
const marks = [
|
|
{
|
|
button: 'Bold',
|
|
tag: 'strong',
|
|
},
|
|
{
|
|
button: 'Italic',
|
|
tag: 'em',
|
|
},
|
|
{
|
|
button: 'Strike',
|
|
tag: 's',
|
|
},
|
|
]
|
|
|
|
marks.forEach(mark => {
|
|
it(`should apply ${mark.button} correctly`, () => {
|
|
cy.get('.tiptap')
|
|
.type('Test')
|
|
.type('{selectall}')
|
|
|
|
cy.get('#app')
|
|
.find('[data-tippy-root]')
|
|
.contains(mark.button)
|
|
.click()
|
|
|
|
cy.get('.tiptap')
|
|
.find(`p ${mark.tag}`)
|
|
})
|
|
})
|
|
})
|