Skip to content

Commit

Permalink
feat: make close button updatable (#2018)
Browse files Browse the repository at this point in the history
  • Loading branch information
limonte committed Jul 14, 2020
1 parent 415c6c6 commit 911394f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
5 changes: 4 additions & 1 deletion cypress/integration/methods/update.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ describe('update()', () => {
showConfirmButton: false,
showCancelButton: true,
cancelButtonText: 'New cancel button text',
imageUrl: '/assets/swal2-logo.png'
imageUrl: '/assets/swal2-logo.png',
showCloseButton: true,
})

expect(Swal.getTitle().textContent).to.equal('New title')
Expand All @@ -40,6 +41,8 @@ describe('update()', () => {
expect(isVisible(Swal.getConfirmButton())).to.be.false
expect(isVisible(Swal.getCancelButton())).to.be.true
expect(Swal.getCancelButton().textContent).to.equal('New cancel button text')

expect(isVisible(Swal.getCloseButton())).to.be.true
})

it('update customClass', () => {
Expand Down
3 changes: 3 additions & 0 deletions src/utils/params.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ export const updatableParams = [
'cancelButtonColor',
'buttonsStyling',
'reverseButtons',
'showCloseButton',
'closeButtonHtml',
'closeButtonAriaLabel',
'imageUrl',
'imageWidth',
'imageHeight',
Expand Down
5 changes: 4 additions & 1 deletion test/qunit/methods/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ QUnit.test('update() method', (assert) => {
showConfirmButton: false,
showCancelButton: true,
cancelButtonText: 'New cancel button text',
imageUrl: '/assets/swal2-logo.png'
imageUrl: '/assets/swal2-logo.png',
showCloseButton: true,
})

assert.equal(Swal.getTitle().textContent, 'New title')
Expand All @@ -40,6 +41,8 @@ QUnit.test('update() method', (assert) => {
assert.notOk(isVisible(Swal.getConfirmButton()))
assert.ok(isVisible(Swal.getCancelButton()))
assert.equal(Swal.getCancelButton().textContent, 'New cancel button text')

assert.ok(isVisible(Swal.getCloseButton()))
})

QUnit.test('update customClass', (assert) => {
Expand Down

0 comments on commit 911394f

Please sign in to comment.