Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/js/tests
diff options
context:
space:
mode:
authorXhmikosR <xhmikosr@gmail.com>2020-11-27 12:15:54 +0300
committerXhmikosR <xhmikosr@gmail.com>2021-09-15 15:44:20 +0300
commitd4e162f4acbb9cca46049f8ddb566e194bd95edc (patch)
tree7c988e7420fc40e45834b67110ccb2d6071dab6e /js/tests
parent551f37aff6dedce0fa9c0d2d7c15b7704ebaacf3 (diff)
Skip tests if `attachShadow` is not present
Diffstat (limited to 'js/tests')
-rw-r--r--js/tests/unit/util.js29
1 files changed, 7 insertions, 22 deletions
diff --git a/js/tests/unit/util.js b/js/tests/unit/util.js
index 656477314f..5884676f9c 100644
--- a/js/tests/unit/util.js
+++ b/js/tests/unit/util.js
@@ -3,6 +3,8 @@ $(function () {
window.Util = typeof bootstrap !== 'undefined' ? bootstrap.Util : Util
+ var supportsAttachShadow = document.documentElement.attachShadow
+
QUnit.module('util', {
afterEach: function () {
$('#qunit-fixture').html('')
@@ -143,13 +145,8 @@ $(function () {
assert.true(Util.supportsTransitionEnd())
})
- QUnit.test('Util.findShadowRoot should find the shadow DOM root', function (assert) {
- // Only for newer browsers
- if (!document.documentElement.attachShadow) {
- assert.expect(0)
- return
- }
-
+ // Only for newer browsers
+ QUnit[supportsAttachShadow ? 'test' : 'skip']('Util.findShadowRoot should find the shadow DOM root', function (assert) {
assert.expect(2)
var $div = $('<div id="test"></div>').appendTo($('#qunit-fixture'))
var shadowRoot = $div[0].attachShadow({
@@ -161,23 +158,11 @@ $(function () {
assert.strictEqual(shadowRoot, Util.findShadowRoot(shadowRoot.firstChild))
})
- QUnit.test('Util.findShadowRoot should return null when attachShadow is not available', function (assert) {
+ QUnit[supportsAttachShadow ? 'skip' : 'test']('Util.findShadowRoot should return null when attachShadow is not available', function (assert) {
assert.expect(1)
-
var $div = $('<div id="test"></div>').appendTo($('#qunit-fixture'))
- if (!document.documentElement.attachShadow) {
- assert.strictEqual(Util.findShadowRoot($div[0]), null)
- } else {
- var sandbox = sinon.createSandbox()
-
- sandbox.replace(document.documentElement, 'attachShadow', function () {
- // to avoid empty function
- return $div
- })
-
- assert.strictEqual(Util.findShadowRoot($div[0]), null)
- sandbox.restore()
- }
+
+ assert.strictEqual(Util.findShadowRoot($div[0]), null)
})
QUnit.test('Util.jQueryDetection should detect jQuery', function (assert) {