Skip to content

Commit

Permalink
test scroll behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
pradel committed Nov 9, 2020
1 parent cfcf5df commit 4c7598c
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions cypress/integration/modal.spec.ts
Expand Up @@ -40,4 +40,29 @@ describe('simple modal', () => {
cy.get('body').type('{esc}');
cy.get('[data-testid=modal]').should('not.exist');
});

it('should block the scroll when modal is opened', () => {
cy.get('button').eq(2).click();
cy.get('html').should('have.css', 'position', 'fixed');
});

it('should unblock the scroll when modal is closed', () => {
cy.get('button').eq(2).click();
cy.get('html').should('have.css', 'position', 'fixed');
cy.get('body').type('{esc}');
cy.get('html').should('not.have.css', 'position', 'fixed');
});

it('should unblock scroll only after last modal is closed when multiple modals are opened', () => {
cy.get('button').eq(8).click();
cy.get('[data-testid=modal] button').eq(0).click();
cy.get('[data-testid=modal]').should('have.length', 2);
cy.get('html').should('have.css', 'position', 'fixed');
cy.get('body').type('{esc}');
cy.get('[data-testid=modal]').should('have.length', 1);
cy.get('html').should('have.css', 'position', 'fixed');
cy.get('body').type('{esc}');
cy.get('[data-testid=modal]').should('not.exist');
cy.get('html').should('not.have.css', 'position', 'fixed');
});
});

0 comments on commit 4c7598c

Please sign in to comment.