Skip to content

Commit

Permalink
allow to override default toast options (#28186)
Browse files Browse the repository at this point in the history
  • Loading branch information
Johann-S authored and XhmikosR committed Feb 6, 2019
1 parent 58470c0 commit 3c49467
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions js/src/toast.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ class Toast {
return DefaultType
}

static get Default() {
return Default
}

// Public

show() {
Expand Down
20 changes: 20 additions & 0 deletions js/tests/unit/toast.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,4 +236,24 @@ $(function () {
})
.bootstrapToast('show')
})

QUnit.test('should expose default setting to allow to override them', function (assert) {
assert.expect(1)

var defaultDelay = 1000
Toast.Default.delay = defaultDelay

var toastHtml =
'<div class="toast" data-autohide="false" data-animation="false">' +
'<button type="button" class="ml-2 mb-1 close" data-dismiss="toast">' +
'close' +
'</button>' +
'</div>'

var $toast = $(toastHtml)
.bootstrapToast()

var toast = $toast.data('bs.toast')
assert.strictEqual(toast._config.delay, defaultDelay)
})
})

0 comments on commit 3c49467

Please sign in to comment.