diff --git a/.eslintrc.json b/.eslintrc.json index d5a54d46b..680642ac6 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -43,6 +43,7 @@ ], "unicorn/consistent-function-scoping": "off", "unicorn/explicit-length-check": "off", + "unicorn/import-index": "off", "unicorn/no-array-callback-reference": "off", "unicorn/no-for-loop": "off", "unicorn/no-null": "off", diff --git a/.github/workflows/browserstack.yml b/.github/workflows/browserstack.yml index a12bffcf7..917ccc188 100644 --- a/.github/workflows/browserstack.yml +++ b/.github/workflows/browserstack.yml @@ -4,8 +4,9 @@ on: push: env: + CI: true FORCE_COLOR: 2 - NODE: 14 + NODE: 14.x jobs: browserstack: @@ -28,8 +29,8 @@ jobs: path: ~/.npm key: ${{ runner.os }}-node-v${{ env.NODE }}-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }} restore-keys: | - ${{ runner.os }}-node-v${{ env.NODE }}-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }} - ${{ runner.os }}-node-v${{ env.NODE }}- + ${{ runner.OS }}-node-v${{ env.NODE }}-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }} + ${{ runner.OS }}-node-v${{ env.NODE }}- - name: Install npm dependencies run: npm ci diff --git a/.github/workflows/bundlewatch.yml b/.github/workflows/bundlewatch.yml index b2bd5eed5..03b3a2b52 100644 --- a/.github/workflows/bundlewatch.yml +++ b/.github/workflows/bundlewatch.yml @@ -7,8 +7,9 @@ on: pull_request: env: + CI: true FORCE_COLOR: 2 - NODE: 14 + NODE: 14.x jobs: bundlewatch: @@ -29,8 +30,8 @@ jobs: path: ~/.npm key: ${{ runner.os }}-node-v${{ env.NODE }}-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }} restore-keys: | - ${{ runner.os }}-node-v${{ env.NODE }}-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }} - ${{ runner.os }}-node-v${{ env.NODE }}- + ${{ runner.OS }}-node-v${{ env.NODE }}-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }} + ${{ runner.OS }}-node-v${{ env.NODE }}- - name: Install npm dependencies run: npm ci diff --git a/.github/workflows/css.yml b/.github/workflows/css.yml index a28059d79..7fb947005 100644 --- a/.github/workflows/css.yml +++ b/.github/workflows/css.yml @@ -7,8 +7,9 @@ on: pull_request: env: + CI: true FORCE_COLOR: 2 - NODE: 14 + NODE: 14.x jobs: css: @@ -29,8 +30,8 @@ jobs: path: ~/.npm key: ${{ runner.os }}-node-v${{ env.NODE }}-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }} restore-keys: | - ${{ runner.os }}-node-v${{ env.NODE }}-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }} - ${{ runner.os }}-node-v${{ env.NODE }}- + ${{ runner.OS }}-node-v${{ env.NODE }}-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }} + ${{ runner.OS }}-node-v${{ env.NODE }}- - name: Install npm dependencies run: npm ci diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 150e4d16c..d2529cbfe 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -7,8 +7,9 @@ on: pull_request: env: + CI: true FORCE_COLOR: 2 - NODE: 14 + NODE: 14.x jobs: docs: @@ -31,8 +32,8 @@ jobs: path: ~/.npm key: ${{ runner.os }}-node-v${{ env.NODE }}-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }} restore-keys: | - ${{ runner.os }}-node-v${{ env.NODE }}-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }} - ${{ runner.os }}-node-v${{ env.NODE }}- + ${{ runner.OS }}-node-v${{ env.NODE }}-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }} + ${{ runner.OS }}-node-v${{ env.NODE }}- - name: Install npm dependencies run: npm ci diff --git a/.github/workflows/js.yml b/.github/workflows/js.yml index c56a2dfdd..09c110fc8 100644 --- a/.github/workflows/js.yml +++ b/.github/workflows/js.yml @@ -7,6 +7,7 @@ on: pull_request: env: + CI: true FORCE_COLOR: 2 jobs: @@ -34,8 +35,8 @@ jobs: path: ~/.npm key: ${{ runner.os }}-node-v${{ matrix.node }}-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }}} restore-keys: | - ${{ runner.os }}-node-v${{ matrix.node }}-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }} - ${{ runner.os }}-node-v${{ matrix.node }}- + ${{ runner.OS }}-node-v${{ matrix.node }}-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }} + ${{ runner.OS }}-node-v${{ matrix.node }}- - name: Install npm dependencies run: npm ci diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 369aaced3..30c434984 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -7,8 +7,9 @@ on: pull_request: env: + CI: true FORCE_COLOR: 2 - NODE: 14 + NODE: 14.x jobs: lint: @@ -29,8 +30,8 @@ jobs: path: ~/.npm key: ${{ runner.os }}-node-v${{ env.NODE }}-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }} restore-keys: | - ${{ runner.os }}-node-v${{ env.NODE }}-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }} - ${{ runner.os }}-node-v${{ env.NODE }}- + ${{ runner.OS }}-node-v${{ env.NODE }}-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }} + ${{ runner.OS }}-node-v${{ env.NODE }}- - name: Install npm dependencies run: npm ci diff --git a/.github/workflows/node-sass.yml b/.github/workflows/node-sass.yml index ee64b2152..9e9cffa40 100644 --- a/.github/workflows/node-sass.yml +++ b/.github/workflows/node-sass.yml @@ -7,8 +7,9 @@ on: pull_request: env: + CI: true FORCE_COLOR: 2 - NODE: 14 + NODE: 14.x jobs: css: diff --git a/.gitignore b/.gitignore index 0a0f88d15..6208c57d7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,19 @@ # Ignore docs files /_gh_pages/ +# This is the old Jekyll docs dist folder; +# keeping it here so that when we switch branches it doesn't show up +/site/docs/**/dist/ +# Jekyll's cache folder; keeping it for the same reason as above +/site/.jekyll-cache/ # Hugo resources folder /resources/ +# Ignore ruby/bundler files; +# keeping them here so that when we switch branches they don't show up +/.bundle/ +/vendor/ +/.ruby-version + # Numerous always-ignore extensions *.diff *.err diff --git a/.stylelintrc b/.stylelintrc index c068d30b5..1c9ee1811 100644 --- a/.stylelintrc +++ b/.stylelintrc @@ -3,10 +3,6 @@ "stylelint-config-twbs-bootstrap/scss" ], "rules": { - "declaration-property-value-disallowed-list": { - "border": "none", - "outline": "none" - }, "function-disallowed-list": [ "calc", "lighten", diff --git a/build/build-plugins.js b/build/build-plugins.js index d1930b855..80a010a7f 100644 --- a/build/build-plugins.js +++ b/build/build-plugins.js @@ -29,7 +29,6 @@ const bsPlugins = { Manipulator: path.resolve(__dirname, '../js/src/dom/manipulator.js'), SelectorEngine: path.resolve(__dirname, '../js/src/dom/selector-engine.js'), Alert: path.resolve(__dirname, '../js/src/alert.js'), - Base: path.resolve(__dirname, '../js/src/base-component.js'), Button: path.resolve(__dirname, '../js/src/button.js'), Carousel: path.resolve(__dirname, '../js/src/carousel.js'), Collapse: path.resolve(__dirname, '../js/src/collapse.js'), @@ -45,13 +44,11 @@ const bsPlugins = { const defaultPluginConfig = { external: [ bsPlugins.Data, - bsPlugins.Base, bsPlugins.EventHandler, bsPlugins.SelectorEngine ], globals: { [bsPlugins.Data]: 'Data', - [bsPlugins.Base]: 'Base', [bsPlugins.EventHandler]: 'EventHandler', [bsPlugins.SelectorEngine]: 'SelectorEngine' } @@ -76,7 +73,6 @@ const getConfigByPluginKey = pluginKey => { } if ( - pluginKey === 'Base' || pluginKey === 'Button' || pluginKey === 'Carousel' || pluginKey === 'Collapse' || @@ -116,13 +112,11 @@ const getConfigByPluginKey = pluginKey => { return { external: [ bsPlugins.Data, - bsPlugins.Base, bsPlugins.EventHandler, bsPlugins.Manipulator ], globals: { [bsPlugins.Data]: 'Data', - [bsPlugins.Base]: 'Base', [bsPlugins.EventHandler]: 'EventHandler', [bsPlugins.Manipulator]: 'Manipulator' } diff --git a/build/zip-examples.js b/build/zip-examples.js index b2f156502..898e5860f 100644 --- a/build/zip-examples.js +++ b/build/zip-examples.js @@ -15,64 +15,34 @@ const sh = require('shelljs') const pkg = require('../package.json') const versionShort = pkg.config.version_short -const distFolder = `bootstrap-${pkg.version}-examples` -const rootDocsDir = '_gh_pages' -const docsDir = `${rootDocsDir}/docs/${versionShort}/` - -// these are the files we need in the examples -const cssFiles = [ - 'bootstrap.min.css', - 'bootstrap.min.css.map', - 'bootstrap.rtl.min.css', - 'bootstrap.rtl.min.css.map' -] -const jsFiles = [ - 'bootstrap.bundle.min.js', - 'bootstrap.bundle.min.js.map' -] -const imgFiles = [ - 'bootstrap-logo.svg', - 'bootstrap-logo-white.svg' -] +const folderName = `bootstrap-${pkg.version}-examples` sh.config.fatal = true -if (!sh.test('-d', rootDocsDir)) { - throw new Error(`The "${rootDocsDir}" folder does not exist, did you forget building the docs?`) +if (!sh.test('-d', '_gh_pages')) { + throw new Error('The "_gh_pages" folder does not exist, did you forget building the docs?') } // switch to the root dir sh.cd(path.join(__dirname, '..')) -// remove any previously created folder/zip with the same name -sh.rm('-rf', [distFolder, `${distFolder}.zip`]) - +// remove any previously created folder with the same name +sh.rm('-rf', folderName) // create any folders so that `cp` works -sh.mkdir('-p', [ - distFolder, - `${distFolder}/assets/brand/`, - `${distFolder}/assets/dist/css/`, - `${distFolder}/assets/dist/js/` -]) +sh.mkdir('-p', folderName) +sh.mkdir('-p', `${folderName}/assets/brand/`) -sh.cp('-Rf', `${docsDir}/examples/*`, distFolder) - -cssFiles.forEach(file => { - sh.cp('-f', `${docsDir}/dist/css/${file}`, `${distFolder}/assets/dist/css/`) -}) - -jsFiles.forEach(file => { - sh.cp('-f', `${docsDir}/dist/js/${file}`, `${distFolder}/assets/dist/js/`) -}) - -imgFiles.forEach(file => { - sh.cp('-f', `${docsDir}/assets/brand/${file}`, `${distFolder}/assets/brand/`) -}) - -sh.rm(`${distFolder}/index.html`) +sh.cp('-Rf', `_gh_pages/docs/${versionShort}/examples/*`, folderName) +sh.cp('-Rf', `_gh_pages/docs/${versionShort}/dist/`, `${folderName}/assets/`) +// also copy the two brand images we use in the examples +sh.cp('-f', [ + `_gh_pages/docs/${versionShort}/assets/brand/bootstrap-logo.svg`, + `_gh_pages/docs/${versionShort}/assets/brand/bootstrap-logo-white.svg` +], `${folderName}/assets/brand/`) +sh.rm(`${folderName}/index.html`) // get all examples' HTML files -sh.find(`${distFolder}/**/*.html`).forEach(file => { +sh.find(`${folderName}/**/*.html`).forEach(file => { const fileContents = sh.cat(file) .toString() .replace(new RegExp(`"/docs/${versionShort}/`, 'g'), '"../') @@ -84,7 +54,7 @@ sh.find(`${distFolder}/**/*.html`).forEach(file => { }) // create the zip file -sh.exec(`zip -r9 "${distFolder}.zip" "${distFolder}"`) +sh.exec(`zip -r9 "${folderName}.zip" "${folderName}"`, { fatal: true }) // remove the folder we created -sh.rm('-rf', distFolder) +sh.rm('-rf', folderName) diff --git a/js/src/dom/event-handler.js b/js/src/dom/event-handler.js index e3c685530..2ee13bafc 100644 --- a/js/src/dom/event-handler.js +++ b/js/src/dom/event-handler.js @@ -112,7 +112,6 @@ function bootstrapDelegationHandler(element, selector, fn) { event.delegateTarget = target if (handler.oneOff) { - // eslint-disable-next-line unicorn/consistent-destructuring EventHandler.off(element, event.type, fn) } diff --git a/js/src/dropdown.js b/js/src/dropdown.js index bada537c9..008294e9b 100644 --- a/js/src/dropdown.js +++ b/js/src/dropdown.js @@ -263,7 +263,7 @@ class Dropdown extends BaseComponent { typeof config.reference.getBoundingClientRect !== 'function' ) { // Popper virtual elements require a getBoundingClientRect method - throw new TypeError(`${NAME.toUpperCase()}: Option "reference" provided type "object" without a required "getBoundingClientRect" method.`) + throw new Error(`${NAME}: Option "reference" provided type "object" without a required "getBoundingClientRect" method.`) } return config diff --git a/js/src/modal.js b/js/src/modal.js index fe1b5a4c6..87c22943a 100644 --- a/js/src/modal.js +++ b/js/src/modal.js @@ -590,7 +590,7 @@ EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function ( data = new Modal(target, config) } - data.toggle(this) + data.show(this) }) /** diff --git a/js/src/util/index.js b/js/src/util/index.js index 22d0a578b..9ccad1cbb 100644 --- a/js/src/util/index.js +++ b/js/src/util/index.js @@ -111,14 +111,15 @@ const typeCheckConfig = (componentName, config, configTypes) => { Object.keys(configTypes).forEach(property => { const expectedTypes = configTypes[property] const value = config[property] - const valueType = value && isElement(value) ? 'element' : toType(value) + const valueType = value && isElement(value) ? + 'element' : + toType(value) if (!new RegExp(expectedTypes).test(valueType)) { - throw new TypeError( + throw new Error( `${componentName.toUpperCase()}: ` + `Option "${property}" provided type "${valueType}" ` + - `but expected type "${expectedTypes}".` - ) + `but expected type "${expectedTypes}".`) } }) } diff --git a/js/src/util/sanitizer.js b/js/src/util/sanitizer.js index ce3d455a6..d908dd661 100644 --- a/js/src/util/sanitizer.js +++ b/js/src/util/sanitizer.js @@ -37,7 +37,7 @@ const allowedAttribute = (attr, allowedAttributeList) => { if (allowedAttributeList.includes(attrName)) { if (uriAttrs.has(attrName)) { - return Boolean(SAFE_URL_PATTERN.test(attr.nodeValue) || DATA_URL_PATTERN.test(attr.nodeValue)) + return Boolean(attr.nodeValue.match(SAFE_URL_PATTERN) || attr.nodeValue.match(DATA_URL_PATTERN)) } return true @@ -47,7 +47,7 @@ const allowedAttribute = (attr, allowedAttributeList) => { // Check if a regular expression validates the attribute. for (let i = 0, len = regExp.length; i < len; i++) { - if (regExp[i].test(attrName)) { + if (attrName.match(regExp[i])) { return true } } diff --git a/js/tests/karma.conf.js b/js/tests/karma.conf.js index cd4946525..38c7003bb 100644 --- a/js/tests/karma.conf.js +++ b/js/tests/karma.conf.js @@ -1,7 +1,5 @@ /* eslint-env node */ -'use strict' - const path = require('path') const ip = require('ip') const { babel } = require('@rollup/plugin-babel') @@ -14,11 +12,10 @@ const { browsersKeys } = require('./browsers') -const ENV = process.env -const BROWSERSTACK = Boolean(ENV.BROWSERSTACK) -const DEBUG = Boolean(ENV.DEBUG) -const JQUERY_TEST = Boolean(ENV.JQUERY) - +const { env } = process +const browserStack = env.BROWSER === 'true' +const debug = env.DEBUG === 'true' +const jQueryTest = env.JQUERY === 'true' const frameworks = [ 'jasmine' ] @@ -33,16 +30,16 @@ const reporters = ['dots'] const detectBrowsers = { usePhantomJS: false, postDetection(availableBrowser) { - if (ENV.CI === true || availableBrowser.includes('Chrome')) { - return DEBUG ? ['Chrome'] : ['ChromeHeadless'] + if (env.CI === true || availableBrowser.includes('Chrome')) { + return debug ? ['Chrome'] : ['ChromeHeadless'] } if (availableBrowser.includes('Chromium')) { - return DEBUG ? ['Chromium'] : ['ChromiumHeadless'] + return debug ? ['Chromium'] : ['ChromiumHeadless'] } if (availableBrowser.includes('Firefox')) { - return DEBUG ? ['Firefox'] : ['FirefoxHeadless'] + return debug ? ['Firefox'] : ['FirefoxHeadless'] } throw new Error('Please install Chrome, Chromium or Firefox') @@ -70,7 +67,7 @@ const conf = { 'node_modules/hammer-simulator/index.js', { pattern: 'js/tests/unit/**/!(jquery).spec.js', - watched: !BROWSERSTACK + watched: !browserStack } ], preprocessors: { @@ -104,11 +101,11 @@ const conf = { } } -if (BROWSERSTACK) { +if (browserStack) { conf.hostname = ip.address() conf.browserStack = { - username: ENV.BROWSER_STACK_USERNAME, - accessKey: ENV.BROWSER_STACK_ACCESS_KEY, + username: env.BROWSER_STACK_USERNAME, + accessKey: env.BROWSER_STACK_ACCESS_KEY, build: `bootstrap-${new Date().toISOString()}`, project: 'Bootstrap', retryLimit: 2 @@ -117,7 +114,7 @@ if (BROWSERSTACK) { conf.customLaunchers = browsers conf.browsers = browsersKeys reporters.push('BrowserStack', 'kjhtml') -} else if (JQUERY_TEST) { +} else if (jQueryTest) { frameworks.push('detectBrowsers') plugins.push( 'karma-chrome-launcher', @@ -158,7 +155,7 @@ if (BROWSERSTACK) { } } - if (DEBUG) { + if (debug) { conf.hostname = ip.address() plugins.push('karma-jasmine-html-reporter') reporters.push('kjhtml') @@ -172,6 +169,7 @@ conf.plugins = plugins conf.reporters = reporters module.exports = karmaConfig => { - conf.logLevel = karmaConfig.LOG_ERROR + // possible values: karmaConfig.LOG_DISABLE || karmaConfig.LOG_ERROR || karmaConfig.LOG_WARN || karmaConfig.LOG_INFO || karmaConfig.LOG_DEBUG + conf.logLevel = karmaConfig.LOG_ERROR || karmaConfig.LOG_WARN karmaConfig.set(conf) } diff --git a/js/tests/unit/carousel.spec.js b/js/tests/unit/carousel.spec.js index 787a276de..0286762fa 100644 --- a/js/tests/unit/carousel.spec.js +++ b/js/tests/unit/carousel.spec.js @@ -1136,9 +1136,11 @@ describe('Carousel', () => { jQueryMock.fn.carousel = Carousel.jQueryInterface jQueryMock.elements = [div] - expect(() => { + try { jQueryMock.fn.carousel.call(jQueryMock, action) - }).toThrowError(TypeError, `No method named "${action}"`) + } catch (error) { + expect(error.message).toEqual(`No method named "${action}"`) + } }) }) diff --git a/js/tests/unit/collapse.spec.js b/js/tests/unit/collapse.spec.js index ff493cf51..4af21e13f 100644 --- a/js/tests/unit/collapse.spec.js +++ b/js/tests/unit/collapse.spec.js @@ -819,9 +819,11 @@ describe('Collapse', () => { jQueryMock.fn.collapse = Collapse.jQueryInterface jQueryMock.elements = [div] - expect(() => { + try { jQueryMock.fn.collapse.call(jQueryMock, action) - }).toThrowError(TypeError, `No method named "${action}"`) + } catch (error) { + expect(error.message).toEqual(`No method named "${action}"`) + } }) }) diff --git a/js/tests/unit/dropdown.spec.js b/js/tests/unit/dropdown.spec.js index cc4139603..ba1d0f443 100644 --- a/js/tests/unit/dropdown.spec.js +++ b/js/tests/unit/dropdown.spec.js @@ -393,13 +393,13 @@ describe('Dropdown', () => { expect(() => new Dropdown(btnDropdown, { reference: {} - })).toThrowError(TypeError, 'DROPDOWN: Option "reference" provided type "object" without a required "getBoundingClientRect" method.') + })).toThrow() expect(() => new Dropdown(btnDropdown, { reference: { getBoundingClientRect: 'not-a-function' } - })).toThrowError(TypeError, 'DROPDOWN: Option "reference" provided type "object" without a required "getBoundingClientRect" method.') + })).toThrow() // use onFirstUpdate as Poppers internal update is executed async const dropdown = new Dropdown(btnDropdown, { @@ -1557,9 +1557,11 @@ describe('Dropdown', () => { jQueryMock.fn.dropdown = Dropdown.jQueryInterface jQueryMock.elements = [div] - expect(() => { + try { jQueryMock.fn.dropdown.call(jQueryMock, action) - }).toThrowError(TypeError, `No method named "${action}"`) + } catch (error) { + expect(error.message).toEqual(`No method named "${action}"`) + } }) }) diff --git a/js/tests/unit/modal.spec.js b/js/tests/unit/modal.spec.js index 29c90bbf1..f645e9892 100644 --- a/js/tests/unit/modal.spec.js +++ b/js/tests/unit/modal.spec.js @@ -870,7 +870,7 @@ describe('Modal', () => { }) describe('data-api', () => { - it('should toggle modal', done => { + it('should open modal', done => { fixtureEl.innerHTML = [ '', '' @@ -885,15 +885,6 @@ describe('Modal', () => { expect(modalEl.getAttribute('aria-hidden')).toEqual(null) expect(modalEl.style.display).toEqual('block') expect(document.querySelector('.modal-backdrop')).toBeDefined() - setTimeout(() => trigger.click(), 10) - }) - - modalEl.addEventListener('hidden.bs.modal', () => { - expect(modalEl.getAttribute('aria-modal')).toEqual(null) - expect(modalEl.getAttribute('role')).toEqual(null) - expect(modalEl.getAttribute('aria-hidden')).toEqual('true') - expect(modalEl.style.display).toEqual('none') - expect(document.querySelector('.modal-backdrop')).toEqual(null) done() }) @@ -1070,9 +1061,11 @@ describe('Modal', () => { jQueryMock.fn.modal = Modal.jQueryInterface jQueryMock.elements = [div] - expect(() => { + try { jQueryMock.fn.modal.call(jQueryMock, action) - }).toThrowError(TypeError, `No method named "${action}"`) + } catch (error) { + expect(error.message).toEqual(`No method named "${action}"`) + } }) it('should call show method', () => { diff --git a/js/tests/unit/popover.spec.js b/js/tests/unit/popover.spec.js index e5c235e2a..3c04e7ac1 100644 --- a/js/tests/unit/popover.spec.js +++ b/js/tests/unit/popover.spec.js @@ -206,9 +206,11 @@ describe('Popover', () => { jQueryMock.fn.popover = Popover.jQueryInterface jQueryMock.elements = [popoverEl] - expect(() => { + try { jQueryMock.fn.popover.call(jQueryMock, action) - }).toThrowError(TypeError, `No method named "${action}"`) + } catch (error) { + expect(error.message).toEqual(`No method named "${action}"`) + } }) it('should should call show method', () => { diff --git a/js/tests/unit/scrollspy.spec.js b/js/tests/unit/scrollspy.spec.js index 0d175aafa..eab9183aa 100644 --- a/js/tests/unit/scrollspy.spec.js +++ b/js/tests/unit/scrollspy.spec.js @@ -625,9 +625,11 @@ describe('ScrollSpy', () => { jQueryMock.fn.scrollspy = ScrollSpy.jQueryInterface jQueryMock.elements = [div] - expect(() => { + try { jQueryMock.fn.scrollspy.call(jQueryMock, action) - }).toThrowError(TypeError, `No method named "${action}"`) + } catch (error) { + expect(error.message).toEqual(`No method named "${action}"`) + } }) }) diff --git a/js/tests/unit/tab.spec.js b/js/tests/unit/tab.spec.js index d098ab027..a644360fe 100644 --- a/js/tests/unit/tab.spec.js +++ b/js/tests/unit/tab.spec.js @@ -21,15 +21,39 @@ describe('Tab', () => { }) describe('show', () => { - it('should activate element by tab id', done => { + it('should activate element by tab id (using buttons, the preferred semantic way)', done => { fixtureEl.innerHTML = [ - '