diff --git a/cypress/integration/example-plugin-headerbuttons.spec.js b/cypress/integration/example-plugin-headerbuttons.spec.js index 79ddf5a8..f23a383a 100644 --- a/cypress/integration/example-plugin-headerbuttons.spec.js +++ b/cypress/integration/example-plugin-headerbuttons.spec.js @@ -122,7 +122,7 @@ describe('Example - Header Button', () => { .invoke('show'); cy.get('.slick-header-column:nth(0)') - .should('have.css', 'width', '140px'); + .should($el => expect(parseInt(`${$el.width()}`, 10)).to.eq(140)); cy.get('.slick-header-columns') .children('.slick-header-column:nth(0)') @@ -130,6 +130,39 @@ describe('Example - Header Button', () => { .should('have.length', 4); }); + it('should click on first "Red Tag Day" header button and expect an alert with that text when clicked', (done) => { + const stub = cy.stub(); + cy.on('window:alert', stub); + + cy.on('window:alert', (text) => { + expect(text).to.eq('command: Red Tag Day'); + done(); + }); + + // header buttons are displayed in inverse mode by default, + // so we need to start at the end + cy.get('.slick-header-columns') + .children('.slick-header-column:nth(0)') + .find('.slick-header-button:nth(3)') + .click(); + }); + + it('should click on second "Write a comment!" header button and expect an alert with that text when clicked', (done) => { + const stub = cy.stub(); + cy.on('window:alert', stub); + + cy.on('window:alert', (text) => { + expect(text).to.eq('Write a comment!'); + done(); + }); + + // header buttons are displayed in inverse mode by default + cy.get('.slick-header-columns') + .children('.slick-header-column:nth(0)') + .find('.slick-header-button:nth(2)') + .click(); + }); + it('should go on the 2nd column "Hover me!" and expect the header button to appear only when doing hover over it', () => { cy.get('.slick-header-columns') .children('.slick-header-column:nth(1)') diff --git a/examples/example-plugin-headerbuttons.html b/examples/example-plugin-headerbuttons.html index d71a34b7..a7f13387 100644 --- a/examples/example-plugin-headerbuttons.html +++ b/examples/example-plugin-headerbuttons.html @@ -44,7 +44,6 @@