Skip to content

Commit

Permalink
Add cypress test for modalOverlayOpeningElement
Browse files Browse the repository at this point in the history
Also added getOpeningProperties function to modal class to easily verify in testing
  • Loading branch information
wbobeirne authored and monshan committed Jun 28, 2022
1 parent 1840400 commit 3b1f4d5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/js/components/shepherd-modal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
closeModalOpening();
export const getElement = () => element;
export const getOpeningProperties = () => openingProperties;
export function closeModalOpening() {
openingProperties = {
Expand Down
27 changes: 27 additions & 0 deletions test/cypress/integration/modal.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,31 @@ describe('Modal mode', () => {
cy.get('.shepherd-modal-is-visible').should('have.length', 1);
});
});

describe('Modal with separate selector', function() {
const steps = () => {
return [
{
attachTo: {
element: '.hero-welcome',
on: 'bottom'
},
modalOverlayOpeningElement: '.hero-welcome h1',
}
];
};

beforeEach(() => {
tour = setupTour(Shepherd, {}, steps, {
useModalOverlay: true
});
});

it('has the modal target the separate selector element', function() {
tour.start();
cy.get('.shepherd-modal-is-visible').should('have.length', 1);
const openingPropertyHeight = tour.modal.getOpeningProperties().height;
cy.get('.hero-welcome h1').invoke('outerHeight').should('eq', openingPropertyHeight);
});
});
});

0 comments on commit 3b1f4d5

Please sign in to comment.