Skip to content

Commit

Permalink
Add a test to check that styles are being applied to iframe document
Browse files Browse the repository at this point in the history
  • Loading branch information
glendaviesnz committed Sep 23, 2022
1 parent 95df797 commit 996534c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
22 changes: 22 additions & 0 deletions cypress/integration/iframe_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
describe('Iframed assertions', function () {
beforeEach(function () {
cy.viewport(1000, 600)
cy.visit('/?iframed=true')
})

const getIframeBody = () => {
return cy
.get('iframe[data-cy="iframe"]')
.its('0.contentDocument.body')
.should('not.be.empty')
.then(cy.wrap)
}

it('Display the crop area with correct styles applied to the iframe', () => {
getIframeBody()
.find('.reactEasyCrop_CropArea')
.should('exist')
.should('have.css', 'color')
.and('eq', 'rgba(0, 0, 0, 0.5)')
})
})
1 change: 1 addition & 0 deletions examples/src/iframe.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export default function Iframe({ children }: Props) {
ref={iFrameRef}
srcDoc="<!doctype html>"
title="test iframed"
data-cy="iframe"
>
<>{iframeBody && createPortal(children, iframeBody)}</>
</iframe>
Expand Down

0 comments on commit 996534c

Please sign in to comment.