From 568553394d0a8b34668a75c9839a0f1f426469b2 Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Sun, 6 Oct 2019 21:10:46 +0200 Subject: theme: Switch to docsy theme --- .../assets/vendor/bootstrap/js/tests/README.md | 69 ++ .../assets/vendor/bootstrap/js/tests/index.html | 140 +++ .../vendor/bootstrap/js/tests/karma-bundle.conf.js | 53 + .../assets/vendor/bootstrap/js/tests/karma.conf.js | 76 ++ .../vendor/bootstrap/js/tests/unit/.eslintrc.json | 37 + .../assets/vendor/bootstrap/js/tests/unit/alert.js | 123 +++ .../vendor/bootstrap/js/tests/unit/button.js | 199 ++++ .../vendor/bootstrap/js/tests/unit/carousel.js | 944 ++++++++++++++++ .../vendor/bootstrap/js/tests/unit/collapse.js | 858 +++++++++++++++ .../vendor/bootstrap/js/tests/unit/dropdown.js | 1124 ++++++++++++++++++++ .../assets/vendor/bootstrap/js/tests/unit/modal.js | 657 ++++++++++++ .../vendor/bootstrap/js/tests/unit/popover.js | 471 ++++++++ .../vendor/bootstrap/js/tests/unit/scrollspy.js | 728 +++++++++++++ .../assets/vendor/bootstrap/js/tests/unit/tab.js | 417 ++++++++ .../vendor/bootstrap/js/tests/unit/tooltip.js | 969 +++++++++++++++++ .../assets/vendor/bootstrap/js/tests/unit/util.js | 104 ++ .../vendor/bootstrap/js/tests/visual/alert.html | 58 + .../vendor/bootstrap/js/tests/visual/button.html | 51 + .../vendor/bootstrap/js/tests/visual/carousel.html | 66 ++ .../vendor/bootstrap/js/tests/visual/collapse.html | 78 ++ .../vendor/bootstrap/js/tests/visual/dropdown.html | 212 ++++ .../vendor/bootstrap/js/tests/visual/modal.html | 268 +++++ .../vendor/bootstrap/js/tests/visual/popover.html | 46 + .../bootstrap/js/tests/visual/scrollspy.html | 95 ++ .../vendor/bootstrap/js/tests/visual/tab.html | 234 ++++ .../vendor/bootstrap/js/tests/visual/tooltip.html | 80 ++ 26 files changed, 8157 insertions(+) create mode 100644 themes/docsy/assets/vendor/bootstrap/js/tests/README.md create mode 100644 themes/docsy/assets/vendor/bootstrap/js/tests/index.html create mode 100644 themes/docsy/assets/vendor/bootstrap/js/tests/karma-bundle.conf.js create mode 100644 themes/docsy/assets/vendor/bootstrap/js/tests/karma.conf.js create mode 100644 themes/docsy/assets/vendor/bootstrap/js/tests/unit/.eslintrc.json create mode 100644 themes/docsy/assets/vendor/bootstrap/js/tests/unit/alert.js create mode 100644 themes/docsy/assets/vendor/bootstrap/js/tests/unit/button.js create mode 100644 themes/docsy/assets/vendor/bootstrap/js/tests/unit/carousel.js create mode 100644 themes/docsy/assets/vendor/bootstrap/js/tests/unit/collapse.js create mode 100644 themes/docsy/assets/vendor/bootstrap/js/tests/unit/dropdown.js create mode 100644 themes/docsy/assets/vendor/bootstrap/js/tests/unit/modal.js create mode 100644 themes/docsy/assets/vendor/bootstrap/js/tests/unit/popover.js create mode 100644 themes/docsy/assets/vendor/bootstrap/js/tests/unit/scrollspy.js create mode 100644 themes/docsy/assets/vendor/bootstrap/js/tests/unit/tab.js create mode 100644 themes/docsy/assets/vendor/bootstrap/js/tests/unit/tooltip.js create mode 100644 themes/docsy/assets/vendor/bootstrap/js/tests/unit/util.js create mode 100644 themes/docsy/assets/vendor/bootstrap/js/tests/visual/alert.html create mode 100644 themes/docsy/assets/vendor/bootstrap/js/tests/visual/button.html create mode 100644 themes/docsy/assets/vendor/bootstrap/js/tests/visual/carousel.html create mode 100644 themes/docsy/assets/vendor/bootstrap/js/tests/visual/collapse.html create mode 100644 themes/docsy/assets/vendor/bootstrap/js/tests/visual/dropdown.html create mode 100644 themes/docsy/assets/vendor/bootstrap/js/tests/visual/modal.html create mode 100644 themes/docsy/assets/vendor/bootstrap/js/tests/visual/popover.html create mode 100644 themes/docsy/assets/vendor/bootstrap/js/tests/visual/scrollspy.html create mode 100644 themes/docsy/assets/vendor/bootstrap/js/tests/visual/tab.html create mode 100644 themes/docsy/assets/vendor/bootstrap/js/tests/visual/tooltip.html (limited to 'themes/docsy/assets/vendor/bootstrap/js/tests') diff --git a/themes/docsy/assets/vendor/bootstrap/js/tests/README.md b/themes/docsy/assets/vendor/bootstrap/js/tests/README.md new file mode 100644 index 0000000..1ba3d69 --- /dev/null +++ b/themes/docsy/assets/vendor/bootstrap/js/tests/README.md @@ -0,0 +1,69 @@ +## How does Bootstrap's test suite work? + +Bootstrap uses [QUnit](https://qunitjs.com/) and [Sinon](http://sinonjs.org/). Each plugin has a file dedicated to its tests in `unit/.js`. + +* `unit/` contains the unit test files for each Bootstrap plugin. +* `vendor/` contains third-party testing-related code (QUnit, jQuery and Sinon). +* `visual/` contains "visual" tests which are run interactively in real browsers and require manual verification by humans. + +To run the unit test suite via [Karma](https://karma-runner.github.io/), run `npm run js-test`. + +To run the unit test suite via a real web browser, open `index.html` in the browser. + + +## How do I add a new unit test? + +1. Locate and open the file dedicated to the plugin which you need to add tests to (`unit/.js`). +2. Review the [QUnit API Documentation](https://api.qunitjs.com/) and use the existing tests as references for how to structure your new tests. +3. Write the necessary unit test(s) for the new or revised functionality. +4. Run `npm run js-test` to see the results of your newly-added test(s). + +**Note:** Your new unit tests should fail before your changes are applied to the plugin, and should pass after your changes are applied to the plugin. + +## What should a unit test look like? + +* Each test should have a unique name clearly stating what unit is being tested. +* Each test should test only one unit per test, although one test can include several assertions. Create multiple tests for multiple units of functionality. +* Each test should begin with [`assert.expect`](https://api.qunitjs.com/assert/expect/) to ensure that the expected assertions are run. +* Each test should follow the project's [JavaScript Code Guidelines](https://github.com/twbs/bootstrap/blob/master/CONTRIBUTING.md#js) + +## Code coverage + +Currently we're aiming for at least 80% test coverage for our code. To ensure your changes meet or exceed this limit, run `npm run js-compile && npm run js-test` and open the file in `js/coverage/lcov-report/index.html` to see the code coverage for each plugin. See more details when you select a plugin and ensure your change is fully covered by unit tests. + +### Example tests + +```js +// Synchronous test +QUnit.test('should describe the unit being tested', function (assert) { + assert.expect(1) + var templateHTML = '
' + + '×' + + '

