diff --git a/cypress/integration/examples/paste-html.ts b/cypress/integration/examples/paste-html.ts new file mode 100644 index 000000000..a47cb864d --- /dev/null +++ b/cypress/integration/examples/paste-html.ts @@ -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 ', () => { + cyNewPasteHtml('Hello Bold') + .get('strong') + .should('contain.text', 'Hello') + }) + + it('pasted code uses ', () => { + cyNewPasteHtml('console.log("hello from slate!")') + .get('code') + .should('contain.text', 'slate!') + }) +})