1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-23 23:42:56 +02:00

cypress: paste html example test (#4439)

This commit is contained in:
Samarjeet
2021-08-12 17:12:53 +05:30
committed by GitHub
parent 8f46d686ac
commit 3e4d92005a

View 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!')
})
})