aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--js/src/toast.js4
-rw-r--r--js/tests/unit/toast.js20
2 files changed, 24 insertions, 0 deletions
diff --git a/js/src/toast.js b/js/src/toast.js
index 98be2a418..02596e9da 100644
--- a/js/src/toast.js
+++ b/js/src/toast.js
@@ -75,6 +75,10 @@ class Toast {
return DefaultType
}
+ static get Default() {
+ return Default
+ }
+
// Public
show() {
diff --git a/js/tests/unit/toast.js b/js/tests/unit/toast.js
index e6bd6be1e..2081693eb 100644
--- a/js/tests/unit/toast.js
+++ b/js/tests/unit/toast.js
@@ -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)
+ })
})