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
diff options
context:
space:
mode:
authorJohann-S <johann.servoire@gmail.com>2018-03-29 23:16:56 +0300
committerMark Otto <markd.otto@gmail.com>2018-03-30 07:21:31 +0300
commitfd57d371f84e2aeac35d5701ae3ad357ad6456b2 (patch)
treee0772bb5460303622156d4024f9cb652234d5109 /js
parent9cdb7a83010dbdc29d1910bda94ca50711168a48 (diff)
fix bundle and run test against it
Diffstat (limited to 'js')
-rw-r--r--js/tests/karma-bundle.conf.js53
-rw-r--r--js/tests/unit/.eslintrc.json3
-rw-r--r--js/tests/unit/util.js2
3 files changed, 57 insertions, 1 deletions
diff --git a/js/tests/karma-bundle.conf.js b/js/tests/karma-bundle.conf.js
new file mode 100644
index 0000000000..74d4c77a6d
--- /dev/null
+++ b/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' : '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,
+ '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/js/tests/unit/.eslintrc.json b/js/tests/unit/.eslintrc.json
index 02dc9c9a4e..f03726543b 100644
--- a/js/tests/unit/.eslintrc.json
+++ b/js/tests/unit/.eslintrc.json
@@ -6,7 +6,8 @@
},
"globals": {
"sinon": false,
- "Util": false
+ "Util": false,
+ "bootstrap": false
},
"parserOptions": {
"ecmaVersion": 5,
diff --git a/js/tests/unit/util.js b/js/tests/unit/util.js
index 9a25a52861..f4303ea15b 100644
--- a/js/tests/unit/util.js
+++ b/js/tests/unit/util.js
@@ -1,6 +1,8 @@
$(function () {
'use strict'
+ window.Util = typeof bootstrap !== 'undefined' ? bootstrap.Util : Util
+
QUnit.module('util')
QUnit.test('Util.getSelectorFromElement should return the correct element', function (assert) {