Template necessary for the test.

' + + '
' + var $alert = $(templateHTML).appendTo('#qunit-fixture').bootstrapAlert() + + $alert.find('.close').trigger('click') + + // Make assertion + assert.strictEqual($alert.hasClass('show'), false, 'remove .show class on .close click') +}) + +// Asynchronous test +QUnit.test('should describe the unit being tested', function (assert) { + assert.expect(2) + var done = assert.async() + + var $tooltip = $('
').bootstrapTooltip() + var tooltipInstance = $tooltip.data('bs.tooltip') + var spyShow = sinon.spy(tooltipInstance, 'show') + + $tooltip.appendTo('#qunit-fixture') + .on('shown.bs.tooltip', function () { + assert.ok(true, '"shown" event was fired after calling "show"') + assert.ok(spyShow.called, 'show called') + done() + }) + .bootstrapTooltip('show') +}) +``` diff --git a/themes/docsy/assets/vendor/bootstrap/js/tests/index.html b/themes/docsy/assets/vendor/bootstrap/js/tests/index.html new file mode 100644 index 0000000..95d72d8 --- /dev/null +++ b/themes/docsy/assets/vendor/bootstrap/js/tests/index.html @@ -0,0 +1,140 @@ + + + + + + Bootstrap Plugin Test Suite + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+ + diff --git a/themes/docsy/assets/vendor/bootstrap/js/tests/karma-bundle.conf.js b/themes/docsy/assets/vendor/bootstrap/js/tests/karma-bundle.conf.js new file mode 100644 index 0000000..50c500f --- /dev/null +++ b/themes/docsy/assets/vendor/bootstrap/js/tests/karma-bundle.conf.js @@ -0,0 +1,53 @@ +/* eslint-env node */ +/* eslint no-process-env: 0 */ + +module.exports = (config) => { + const jqueryFile = process.env.USE_OLD_JQUERY ? 'https://code.jquery.com/jquery-1.9.1.min.js' : 'site/docs/4.1/assets/js/vendor/jquery-slim.min.js' + + config.set({ + basePath: '../..', + frameworks: ['qunit', 'sinon', 'detectBrowsers'], + plugins: [ + 'karma-chrome-launcher', + 'karma-firefox-launcher', + 'karma-qunit', + 'karma-sinon', + 'karma-detect-browsers' + ], + // list of files / patterns to load in the browser + files: [ + jqueryFile, + 'site/docs/4.1/assets/js/vendor/popper.min.js', + 'dist/js/bootstrap.js', + 'js/tests/unit/*.js' + ], + reporters: ['dots'], + port: 9876, + colors: true, + // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG + logLevel: config.LOG_ERROR || config.LOG_WARN, + autoWatch: false, + customLaunchers: { + FirefoxHeadless: { + base: 'Firefox', + flags: ['-headless'] + } + }, + singleRun: true, + concurrency: Infinity, + detectBrowsers: { + usePhantomJS: false, + postDetection(availableBrowser) { + if (typeof process.env.TRAVIS_JOB_ID !== 'undefined' || availableBrowser.includes('Chrome')) { + return ['ChromeHeadless'] + } + + if (availableBrowser.includes('Firefox')) { + return ['FirefoxHeadless'] + } + + throw new Error('Please install Firefox or Chrome') + } + } + }) +} diff --git a/themes/docsy/assets/vendor/bootstrap/js/tests/karma.conf.js b/themes/docsy/assets/vendor/bootstrap/js/tests/karma.conf.js new file mode 100644 index 0000000..397f8b8 --- /dev/null +++ b/themes/docsy/assets/vendor/bootstrap/js/tests/karma.conf.js @@ -0,0 +1,76 @@ +/* eslint-env node */ +/* eslint no-process-env: 0 */ +const path = require('path') +const jsCoveragePath = path.resolve(__dirname, '../coverage') + +module.exports = (config) => { + const jqueryFile = process.env.USE_OLD_JQUERY ? 'https://code.jquery.com/jquery-1.9.1.min.js' : 'site/docs/4.1/assets/js/vendor/jquery-slim.min.js' + + config.set({ + basePath: '../..', + frameworks: ['qunit', 'sinon', 'detectBrowsers'], + plugins: [ + 'karma-chrome-launcher', + 'karma-firefox-launcher', + 'karma-qunit', + 'karma-sinon', + 'karma-detect-browsers', + 'karma-coverage-istanbul-reporter' + ], + // list of files / patterns to load in the browser + files: [ + jqueryFile, + 'site/docs/4.1/assets/js/vendor/popper.min.js', + 'js/coverage/dist/util.js', + 'js/coverage/dist/tooltip.js', + 'js/coverage/dist/!(util|index|tooltip).js', // include all of our js/dist files except util.js, index.js and tooltip.js + 'js/tests/unit/*.js' + ], + reporters: ['dots', 'coverage-istanbul'], + port: 9876, + colors: true, + // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG + logLevel: config.LOG_ERROR || config.LOG_WARN, + autoWatch: false, + customLaunchers: { + FirefoxHeadless: { + base: 'Firefox', + flags: ['-headless'] + } + }, + singleRun: true, + concurrency: Infinity, + detectBrowsers: { + usePhantomJS: false, + postDetection(availableBrowser) { + if (typeof process.env.TRAVIS_JOB_ID !== 'undefined' || availableBrowser.includes('Chrome')) { + return ['ChromeHeadless'] + } + + if (availableBrowser.includes('Firefox')) { + return ['FirefoxHeadless'] + } + + throw new Error('Please install Firefox or Chrome') + } + }, + coverageIstanbulReporter: { + dir: jsCoveragePath, + reports: ['lcov', 'text-summary'], + thresholds: { + emitWarning: false, + global: { + statements: 90, + branches: 84, + functions: 87, + lines: 90 + } + } + }, + client: { + qunit: { + showUI: true + } + } + }) +} diff --git a/themes/docsy/assets/vendor/bootstrap/js/tests/unit/.eslintrc.json b/themes/docsy/assets/vendor/bootstrap/js/tests/unit/.eslintrc.json new file mode 100644 index 0000000..0896f40 --- /dev/null +++ b/themes/docsy/assets/vendor/bootstrap/js/tests/unit/.eslintrc.json @@ -0,0 +1,37 @@ +{ + "env": { + "es6": false, + "jquery": true, + "qunit": true + }, + "globals": { + "bootstrap": false, + "sinon": false, + "Util": false, + "Alert": false, + "Button": false + }, + "parserOptions": { + "ecmaVersion": 5, + "sourceType": "script" + }, + "extends": "../../../.eslintrc.json", + "rules": { + "no-console": "off", + // Best Practices + "consistent-return": "off", + "no-magic-numbers": "off", + "vars-on-top": "off", + + // Stylistic Issues + "func-style": "off", + "spaced-comment": "off", + + // ECMAScript 6 + "no-var": "off", + "object-shorthand": "off", + "prefer-arrow-callback": "off", + "prefer-template": "off", + "prefer-rest-params": "off" + } +} diff --git a/themes/docsy/assets/vendor/bootstrap/js/tests/unit/alert.js b/themes/docsy/assets/vendor/bootstrap/js/tests/unit/alert.js new file mode 100644 index 0000000..65a8f9e --- /dev/null +++ b/themes/docsy/assets/vendor/bootstrap/js/tests/unit/alert.js @@ -0,0 +1,123 @@ +$(function () { + 'use strict' + + QUnit.module('alert plugin') + + QUnit.test('should be defined on jquery object', function (assert) { + assert.expect(1) + assert.ok($(document.body).alert, 'alert method is defined') + }) + + QUnit.module('alert', { + beforeEach: function () { + // Run all tests in noConflict mode -- it's the only way to ensure that the plugin works in noConflict mode + $.fn.bootstrapAlert = $.fn.alert.noConflict() + }, + afterEach: function () { + $.fn.alert = $.fn.bootstrapAlert + delete $.fn.bootstrapAlert + $('#qunit-fixture').html('') + } + }) + + QUnit.test('should provide no conflict', function (assert) { + assert.expect(1) + assert.strictEqual(typeof $.fn.alert, 'undefined', 'alert was set back to undefined (org value)') + }) + + QUnit.test('should return jquery collection containing the element', function (assert) { + assert.expect(2) + var $el = $('
') + var $alert = $el.bootstrapAlert() + assert.ok($alert instanceof $, 'returns jquery collection') + assert.strictEqual($alert[0], $el[0], 'collection contains element') + }) + + QUnit.test('should fade element out on clicking .close', function (assert) { + assert.expect(1) + var alertHTML = '
' + + '×' + + '

