diff options
author | Johann-S <johann.servoire@gmail.com> | 2019-02-06 16:19:04 +0300 |
---|---|---|
committer | XhmikosR <xhmikosr@gmail.com> | 2019-02-06 16:19:04 +0300 |
commit | 3c49467224cc7f37ce56ce9c287de8f169efd7b3 (patch) | |
tree | edc8a8d4a7536169e06947980f3e886113b2b0c7 /js | |
parent | 58470c0ac508df1b03e93faf5c2ff0e11fa3c078 (diff) |
allow to override default toast options (#28186)
Diffstat (limited to 'js')
-rw-r--r-- | js/src/toast.js | 4 | ||||
-rw-r--r-- | js/tests/unit/toast.js | 20 |
2 files changed, 24 insertions, 0 deletions
diff --git a/js/src/toast.js b/js/src/toast.js index 98be2a4187..02596e9dad 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 e6bd6be1ee..2081693ebc 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) + }) }) |