diff --git a/js/tests/unit/base-component.spec.js b/js/tests/unit/base-component.spec.js index 9fe4e72d7b..9e0b872d49 100644 --- a/js/tests/unit/base-component.spec.js +++ b/js/tests/unit/base-component.spec.js @@ -66,6 +66,7 @@ describe('Base Component', () => { }) }) }) + describe('Public Methods', () => { describe('constructor', () => { it('should accept element, either passed as a CSS selector or DOM element', () => { @@ -93,6 +94,7 @@ describe('Base Component', () => { expect(selectorInstance._element).not.toBeDefined() }) }) + describe('dispose', () => { it('should dispose an component', () => { createInstance() @@ -144,6 +146,7 @@ describe('Base Component', () => { expect(DummyClass.getInstance(div)).toBeNull() }) }) + describe('getOrCreateInstance', () => { it('should return an instance', () => { createInstance() diff --git a/js/tests/unit/carousel.spec.js b/js/tests/unit/carousel.spec.js index a4b440c893..66f4a8367b 100644 --- a/js/tests/unit/carousel.spec.js +++ b/js/tests/unit/carousel.spec.js @@ -235,9 +235,7 @@ describe('Carousel', () => { const carouselEl = fixtureEl.querySelector('#myCarousel') const carousel = new Carousel(carouselEl, { wrap: true }) - const getActiveId = () => { - return carouselEl.querySelector('.carousel-item.active').getAttribute('id') - } + const getActiveId = () => carouselEl.querySelector('.carousel-item.active').getAttribute('id') carouselEl.addEventListener('slid.bs.carousel', event => { const activeId = getActiveId() @@ -1153,6 +1151,7 @@ describe('Carousel', () => { }) }) }) + describe('rtl function', () => { it('"_directionToOrder" and "_orderToDirection" must return the right results', () => { fixtureEl.innerHTML = '
' diff --git a/js/tests/unit/collapse.spec.js b/js/tests/unit/collapse.spec.js index fa8024f6e1..a7635006fe 100644 --- a/js/tests/unit/collapse.spec.js +++ b/js/tests/unit/collapse.spec.js @@ -268,31 +268,31 @@ describe('Collapse', () => { it('should be able to handle toggling of other children siblings', done => { fixtureEl.innerHTML = [ '
', - '
', - ' ', - '
', - '
', - '
', - '
', - '
', - '
', - ' ', - '
', - '
', - '
content
', - '
', - '
', - '
', - '
', - ' ', - '
', - '
', - '
content
', - '
', - '
', - '
', + '
', + ' ', + '
', + '
', + '
', + '
', + '
', + '
', + ' ', + '
', + '
', + '
content
', + '
', + '
', + '
', + '
', + ' ', + '
', + '
', + '
content
', + '
', + '
', '
', - '
', + '
', + '
', '
' ].join('') @@ -322,31 +322,32 @@ describe('Collapse', () => { parentBtn.click() }) + it('should not change tab tabpanels descendants on accordion', done => { fixtureEl.innerHTML = [ '
', - '
', - '

', - ' ', - '

', - '
', - '
', - ' ', - ' ', + '
', + '

', + ' ', + '

', + '
', + '
', + ' ', + ' ', '
', - '
' + '
', + '
', + '
' ].join('') const el = fixtureEl.querySelector('#collapseOne') diff --git a/js/tests/unit/dom/selector-engine.spec.js b/js/tests/unit/dom/selector-engine.spec.js index 3df753b72f..005e92704c 100644 --- a/js/tests/unit/dom/selector-engine.spec.js +++ b/js/tests/unit/dom/selector-engine.spec.js @@ -197,9 +197,7 @@ describe('SelectorEngine', () => { }) it('should return not return elements with negative tab index', () => { - fixtureEl.innerHTML = [ - '' - ].join('') + fixtureEl.innerHTML = '' const expectedElements = [] @@ -207,9 +205,7 @@ describe('SelectorEngine', () => { }) it('should return contenteditable elements', () => { - fixtureEl.innerHTML = [ - '
lorem
' - ].join('') + fixtureEl.innerHTML = '
lorem
' const expectedElements = [fixtureEl.querySelector('[contenteditable="true"]')] @@ -217,9 +213,7 @@ describe('SelectorEngine', () => { }) it('should not return disabled elements', () => { - fixtureEl.innerHTML = [ - '' - ].join('') + fixtureEl.innerHTML = '' const expectedElements = [] @@ -227,9 +221,7 @@ describe('SelectorEngine', () => { }) it('should not return invisible elements', () => { - fixtureEl.innerHTML = [ - '' - ].join('') + fixtureEl.innerHTML = '' const expectedElements = [] diff --git a/js/tests/unit/dropdown.spec.js b/js/tests/unit/dropdown.spec.js index 0765768d4b..9c0eae6d85 100644 --- a/js/tests/unit/dropdown.spec.js +++ b/js/tests/unit/dropdown.spec.js @@ -1750,8 +1750,8 @@ describe('Dropdown', () => { ' Secondary link', ' Something else here', '
', - ' Another link', - '
', + ' Another link', + '
', '
', '' ] @@ -1783,7 +1783,7 @@ describe('Dropdown', () => { ' ', ' ', + ' ', ' ', '' ] diff --git a/js/tests/unit/modal.spec.js b/js/tests/unit/modal.spec.js index dd501aa7bf..5729942e57 100644 --- a/js/tests/unit/modal.spec.js +++ b/js/tests/unit/modal.spec.js @@ -57,9 +57,7 @@ describe('Modal', () => { describe('toggle', () => { it('should call ScrollBarHelper to handle scrollBar on body', done => { - fixtureEl.innerHTML = [ - '' - ].join('') + fixtureEl.innerHTML = '' spyOn(ScrollBarHelper.prototype, 'hide').and.callThrough() spyOn(ScrollBarHelper.prototype, 'reset').and.callThrough() diff --git a/js/tests/unit/offcanvas.spec.js b/js/tests/unit/offcanvas.spec.js index e262a9a3a0..191a9f8018 100644 --- a/js/tests/unit/offcanvas.spec.js +++ b/js/tests/unit/offcanvas.spec.js @@ -108,10 +108,7 @@ describe('Offcanvas', () => { describe('config', () => { it('should have default values', () => { - fixtureEl.innerHTML = [ - '
', - '
' - ].join('') + fixtureEl.innerHTML = '
' const offCanvasEl = fixtureEl.querySelector('.offcanvas') const offCanvas = new Offcanvas(offCanvasEl) @@ -123,10 +120,7 @@ describe('Offcanvas', () => { }) it('should read data attributes and override default config', () => { - fixtureEl.innerHTML = [ - '
', - '
' - ].join('') + fixtureEl.innerHTML = '
' const offCanvasEl = fixtureEl.querySelector('.offcanvas') const offCanvas = new Offcanvas(offCanvasEl) @@ -138,10 +132,7 @@ describe('Offcanvas', () => { }) it('given a config object must override data attributes', () => { - fixtureEl.innerHTML = [ - '
', - '
' - ].join('') + fixtureEl.innerHTML = '
' const offCanvasEl = fixtureEl.querySelector('.offcanvas') const offCanvas = new Offcanvas(offCanvasEl, { @@ -154,6 +145,7 @@ describe('Offcanvas', () => { expect(offCanvas._config.scroll).toBeFalse() }) }) + describe('options', () => { it('if scroll is enabled, should allow body to scroll while offcanvas is open', done => { fixtureEl.innerHTML = '
' diff --git a/js/tests/unit/scrollspy.spec.js b/js/tests/unit/scrollspy.spec.js index 1b713757e3..5c044e697a 100644 --- a/js/tests/unit/scrollspy.spec.js +++ b/js/tests/unit/scrollspy.spec.js @@ -73,8 +73,8 @@ describe('ScrollSpy', () => { ' ', '', '
', - '
', - '
', + '
', + '
', '
' ].join('') @@ -175,16 +175,16 @@ describe('ScrollSpy', () => { fixtureEl.innerHTML = [ '', '', '
', - '
', - '
', - '
', + '
', + '
', + '
', '
' ].join('') diff --git a/js/tests/unit/tab.spec.js b/js/tests/unit/tab.spec.js index ade0f35704..43d20438eb 100644 --- a/js/tests/unit/tab.spec.js +++ b/js/tests/unit/tab.spec.js @@ -21,8 +21,12 @@ describe('Tab', () => { describe('constructor', () => { it('should take care of element either passed as a CSS selector or DOM element', () => { fixtureEl.innerHTML = [ - '', - '' + '', + '' ].join('') const tabEl = fixtureEl.querySelector('[href="#home"]') @@ -112,7 +116,10 @@ describe('Tab', () => { ' ', ' ', ' ', '', - '
' + '
', + '
', + '
', + '
' ].join('') const profileTriggerEl = fixtureEl.querySelector('#triggerProfile') diff --git a/js/tests/unit/toast.spec.js b/js/tests/unit/toast.spec.js index 9541bcdeec..c4ea43808c 100644 --- a/js/tests/unit/toast.spec.js +++ b/js/tests/unit/toast.spec.js @@ -393,7 +393,7 @@ describe('Toast', () => { '
', ' a simple toast', '
', - ' ' + '' ].join('') const toastEl = fixtureEl.querySelector('.toast') diff --git a/js/tests/unit/tooltip.spec.js b/js/tests/unit/tooltip.spec.js index 9b87f75b2a..d8ca21a630 100644 --- a/js/tests/unit/tooltip.spec.js +++ b/js/tests/unit/tooltip.spec.js @@ -416,13 +416,14 @@ describe('Tooltip', () => { }) it('should show a tooltip when hovering a children element', done => { - fixtureEl.innerHTML = - '' + - '' + - '' + - '' + - '' + + fixtureEl.innerHTML = [ + '', + ' ', + ' ', + ' ', + ' ', '' + ].join('') const tooltipEl = fixtureEl.querySelector('a') const tooltip = new Tooltip(tooltipEl) @@ -1201,7 +1202,7 @@ describe('Tooltip', () => { const content = [ '
', - ' ', + ' ', '
' ].join('') diff --git a/js/tests/unit/util/backdrop.spec.js b/js/tests/unit/util/backdrop.spec.js index 5a62ab8b15..4fa9e54366 100644 --- a/js/tests/unit/util/backdrop.spec.js +++ b/js/tests/unit/util/backdrop.spec.js @@ -232,6 +232,7 @@ describe('Backdrop', () => { }) }) }) + describe('Config', () => { describe('rootElement initialization', () => { it('Should be appended on "document.body" by default', done => { @@ -258,10 +259,7 @@ describe('Backdrop', () => { }) it('Should appended on any element given by the proper config', done => { - fixtureEl.innerHTML = [ - '
', - '
' - ].join('') + fixtureEl.innerHTML = '
' const wrapper = fixtureEl.querySelector('#wrapper') const instance = new Backdrop({ diff --git a/js/tests/unit/util/component-functions.spec.js b/js/tests/unit/util/component-functions.spec.js index edaedd32ee..16f910a633 100644 --- a/js/tests/unit/util/component-functions.spec.js +++ b/js/tests/unit/util/component-functions.spec.js @@ -33,7 +33,7 @@ describe('Plugin functions', () => { it('should get Plugin and execute the given method, when a click occurred on data-bs-dismiss="PluginName"', () => { fixtureEl.innerHTML = [ '
', - ' ', + ' ', '
' ].join('') @@ -53,7 +53,7 @@ describe('Plugin functions', () => { it('if data-bs-dismiss="PluginName" hasn\'t got "data-bs-target", "getOrCreateInstance" has to be initialized by closest "plugin.Name" class', () => { fixtureEl.innerHTML = [ '
', - ' ', + ' ', '
' ].join('') @@ -73,7 +73,7 @@ describe('Plugin functions', () => { it('if data-bs-dismiss="PluginName" is disabled, must not trigger function', () => { fixtureEl.innerHTML = [ '
', - ' ', + ' ', '
' ].join('') @@ -90,7 +90,7 @@ describe('Plugin functions', () => { it('should prevent default when the trigger is or ', () => { fixtureEl.innerHTML = [ '
', - ' ', + ' ', '
' ].join('') diff --git a/js/tests/unit/util/focustrap.spec.js b/js/tests/unit/util/focustrap.spec.js index 12fd46ecf4..52a7573971 100644 --- a/js/tests/unit/util/focustrap.spec.js +++ b/js/tests/unit/util/focustrap.spec.js @@ -45,7 +45,7 @@ describe('FocusTrap', () => { fixtureEl.innerHTML = [ 'outside', '
', - ' inside', + ' inside', '
' ].join('') @@ -78,9 +78,9 @@ describe('FocusTrap', () => { fixtureEl.innerHTML = [ 'outside', '
', - ' first', - ' inside', - ' last', + ' first', + ' inside', + ' last', '
' ].join('') @@ -115,9 +115,9 @@ describe('FocusTrap', () => { fixtureEl.innerHTML = [ 'outside', '
', - ' first', - ' inside', - ' last', + ' first', + ' inside', + ' last', '
' ].join('') diff --git a/js/tests/unit/util/index.spec.js b/js/tests/unit/util/index.spec.js index e0220091e3..a9e446c9df 100644 --- a/js/tests/unit/util/index.spec.js +++ b/js/tests/unit/util/index.spec.js @@ -431,6 +431,7 @@ describe('Util', () => { expect(Util.isDisabled(el('#select'))).toBeFalse() expect(Util.isDisabled(el('#input'))).toBeFalse() }) + it('should return true if the element has disabled attribute', () => { fixtureEl.innerHTML = [ '
', diff --git a/js/tests/unit/util/scrollbar.spec.js b/js/tests/unit/util/scrollbar.spec.js index ee17d3c7b4..c42234c4fe 100644 --- a/js/tests/unit/util/scrollbar.spec.js +++ b/js/tests/unit/util/scrollbar.spec.js @@ -24,7 +24,9 @@ describe('ScrollBar', () => { } } - const isScrollBarHidden = () => { // IOS devices, Android devices and Browsers on Mac, hide scrollbar by default and appear it, only while scrolling. So the tests for scrollbar would fail + // iOS, Android devices and macOS browsers hide scrollbar by default and show it only while scrolling. + // So the tests for scrollbar would fail + const isScrollBarHidden = () => { const calc = windowCalculations() return calc.htmlClient === calc.htmlOffset && calc.htmlClient === calc.window } @@ -52,9 +54,7 @@ describe('ScrollBar', () => { it('should return true if body is overflowing', () => { document.documentElement.style.overflowY = 'scroll' document.body.style.overflowY = 'scroll' - fixtureEl.innerHTML = [ - '
' - ].join('') + fixtureEl.innerHTML = '
' const result = new ScrollBarHelper().isOverflowing() if (isScrollBarHidden()) { @@ -67,9 +67,7 @@ describe('ScrollBar', () => { it('should return false if body is not overflowing', () => { doc.style.overflowY = 'hidden' document.body.style.overflowY = 'hidden' - fixtureEl.innerHTML = [ - '
' - ].join('') + fixtureEl.innerHTML = '
' const scrollBar = new ScrollBarHelper() const result = scrollBar.isOverflowing() @@ -81,9 +79,7 @@ describe('ScrollBar', () => { it('should return an integer greater than zero, if body is overflowing', () => { doc.style.overflowY = 'scroll' document.body.style.overflowY = 'scroll' - fixtureEl.innerHTML = [ - '
' - ].join('') + fixtureEl.innerHTML = '
' const result = new ScrollBarHelper().getWidth() if (isScrollBarHidden()) { @@ -96,9 +92,7 @@ describe('ScrollBar', () => { it('should return 0 if body is not overflowing', () => { document.documentElement.style.overflowY = 'hidden' document.body.style.overflowY = 'hidden' - fixtureEl.innerHTML = [ - '
' - ].join('') + fixtureEl.innerHTML = '
' const result = new ScrollBarHelper().getWidth() @@ -109,9 +103,9 @@ describe('ScrollBar', () => { describe('hide - reset', () => { it('should adjust the inline padding of fixed elements which are full-width', done => { fixtureEl.innerHTML = [ - '
' + - '
', - '
', + '
', + '
', + '
', '
' ].join('') doc.style.overflowY = 'scroll' @@ -145,8 +139,8 @@ describe('ScrollBar', () => { it('should adjust the inline margin and padding of sticky elements', done => { fixtureEl.innerHTML = [ - '
' + - '
', + '
', + '
', '
' ].join('') doc.style.overflowY = 'scroll' @@ -173,9 +167,7 @@ describe('ScrollBar', () => { }) it('should not adjust the inline margin and padding of sticky and fixed elements when element do not have full width', () => { - fixtureEl.innerHTML = [ - '
' - ].join('') + fixtureEl.innerHTML = '
' const stickyTopEl = fixtureEl.querySelector('.sticky-top') const originalMargin = getMarginX(stickyTopEl) @@ -195,8 +187,8 @@ describe('ScrollBar', () => { it('should not put data-attribute if element doesn\'t have the proper style property, should just remove style property if element didn\'t had one', () => { fixtureEl.innerHTML = [ - '
' + - '
', + '
', + '
', '
' ].join('') @@ -243,7 +235,7 @@ describe('ScrollBar', () => { fixtureEl.innerHTML = [ '' ].join('') @@ -283,7 +275,7 @@ describe('ScrollBar', () => { fixtureEl.innerHTML = [ '' ].join('') diff --git a/js/tests/unit/util/swipe.spec.js b/js/tests/unit/util/swipe.spec.js index 474e34f653..93131b8fdd 100644 --- a/js/tests/unit/util/swipe.spec.js +++ b/js/tests/unit/util/swipe.spec.js @@ -39,17 +39,17 @@ describe('Swipe', () => { fixtureEl = getFixture() const cssStyle = [ '' ].join('') - fixtureEl.innerHTML = '
' + cssStyle + fixtureEl.innerHTML = `
${cssStyle}` swipeEl = fixtureEl.querySelector('div') }) @@ -266,7 +266,7 @@ describe('Swipe', () => { expect(Swipe.isSupported()).toBeTrue() }) - it('should return "false" if "touchstart" not exists in document element and "navigator.maxTouchPoints" are zero (0)', () => { + it('should return "false" if "touchstart" not exists in document element and "navigator.maxTouchPoints" are zero (0)', () => { Object.defineProperty(window.navigator, 'maxTouchPoints', () => 0) deleteDocumentElementOntouchstart() diff --git a/js/tests/unit/util/template-factory.spec.js b/js/tests/unit/util/template-factory.spec.js index dccf2a5857..0fdf871466 100644 --- a/js/tests/unit/util/template-factory.spec.js +++ b/js/tests/unit/util/template-factory.spec.js @@ -113,11 +113,11 @@ describe('TemplateFactory', () => { describe('Content', () => { it('add simple text content', () => { const template = [ - '
' + - '
' + - '
' + + '
', + '
', + '
', '
' - ].join(' ') + ].join('') const factory = new TemplateFactory({ template, @@ -245,14 +245,15 @@ describe('TemplateFactory', () => { expect(factory.hasContent()).toBeFalse() }) }) + describe('changeContent', () => { it('should change Content', () => { const template = [ - '
' + - '
' + - '
' + + '
', + '
', + '
', '
' - ].join(' ') + ].join('') const factory = new TemplateFactory({ template, @@ -276,11 +277,11 @@ describe('TemplateFactory', () => { it('should change only the given, content', () => { const template = [ - '
' + - '
' + - '
' + + '
', + '
', + '
', '
' - ].join(' ') + ].join('') const factory = new TemplateFactory({ template,