Holy guacamole! Best check yo self, you\'re not looking too good.

' + + '
' + + var $alert = $(alertHTML).bootstrapAlert().appendTo($('#qunit-fixture')) + + $alert.find('.close').trigger('click') + + assert.strictEqual($alert.hasClass('show'), false, 'remove .show class on .close click') + }) + + QUnit.test('should remove element when clicking .close', function (assert) { + assert.expect(2) + var done = assert.async() + var alertHTML = '
' + + '×' + + '

Holy guacamole! Best check yo self, you\'re not looking too good.

' + + '
' + var $alert = $(alertHTML).appendTo('#qunit-fixture').bootstrapAlert() + + assert.notEqual($('#qunit-fixture').find('.alert').length, 0, 'element added to dom') + + $alert + .one('closed.bs.alert', function () { + assert.strictEqual($('#qunit-fixture').find('.alert').length, 0, 'element removed from dom') + done() + }) + .find('.close') + .trigger('click') + }) + + QUnit.test('should not fire closed when close is prevented', function (assert) { + assert.expect(1) + var done = assert.async() + $('
') + .on('close.bs.alert', function (e) { + e.preventDefault() + assert.ok(true, 'close event fired') + done() + }) + .on('closed.bs.alert', function () { + assert.ok(false, 'closed event fired') + }) + .bootstrapAlert('close') + }) + + QUnit.test('close should use internal _element if no element provided', function (assert) { + assert.expect(1) + + var done = assert.async() + var $el = $('
') + var $alert = $el.bootstrapAlert() + var alertInstance = $alert.data('bs.alert') + + $alert.one('closed.bs.alert', function () { + assert.ok('alert closed') + done() + }) + + alertInstance.close() + }) + + QUnit.test('dispose should remove data and the element', function (assert) { + assert.expect(2) + + var $el = $('
') + var $alert = $el.bootstrapAlert() + + assert.ok(typeof $alert.data('bs.alert') !== 'undefined') + + $alert.data('bs.alert').dispose() + + assert.ok(typeof $alert.data('bs.button') === 'undefined') + }) + + QUnit.test('should return alert version', function (assert) { + assert.expect(1) + + if (typeof Alert !== 'undefined') { + assert.ok(typeof Alert.VERSION === 'string') + } else { + assert.notOk() + } + }) +}) diff --git a/themes/docsy/assets/vendor/bootstrap/js/tests/unit/button.js b/themes/docsy/assets/vendor/bootstrap/js/tests/unit/button.js new file mode 100644 index 0000000..9576dd2 --- /dev/null +++ b/themes/docsy/assets/vendor/bootstrap/js/tests/unit/button.js @@ -0,0 +1,199 @@ +$(function () { + 'use strict' + + QUnit.module('button plugin') + + QUnit.test('should be defined on jquery object', function (assert) { + assert.expect(1) + assert.ok($(document.body).button, 'button method is defined') + }) + + QUnit.module('button', { + beforeEach: function () { + // Run all tests in noConflict mode -- it's the only way to ensure that the plugin works in noConflict mode + $.fn.bootstrapButton = $.fn.button.noConflict() + }, + afterEach: function () { + $.fn.button = $.fn.bootstrapButton + delete $.fn.bootstrapButton + $('#qunit-fixture').html('') + } + }) + + QUnit.test('should provide no conflict', function (assert) { + assert.expect(1) + assert.strictEqual(typeof $.fn.button, 'undefined', 'button was set back to undefined (org value)') + }) + + QUnit.test('should return jquery collection containing the element', function (assert) { + assert.expect(2) + var $el = $('
') + var $button = $el.bootstrapButton() + assert.ok($button instanceof $, 'returns jquery collection') + assert.strictEqual($button[0], $el[0], 'collection contains element') + }) + + QUnit.test('should toggle active', function (assert) { + assert.expect(2) + var $btn = $('') + assert.ok(!$btn.hasClass('active'), 'btn does not have active class') + $btn.bootstrapButton('toggle') + assert.ok($btn.hasClass('active'), 'btn has class active') + }) + + QUnit.test('should toggle active when btn children are clicked', function (assert) { + assert.expect(2) + var $btn = $('') + var $inner = $('') + $btn + .append($inner) + .appendTo('#qunit-fixture') + assert.ok(!$btn.hasClass('active'), 'btn does not have active class') + $inner.trigger('click') + assert.ok($btn.hasClass('active'), 'btn has class active') + }) + + QUnit.test('should toggle aria-pressed', function (assert) { + assert.expect(2) + var $btn = $('') + assert.strictEqual($btn.attr('aria-pressed'), 'false', 'btn aria-pressed state is false') + $btn.bootstrapButton('toggle') + assert.strictEqual($btn.attr('aria-pressed'), 'true', 'btn aria-pressed state is true') + }) + + QUnit.test('should toggle aria-pressed on buttons with container', function (assert) { + assert.expect(1) + var groupHTML = '
' + + '' + + '' + + '
' + $('#qunit-fixture').append(groupHTML) + $('#btn1').bootstrapButton('toggle') + assert.strictEqual($('#btn1').attr('aria-pressed'), 'true') + }) + + QUnit.test('should toggle aria-pressed when btn children are clicked', function (assert) { + assert.expect(2) + var $btn = $('') + var $inner = $('') + $btn + .append($inner) + .appendTo('#qunit-fixture') + assert.strictEqual($btn.attr('aria-pressed'), 'false', 'btn aria-pressed state is false') + $inner.trigger('click') + assert.strictEqual($btn.attr('aria-pressed'), 'true', 'btn aria-pressed state is true') + }) + + QUnit.test('should trigger input change event when toggled button has input field', function (assert) { + assert.expect(1) + var done = assert.async() + + var groupHTML = '
' + + '' + + '
' + var $group = $(groupHTML).appendTo('#qunit-fixture') + + $group.find('input').on('change', function (e) { + e.preventDefault() + assert.ok(true, 'change event fired') + done() + }) + + $group.find('label').trigger('click') + }) + + QUnit.test('should check for closest matching toggle', function (assert) { + assert.expect(12) + var groupHTML = '
' + + '' + + '' + + '' + + '
' + var $group = $(groupHTML).appendTo('#qunit-fixture') + + var $btn1 = $group.children().eq(0) + var $btn2 = $group.children().eq(1) + + assert.ok($btn1.hasClass('active'), 'btn1 has active class') + assert.ok($btn1.find('input').prop('checked'), 'btn1 is checked') + assert.ok(!$btn2.hasClass('active'), 'btn2 does not have active class') + assert.ok(!$btn2.find('input').prop('checked'), 'btn2 is not checked') + $btn2.find('input').trigger('click') + assert.ok(!$btn1.hasClass('active'), 'btn1 does not have active class') + assert.ok(!$btn1.find('input').prop('checked'), 'btn1 is not checked') + assert.ok($btn2.hasClass('active'), 'btn2 has active class') + assert.ok($btn2.find('input').prop('checked'), 'btn2 is checked') + + $btn2.find('input').trigger('click') // Clicking an already checked radio should not un-check it + assert.ok(!$btn1.hasClass('active'), 'btn1 does not have active class') + assert.ok(!$btn1.find('input').prop('checked'), 'btn1 is not checked') + assert.ok($btn2.hasClass('active'), 'btn2 has active class') + assert.ok($btn2.find('input').prop('checked'), 'btn2 is checked') + }) + + QUnit.test('should not add aria-pressed on labels for radio/checkbox inputs in a data-toggle="buttons" group', function (assert) { + assert.expect(2) + var groupHTML = '
' + + '' + + '' + + '
' + var $group = $(groupHTML).appendTo('#qunit-fixture') + + var $btn1 = $group.children().eq(0) + var $btn2 = $group.children().eq(1) + + $btn1.find('input').trigger('click') + assert.ok($btn1.is(':not([aria-pressed])'), 'label for nested checkbox input has not been given an aria-pressed attribute') + + $btn2.find('input').trigger('click') + assert.ok($btn2.is(':not([aria-pressed])'), 'label for nested radio input has not been given an aria-pressed attribute') + }) + + QUnit.test('should handle disabled attribute on non-button elements', function (assert) { + assert.expect(2) + var groupHTML = '
' + + '' + + '
' + var $group = $(groupHTML).appendTo('#qunit-fixture') + + var $btn = $group.children().eq(0) + var $input = $btn.children().eq(0) + + $btn.trigger('click') + assert.ok($btn.is(':not(.active)'), 'button did not become active') + assert.ok(!$input.is(':checked'), 'checkbox did not get checked') + }) + + QUnit.test('dispose should remove data and the element', function (assert) { + assert.expect(2) + + var $el = $('
') + var $button = $el.bootstrapButton() + + assert.ok(typeof $button.data('bs.button') !== 'undefined') + + $button.data('bs.button').dispose() + + assert.ok(typeof $button.data('bs.button') === 'undefined') + }) + + QUnit.test('should return button version', function (assert) { + assert.expect(1) + + if (typeof Button !== 'undefined') { + assert.ok(typeof Button.VERSION === 'string') + } else { + assert.notOk() + } + }) +}) diff --git a/themes/docsy/assets/vendor/bootstrap/js/tests/unit/carousel.js b/themes/docsy/assets/vendor/bootstrap/js/tests/unit/carousel.js new file mode 100644 index 0000000..baabcf4 --- /dev/null +++ b/themes/docsy/assets/vendor/bootstrap/js/tests/unit/carousel.js @@ -0,0 +1,944 @@ +$(function () { + 'use strict' + + QUnit.module('carousel plugin') + + QUnit.test('should be defined on jQuery object', function (assert) { + assert.expect(1) + assert.ok($(document.body).carousel, 'carousel method is defined') + }) + + QUnit.module('carousel', { + beforeEach: function () { + // Run all tests in noConflict mode -- it's the only way to ensure that the plugin works in noConflict mode + $.fn.bootstrapCarousel = $.fn.carousel.noConflict() + }, + afterEach: function () { + $.fn.carousel = $.fn.bootstrapCarousel + delete $.fn.bootstrapCarousel + $('#qunit-fixture').html('') + } + }) + + QUnit.test('should provide no conflict', function (assert) { + assert.expect(1) + assert.strictEqual(typeof $.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 = $('
') + var $carousel = $el.bootstrapCarousel() + assert.ok($carousel instanceof $, 'returns jquery collection') + assert.strictEqual($carousel[0], $el[0], 'collection contains element') + }) + + QUnit.test('should type check config options', function (assert) { + assert.expect(2) + + var message + var expectedMessage = 'CAROUSEL: Option "interval" provided type "string" but expected type "(number|boolean)".' + var config = { + interval: 'fat sux' + } + + try { + $('
').bootstrapCarousel(config) + } catch (err) { + message = err.message + } + + assert.ok(message === expectedMessage, 'correct error message') + + config = { + keyboard: document.createElement('div') + } + expectedMessage = 'CAROUSEL: Option "keyboard" provided type "element" but expected type "boolean".' + + try { + $('
').bootstrapCarousel(config) + } catch (err) { + message = err.message + } + + assert.ok(message === expectedMessage, 'correct error message') + }) + + QUnit.test('should not fire slid when slide is prevented', function (assert) { + assert.expect(1) + var done = assert.async() + $('