From 21a65f181eebc3f2c0cd43fb3383ee3de673745b Mon Sep 17 00:00:00 2001 From: Johann-S Date: Wed, 16 Sep 2015 10:35:29 +0200 Subject: Add throw error for undefined method on plugins --- js/tests/unit/carousel.js | 12 ++++++++++++ js/tests/unit/collapse.js | 12 ++++++++++++ js/tests/unit/dropdown.js | 12 ++++++++++++ js/tests/unit/modal.js | 12 ++++++++++++ js/tests/unit/popover.js | 12 ++++++++++++ js/tests/unit/scrollspy.js | 12 ++++++++++++ js/tests/unit/tab.js | 12 ++++++++++++ js/tests/unit/tooltip.js | 12 ++++++++++++ 8 files changed, 96 insertions(+) (limited to 'js/tests') diff --git a/js/tests/unit/carousel.js b/js/tests/unit/carousel.js index 017bd9bee..d6d0186e1 100644 --- a/js/tests/unit/carousel.js +++ b/js/tests/unit/carousel.js @@ -24,6 +24,18 @@ $(function () { assert.strictEqual($.fn.carousel, undefined, 'carousel was set back to undefined (orig value)') }) + QUnit.test('should throw explicit error on undefined method', function (assert) { + assert.expect(1) + var $el = $('
') + $el.bootstrapCarousel() + try { + $el.bootstrapCarousel('noMethod') + } + catch (err) { + assert.strictEqual(err.message, 'No method named "noMethod"') + } + }) + QUnit.test('should return jquery collection containing the element', function (assert) { assert.expect(2) var $el = $('
') diff --git a/js/tests/unit/collapse.js b/js/tests/unit/collapse.js index 78fafc6c2..4eadc205b 100644 --- a/js/tests/unit/collapse.js +++ b/js/tests/unit/collapse.js @@ -24,6 +24,18 @@ $(function () { assert.strictEqual($.fn.collapse, undefined, 'collapse was set back to undefined (org value)') }) + QUnit.test('should throw explicit error on undefined method', function (assert) { + assert.expect(1) + var $el = $('
') + $el.bootstrapCollapse() + try { + $el.bootstrapCollapse('noMethod') + } + catch (err) { + assert.strictEqual(err.message, 'No method named "noMethod"') + } + }) + QUnit.test('should return jquery collection containing the element', function (assert) { assert.expect(2) var $el = $('
') diff --git a/js/tests/unit/dropdown.js b/js/tests/unit/dropdown.js index 566b50ee7..e6cda58d4 100644 --- a/js/tests/unit/dropdown.js +++ b/js/tests/unit/dropdown.js @@ -24,6 +24,18 @@ $(function () { assert.strictEqual($.fn.dropdown, undefined, 'dropdown was set back to undefined (org value)') }) + QUnit.test('should throw explicit error on undefined method', function (assert) { + assert.expect(1) + var $el = $('
') + $el.bootstrapDropdown() + try { + $el.bootstrapDropdown('noMethod') + } + catch (err) { + assert.strictEqual(err.message, 'No method named "noMethod"') + } + }) + QUnit.test('should return jquery collection containing the element', function (assert) { assert.expect(2) var $el = $('
') diff --git a/js/tests/unit/modal.js b/js/tests/unit/modal.js index 6da09e3c6..50baac8a3 100644 --- a/js/tests/unit/modal.js +++ b/js/tests/unit/modal.js @@ -24,6 +24,18 @@ $(function () { assert.strictEqual($.fn.modal, undefined, 'modal was set back to undefined (orig value)') }) + QUnit.test('should throw explicit error on undefined method', function (assert) { + assert.expect(1) + var $el = $('