Move copy button test from e2e to unit test

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
Tilman Vatteroth 2022-04-03 19:31:28 +02:00
parent aca9856766
commit bf1881eb54
4 changed files with 185 additions and 32 deletions

View file

@ -91,21 +91,4 @@ describe('Code', () => {
})
})
})
it('has a working copy button', () => {
cy.setCodemirrorContent('```javascript \nlet x = 0\n```')
cy.getByCypressId('documentIframe').then((element: JQuery<HTMLElement>) => {
const frame = element.get(0) as HTMLIFrameElement
if (frame === null || frame.contentWindow === null) {
return cy.wrap(null)
}
cy.spy(frame.contentWindow.navigator.clipboard, 'writeText').as('copy')
})
cy.getIframeBody().findByCypressId('copy-code-button').click()
cy.get('@copy').should('be.calledWithExactly', 'let x = 0\n')
})
})