diff options
author | Mark Otto <markdotto@gmail.com> | 2016-11-26 01:59:28 +0300 |
---|---|---|
committer | Mark Otto <markdotto@gmail.com> | 2016-11-26 01:59:28 +0300 |
commit | 432fe74c3182f3be258320fec31b0a8c5d70848d (patch) | |
tree | cfff52601575c2bc32e50ee5875ffe6f6f0f1b98 /js/tests/unit | |
parent | b1b1f30cbd0f4f620047dc158cf91e328eeecc6b (diff) | |
parent | c2616fb74e6bdc0cd46a5678a2c5cffcbe422106 (diff) |
Merge branch 'eslint' of https://github.com/bardiharborow/bootstrap into bardiharborow-eslint
Diffstat (limited to 'js/tests/unit')
-rw-r--r-- | js/tests/unit/alert.js | 2 | ||||
-rw-r--r-- | js/tests/unit/button.js | 2 | ||||
-rw-r--r-- | js/tests/unit/carousel.js | 2 | ||||
-rw-r--r-- | js/tests/unit/collapse.js | 14 | ||||
-rw-r--r-- | js/tests/unit/dropdown.js | 2 | ||||
-rw-r--r-- | js/tests/unit/modal.js | 4 | ||||
-rw-r--r-- | js/tests/unit/phantom.js | 31 | ||||
-rw-r--r-- | js/tests/unit/popover.js | 2 | ||||
-rw-r--r-- | js/tests/unit/scrollspy.js | 14 | ||||
-rw-r--r-- | js/tests/unit/tab.js | 2 | ||||
-rw-r--r-- | js/tests/unit/tooltip.js | 20 |
11 files changed, 34 insertions, 61 deletions
diff --git a/js/tests/unit/alert.js b/js/tests/unit/alert.js index 3128e20be3..9548c3318c 100644 --- a/js/tests/unit/alert.js +++ b/js/tests/unit/alert.js @@ -1,5 +1,5 @@ $(function () { - 'use strict'; + 'use strict' QUnit.module('alert plugin') diff --git a/js/tests/unit/button.js b/js/tests/unit/button.js index 5648506cf5..7fd86e13a5 100644 --- a/js/tests/unit/button.js +++ b/js/tests/unit/button.js @@ -1,5 +1,5 @@ $(function () { - 'use strict'; + 'use strict' QUnit.module('button plugin') diff --git a/js/tests/unit/carousel.js b/js/tests/unit/carousel.js index d6d0186e15..033ccfd6c5 100644 --- a/js/tests/unit/carousel.js +++ b/js/tests/unit/carousel.js @@ -1,5 +1,5 @@ $(function () { - 'use strict'; + 'use strict' QUnit.module('carousel plugin') diff --git a/js/tests/unit/collapse.js b/js/tests/unit/collapse.js index 25bb7772e2..7db69e2cf8 100644 --- a/js/tests/unit/collapse.js +++ b/js/tests/unit/collapse.js @@ -1,5 +1,5 @@ $(function () { - 'use strict'; + 'use strict' QUnit.module('collapse plugin') @@ -56,14 +56,14 @@ $(function () { assert.expect(2) var html = [ '<div class="panel-group" id="accordion1">', - '<div class="panel">', - '<div id="collapse1" class="collapse"/>', - '</div>', + '<div class="panel">', + '<div id="collapse1" class="collapse"/>', + '</div>', '</div>', '<div class="panel-group" id="accordion2">', - '<div class="panel">', - '<div id="collapse2" class="collapse active"/>', - '</div>', + '<div class="panel">', + '<div id="collapse2" class="collapse active"/>', + '</div>', '</div>' ].join('') $(html).appendTo('#qunit-fixture') diff --git a/js/tests/unit/dropdown.js b/js/tests/unit/dropdown.js index becd1d0898..7e8ecae4ea 100644 --- a/js/tests/unit/dropdown.js +++ b/js/tests/unit/dropdown.js @@ -1,5 +1,5 @@ $(function () { - 'use strict'; + 'use strict' QUnit.module('dropdowns plugin') diff --git a/js/tests/unit/modal.js b/js/tests/unit/modal.js index f5157d4544..2d5911af3b 100644 --- a/js/tests/unit/modal.js +++ b/js/tests/unit/modal.js @@ -1,5 +1,5 @@ $(function () { - 'use strict'; + 'use strict' QUnit.module('modal plugin') @@ -374,7 +374,7 @@ $(function () { var paddingRight = parseInt($(document.body).css('padding-right'), 10) assert.strictEqual(isNaN(paddingRight), false) assert.strictEqual(paddingRight !== 0, true) - $(document.body).css('padding-right', ''); // Because test case "should ignore other inline styles when trying to restore body padding after closing" fail if not + $(document.body).css('padding-right', '') // Because test case "should ignore other inline styles when trying to restore body padding after closing" fail if not done() }) .bootstrapModal('show') diff --git a/js/tests/unit/phantom.js b/js/tests/unit/phantom.js index 525aea0024..eea7486a43 100644 --- a/js/tests/unit/phantom.js +++ b/js/tests/unit/phantom.js @@ -7,7 +7,7 @@ */ (function () { - 'use strict'; + 'use strict' // Don't re-order tests. QUnit.config.reorder = false @@ -70,32 +70,3 @@ }) }()) - - -// bind polyfill -// shoutout mdn: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind#Polyfill - -if (!Function.prototype.bind) { - Function.prototype.bind = function (oThis) { - if (typeof this !== 'function') { - // closest thing possible to the ECMAScript 5 - // internal IsCallable function - throw new TypeError('Function.prototype.bind - what is trying to be bound is not callable'); - } - - var aArgs = Array.prototype.slice.call(arguments, 1) - var fToBind = this - var FNOP = function () {} - var fBound = function () { - return fToBind.apply(this instanceof FNOP ? this : oThis, aArgs.concat(Array.prototype.slice.call(arguments))) - } - - if (this.prototype) { - // native functions don't have a prototype - FNOP.prototype = this.prototype - } - fBound.prototype = new FNOP() - - return fBound - } -} diff --git a/js/tests/unit/popover.js b/js/tests/unit/popover.js index 6e47222f14..4667d9e9a7 100644 --- a/js/tests/unit/popover.js +++ b/js/tests/unit/popover.js @@ -1,5 +1,5 @@ $(function () { - 'use strict'; + 'use strict' QUnit.module('popover plugin') diff --git a/js/tests/unit/scrollspy.js b/js/tests/unit/scrollspy.js index 97ddd16ece..a349b5337e 100644 --- a/js/tests/unit/scrollspy.js +++ b/js/tests/unit/scrollspy.js @@ -1,5 +1,5 @@ $(function () { - 'use strict'; + 'use strict' QUnit.module('scrollspy plugin') @@ -231,8 +231,8 @@ $(function () { .appendTo('#qunit-fixture') .bootstrapScrollspy({ offset: 0, target: '#navigation' }) - !function testActiveElements() { - if (++times > 3) return done() + function testActiveElements() { + if (++times > 3) { return done() } $content.one('scroll', function () { assert.ok($('#a-1').hasClass('active'), 'nav item for outer element has "active" class') @@ -241,7 +241,9 @@ $(function () { }) $content.scrollTop($content.scrollTop() + 10) - }() + } + + testActiveElements() }) QUnit.test('should clear selection if above the first section', function (assert) { @@ -399,8 +401,8 @@ $(function () { $navbar.appendTo('#qunit-fixture') $content.appendTo('#qunit-fixture') - if (type === 'js') $content.bootstrapScrollspy({ target: '.navbar', offset: 0, method: 'position' }) - else if (type === 'data') $(window).trigger('load') + if (type === 'js') { $content.bootstrapScrollspy({ target: '.navbar', offset: 0, method: 'position' }) } + else if (type === 'data') { $(window).trigger('load') } var $target = $('#div-' + type + 'm-2') var scrollspy = $content.data('bs.scrollspy') diff --git a/js/tests/unit/tab.js b/js/tests/unit/tab.js index 1f990f0f33..8b6f31f83e 100644 --- a/js/tests/unit/tab.js +++ b/js/tests/unit/tab.js @@ -1,5 +1,5 @@ $(function () { - 'use strict'; + 'use strict' QUnit.module('tabs plugin') diff --git a/js/tests/unit/tooltip.js b/js/tests/unit/tooltip.js index 97c5855cb0..ea95118a44 100644 --- a/js/tests/unit/tooltip.js +++ b/js/tests/unit/tooltip.js @@ -1,5 +1,5 @@ $(function () { - 'use strict'; + 'use strict' QUnit.module('tooltip plugin') @@ -382,7 +382,7 @@ $(function () { var $tooltip = $($target.data('bs.tooltip').tip) // this is some dumb hack stuff because sub pixels in firefox - var top = Math.round($target.offset().top + ($target[0].offsetHeight / 2) - ($tooltip[0].offsetHeight / 2)) + var top = Math.round($target.offset().top + $target[0].offsetHeight / 2 - $tooltip[0].offsetHeight / 2) var top2 = Math.round($tooltip.offset().top) var topDiff = top - top2 assert.ok(topDiff <= 1 && topDiff >= -1) @@ -540,7 +540,7 @@ $(function () { var $tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"/>') .appendTo('#qunit-fixture') - .bootstrapTooltip({ delay: { show: 0, hide: 150 }}) + .bootstrapTooltip({ delay: { show: 0, hide: 150 } }) setTimeout(function () { assert.ok($('.tooltip').is('.fade.active'), '1ms: tooltip faded active') @@ -587,7 +587,7 @@ $(function () { var $tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"/>') .appendTo('#qunit-fixture') - .bootstrapTooltip({ delay: { show: 150, hide: 0 }}) + .bootstrapTooltip({ delay: { show: 150, hide: 0 } }) setTimeout(function () { assert.ok(!$('.tooltip').is('.fade.active'), '100ms: tooltip not faded active') @@ -608,7 +608,7 @@ $(function () { var $tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"/>') .appendTo('#qunit-fixture') - .bootstrapTooltip({ delay: { show: 0, hide: 150 }}) + .bootstrapTooltip({ delay: { show: 0, hide: 150 } }) setTimeout(function () { assert.ok($($tooltip.data('bs.tooltip').tip).is('.fade.active'), '1ms: tooltip faded active') @@ -723,10 +723,10 @@ $(function () { $('#tt-outer').trigger('mouseleave') assert.strictEqual(currentUid, $('#tt-content').text()) - assert.ok(obj._hoverState == 'out', 'the tooltip hoverState should be set to "out"') + assert.ok(obj._hoverState === 'out', 'the tooltip hoverState should be set to "out"') $('#tt-outer').trigger('mouseenter') - assert.ok(obj._hoverState == 'active', 'the tooltip hoverState should be set to "active"') + assert.ok(obj._hoverState === 'active', 'the tooltip hoverState should be set to "active"') assert.strictEqual(currentUid, $('#tt-content').text()) }) @@ -788,7 +788,7 @@ $(function () { var tooltip = $el.data('bs.tooltip') var $tooltip = $(tooltip.getTipElement()) - function showingTooltip() { return $tooltip.hasClass('active') || tooltip._hoverState == 'active' } + function showingTooltip() { return $tooltip.hasClass('active') || tooltip._hoverState === 'active' } var tests = [ ['mouseenter', 'mouseleave'], @@ -812,8 +812,8 @@ $(function () { $.each(tests, function (idx, triggers) { for (var i = 0, len = triggers.length; i < len; i++) { - $el.trigger(triggers[i]); - assert.equal(i < (len - 1), showingTooltip()) + $el.trigger(triggers[i]) + assert.equal(i < len - 1, showingTooltip()) } }) }) |