mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-24 07:52:50 +02:00
cypress: paste html example test (#4439)
This commit is contained in:
29
cypress/integration/examples/paste-html.ts
Normal file
29
cypress/integration/examples/paste-html.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
describe('paste html example', () => {
|
||||
beforeEach(() => cy.visit('examples/paste-html'))
|
||||
|
||||
const createHtmlPasteEvent = (htmlContent: string) =>
|
||||
Object.assign(new Event('paste', { bubbles: true, cancelable: true }), {
|
||||
clipboardData: {
|
||||
getData: (type = 'text/html') => htmlContent,
|
||||
types: ['text/html'],
|
||||
},
|
||||
})
|
||||
|
||||
const cyNewPasteHtml = (htmlContent: string) =>
|
||||
cy
|
||||
.findByRole('textbox')
|
||||
.type('{selectall}')
|
||||
.trigger('paste', createHtmlPasteEvent(htmlContent))
|
||||
|
||||
it('pasted bold text uses <strong>', () => {
|
||||
cyNewPasteHtml('<strong>Hello Bold</strong>')
|
||||
.get('strong')
|
||||
.should('contain.text', 'Hello')
|
||||
})
|
||||
|
||||
it('pasted code uses <code>', () => {
|
||||
cyNewPasteHtml('<code>console.log("hello from slate!")</code>')
|
||||
.get('code')
|
||||
.should('contain.text', 'slate!')
|
||||
})
|
||||
})
|
Reference in New Issue
Block a user