From af60644d2f0ae56740ce68d63e81ad0c1b46e912 Mon Sep 17 00:00:00 2001 From: Johann-S Date: Thu, 13 Dec 2018 10:54:54 +0100 Subject: [PATCH] integration test to be sure bootstrap can be bundled --- js/tests/integration/bundle.js | 8 ++++ js/tests/integration/index.html | 66 +++++++++++++++++++++++++++ js/tests/integration/rollup.bundle.js | 20 ++++++++ package-lock.json | 33 ++++++++++++++ package.json | 5 +- 5 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 js/tests/integration/bundle.js create mode 100644 js/tests/integration/index.html create mode 100644 js/tests/integration/rollup.bundle.js diff --git a/js/tests/integration/bundle.js b/js/tests/integration/bundle.js new file mode 100644 index 0000000000..df5b34610d --- /dev/null +++ b/js/tests/integration/bundle.js @@ -0,0 +1,8 @@ +import 'popper.js' +import $ from 'jquery' +import bootstrap from '../../../dist/js/bootstrap' + +$(() => { + $('#resultUID').text(bootstrap.Util.getUID('bs')) + $('[data-toggle="tooltip"]').tooltip() +}) diff --git a/js/tests/integration/index.html b/js/tests/integration/index.html new file mode 100644 index 0000000000..e5b33a84dc --- /dev/null +++ b/js/tests/integration/index.html @@ -0,0 +1,66 @@ + + + + + + + + + + + Hello, world! + + +
+

Hello, world!

+
+
+ Util.getUID: + +
+ + +
+
+ + + diff --git a/js/tests/integration/rollup.bundle.js b/js/tests/integration/rollup.bundle.js new file mode 100644 index 0000000000..783cc2ba05 --- /dev/null +++ b/js/tests/integration/rollup.bundle.js @@ -0,0 +1,20 @@ +/* eslint-env node */ + +const resolve = require('rollup-plugin-node-resolve') +const commonjs = require('rollup-plugin-commonjs') +const babel = require('rollup-plugin-babel') + +module.exports = { + input: 'js/tests/integration/bundle.js', + output: { + file: 'js/coverage/bundle.js', + format: 'iife' + }, + plugins: [ + resolve(), + commonjs(), + babel({ + exclude: 'node_modules/**' + }) + ] +} diff --git a/package-lock.json b/package-lock.json index 5f3828fa97..e7a620c29c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5658,6 +5658,12 @@ "handlebars": "^4.0.11" } }, + "jquery": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.3.1.tgz", + "integrity": "sha512-Ubldcmxp5np52/ENotGxlLe6aGMvmF4R8S6tZjsP6Knsaxd/xp3Zrh50cG93lR6nPXyUFwzN3ZSOQI0wRJNdGg==", + "dev": true + }, "js-base64": { "version": "2.4.9", "resolved": "https://registry.npmjs.org/js-base64/-/js-base64-2.4.9.tgz", @@ -6134,6 +6140,15 @@ "yallist": "^2.1.2" } }, + "magic-string": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.1.tgz", + "integrity": "sha512-sCuTz6pYom8Rlt4ISPFn6wuFodbKMIHUMv4Qko9P17dpxb7s52KJTmRuZZqHdGmLCK9AOcDare039nRIcfdkEg==", + "dev": true, + "requires": { + "sourcemap-codec": "^1.4.1" + } + }, "make-dir": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-1.3.0.tgz", @@ -8509,6 +8524,18 @@ "rollup-pluginutils": "^2.3.0" } }, + "rollup-plugin-commonjs": { + "version": "9.2.0", + "resolved": "https://registry.npmjs.org/rollup-plugin-commonjs/-/rollup-plugin-commonjs-9.2.0.tgz", + "integrity": "sha512-0RM5U4Vd6iHjL6rLvr3lKBwnPsaVml+qxOGaaNUWN1lSq6S33KhITOfHmvxV3z2vy9Mk4t0g4rNlVaJJsNQPWA==", + "dev": true, + "requires": { + "estree-walker": "^0.5.2", + "magic-string": "^0.25.1", + "resolve": "^1.8.1", + "rollup-pluginutils": "^2.3.3" + } + }, "rollup-plugin-node-resolve": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/rollup-plugin-node-resolve/-/rollup-plugin-node-resolve-4.0.0.tgz", @@ -9179,6 +9206,12 @@ "integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=", "dev": true }, + "sourcemap-codec": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/sourcemap-codec/-/sourcemap-codec-1.4.4.tgz", + "integrity": "sha512-CYAPYdBu34781kLHkaW3m6b/uUSyMOC2R61gcYMWooeuaGtjof86ZA/8T+qVPPt7np1085CR9hmMGrySwEc8Xg==", + "dev": true + }, "spdx-correct": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.1.0.tgz", diff --git a/package.json b/package.json index c54dfeb10a..7f84762f85 100644 --- a/package.json +++ b/package.json @@ -57,11 +57,12 @@ "js-minify-standalone": "uglifyjs --compress typeofs=false --mangle --comments \"/^!/\" --source-map \"content=dist/js/bootstrap.js.map,includeSources,url=bootstrap.min.js.map\" --output dist/js/bootstrap.min.js dist/js/bootstrap.js", "js-minify-bundle": "uglifyjs --compress typeofs=false --mangle --comments \"/^!/\" --source-map \"content=dist/js/bootstrap.bundle.js.map,includeSources,url=bootstrap.bundle.min.js.map\" --output dist/js/bootstrap.bundle.min.js dist/js/bootstrap.bundle.js", "js-minify-docs": "cross-env-shell uglifyjs --mangle --comments \\\"/^!/\\\" --output site/docs/$npm_package_version_short/assets/js/docs.min.js site/docs/$npm_package_version_short/assets/js/vendor/anchor.min.js site/docs/$npm_package_version_short/assets/js/vendor/clipboard.min.js site/docs/$npm_package_version_short/assets/js/vendor/bs-custom-file-input.min.js \"site/docs/$npm_package_version_short/assets/js/src/*.js\"", - "js-test": "npm-run-all js-test-karma*", + "js-test": "npm-run-all js-test-karma* js-test-integration", "js-test-karma": "karma start js/tests/karma.conf.js", "js-test-karma-old": "cross-env USE_OLD_JQUERY=true npm run js-test-karma", "js-test-karma-bundle": "cross-env BUNDLE=true npm run js-test-karma", "js-test-karma-bundle-old": "cross-env BUNDLE=true USE_OLD_JQUERY=true npm run js-test-karma", + "js-test-integration": "rollup --config js/tests/integration/rollup.bundle.js", "js-test-cloud": "cross-env BROWSER=true npm run js-test-karma", "lint": "npm-run-all js-lint css-lint", "coveralls": "shx cat js/coverage/lcov.info | coveralls", @@ -119,6 +120,7 @@ "hammer-simulator": "0.0.1", "http-server": "^0.11.1", "ip": "^1.1.5", + "jquery": "^3.3.1", "karma": "^3.1.3", "karma-browserstack-launcher": "^1.3.0", "karma-chrome-launcher": "^2.2.0", @@ -135,6 +137,7 @@ "qunit": "^2.8.0", "rollup": "^0.67.4", "rollup-plugin-babel": "^4.0.3", + "rollup-plugin-commonjs": "^9.2.0", "rollup-plugin-node-resolve": "^4.0.0", "shelljs": "^0.8.3", "shx": "^0.3.2",