mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-11 08:04:59 +02:00
tests: remove extra spaces, unneeded arrays and add missing newlines
This commit is contained in:
@@ -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()
|
||||
|
@@ -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 = '<div></div>'
|
||||
|
@@ -322,6 +322,7 @@ describe('Collapse', () => {
|
||||
|
||||
parentBtn.click()
|
||||
})
|
||||
|
||||
it('should not change tab tabpanels descendants on accordion', done => {
|
||||
fixtureEl.innerHTML = [
|
||||
'<div class="accordion" id="accordionExample">',
|
||||
|
@@ -197,9 +197,7 @@ describe('SelectorEngine', () => {
|
||||
})
|
||||
|
||||
it('should return not return elements with negative tab index', () => {
|
||||
fixtureEl.innerHTML = [
|
||||
'<button tabindex="-1">lorem</button>'
|
||||
].join('')
|
||||
fixtureEl.innerHTML = '<button tabindex="-1">lorem</button>'
|
||||
|
||||
const expectedElements = []
|
||||
|
||||
@@ -207,9 +205,7 @@ describe('SelectorEngine', () => {
|
||||
})
|
||||
|
||||
it('should return contenteditable elements', () => {
|
||||
fixtureEl.innerHTML = [
|
||||
'<div contenteditable="true">lorem</div>'
|
||||
].join('')
|
||||
fixtureEl.innerHTML = '<div contenteditable="true">lorem</div>'
|
||||
|
||||
const expectedElements = [fixtureEl.querySelector('[contenteditable="true"]')]
|
||||
|
||||
@@ -217,9 +213,7 @@ describe('SelectorEngine', () => {
|
||||
})
|
||||
|
||||
it('should not return disabled elements', () => {
|
||||
fixtureEl.innerHTML = [
|
||||
'<button disabled="true">lorem</button>'
|
||||
].join('')
|
||||
fixtureEl.innerHTML = '<button disabled="true">lorem</button>'
|
||||
|
||||
const expectedElements = []
|
||||
|
||||
@@ -227,9 +221,7 @@ describe('SelectorEngine', () => {
|
||||
})
|
||||
|
||||
it('should not return invisible elements', () => {
|
||||
fixtureEl.innerHTML = [
|
||||
'<button style="display:none;">lorem</button>'
|
||||
].join('')
|
||||
fixtureEl.innerHTML = '<button style="display:none;">lorem</button>'
|
||||
|
||||
const expectedElements = []
|
||||
|
||||
|
@@ -57,9 +57,7 @@ describe('Modal', () => {
|
||||
|
||||
describe('toggle', () => {
|
||||
it('should call ScrollBarHelper to handle scrollBar on body', done => {
|
||||
fixtureEl.innerHTML = [
|
||||
'<div class="modal"><div class="modal-dialog"></div></div>'
|
||||
].join('')
|
||||
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div></div>'
|
||||
|
||||
spyOn(ScrollBarHelper.prototype, 'hide').and.callThrough()
|
||||
spyOn(ScrollBarHelper.prototype, 'reset').and.callThrough()
|
||||
|
@@ -108,10 +108,7 @@ describe('Offcanvas', () => {
|
||||
|
||||
describe('config', () => {
|
||||
it('should have default values', () => {
|
||||
fixtureEl.innerHTML = [
|
||||
'<div class="offcanvas">',
|
||||
'</div>'
|
||||
].join('')
|
||||
fixtureEl.innerHTML = '<div class="offcanvas"></div>'
|
||||
|
||||
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 = [
|
||||
'<div class="offcanvas" data-bs-scroll="true" data-bs-backdrop="false" data-bs-keyboard="false">',
|
||||
'</div>'
|
||||
].join('')
|
||||
fixtureEl.innerHTML = '<div class="offcanvas" data-bs-scroll="true" data-bs-backdrop="false" data-bs-keyboard="false"></div>'
|
||||
|
||||
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 = [
|
||||
'<div class="offcanvas" data-bs-scroll="true" data-bs-backdrop="false" data-bs-keyboard="false">',
|
||||
'</div>'
|
||||
].join('')
|
||||
fixtureEl.innerHTML = '<div class="offcanvas" data-bs-scroll="true" data-bs-backdrop="false" data-bs-keyboard="false"></div>'
|
||||
|
||||
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 = '<div class="offcanvas"></div>'
|
||||
|
@@ -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 = [
|
||||
'<ul class="nav"><li><a href="#home" role="tab">Home</a></li></ul>',
|
||||
'<ul><li id="home"></li></ul>'
|
||||
'<ul class="nav">',
|
||||
' <li><a href="#home" role="tab">Home</a></li>',
|
||||
'</ul>',
|
||||
'<ul>',
|
||||
' <li id="home"></li>',
|
||||
'</ul>'
|
||||
].join('')
|
||||
|
||||
const tabEl = fixtureEl.querySelector('[href="#home"]')
|
||||
@@ -112,7 +116,10 @@ describe('Tab', () => {
|
||||
' <button type="button" data-bs-target="#home" role="tab">Home</button>',
|
||||
' <button type="button" id="triggerProfile" data-bs-target="#profile" role="tab">Profile</a>',
|
||||
'</nav>',
|
||||
'<div><div id="home" role="tabpanel"></div><div id="profile" role="tabpanel"></div></div>'
|
||||
'<div>',
|
||||
' <div id="home" role="tabpanel"></div>',
|
||||
' <div id="profile" role="tabpanel"></div>',
|
||||
'</div>'
|
||||
].join('')
|
||||
|
||||
const profileTriggerEl = fixtureEl.querySelector('#triggerProfile')
|
||||
@@ -132,7 +139,10 @@ describe('Tab', () => {
|
||||
' <button type="button" data-bs-target="#home" role="tab">Home</button>',
|
||||
' <button type="button" id="triggerProfile" data-bs-target="#profile" role="tab">Profile</button>',
|
||||
'</div>',
|
||||
'<div><div id="home" role="tabpanel"></div><div id="profile" role="tabpanel"></div></div>'
|
||||
'<div>',
|
||||
' <div id="home" role="tabpanel"></div>',
|
||||
' <div id="profile" role="tabpanel"></div>',
|
||||
'</div>'
|
||||
].join('')
|
||||
|
||||
const profileTriggerEl = fixtureEl.querySelector('#triggerProfile')
|
||||
|
@@ -416,13 +416,14 @@ describe('Tooltip', () => {
|
||||
})
|
||||
|
||||
it('should show a tooltip when hovering a children element', done => {
|
||||
fixtureEl.innerHTML =
|
||||
'<a href="#" rel="tooltip" title="Another tooltip">' +
|
||||
'<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50" viewBox="0 0 100 100">' +
|
||||
'<rect width="100%" fill="#563d7c"/>' +
|
||||
'<circle cx="50" cy="50" r="30" fill="#fff"/>' +
|
||||
'</svg>' +
|
||||
fixtureEl.innerHTML = [
|
||||
'<a href="#" rel="tooltip" title="Another tooltip">',
|
||||
' <svg xmlns="http://www.w3.org/2000/svg" width="50" height="50" viewBox="0 0 100 100">',
|
||||
' <rect width="100%" fill="#563d7c"/>',
|
||||
' <circle cx="50" cy="50" r="30" fill="#fff"/>',
|
||||
' </svg>',
|
||||
'</a>'
|
||||
].join('')
|
||||
|
||||
const tooltipEl = fixtureEl.querySelector('a')
|
||||
const tooltip = new Tooltip(tooltipEl)
|
||||
|
@@ -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 = [
|
||||
'<div id="wrapper">',
|
||||
'</div>'
|
||||
].join('')
|
||||
fixtureEl.innerHTML = '<div id="wrapper"></div>'
|
||||
|
||||
const wrapper = fixtureEl.querySelector('#wrapper')
|
||||
const instance = new Backdrop({
|
||||
|
@@ -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 = [
|
||||
'<div>',
|
||||
|
@@ -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 = [
|
||||
'<div style="height: 110vh; width: 100%"></div>'
|
||||
].join('')
|
||||
fixtureEl.innerHTML = '<div style="height: 110vh; width: 100%"></div>'
|
||||
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 = [
|
||||
'<div style="height: 110vh; width: 100%"></div>'
|
||||
].join('')
|
||||
fixtureEl.innerHTML = '<div style="height: 110vh; width: 100%"></div>'
|
||||
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 = [
|
||||
'<div style="height: 110vh; width: 100%"></div>'
|
||||
].join('')
|
||||
fixtureEl.innerHTML = '<div style="height: 110vh; width: 100%"></div>'
|
||||
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 = [
|
||||
'<div style="height: 110vh; width: 100%"></div>'
|
||||
].join('')
|
||||
fixtureEl.innerHTML = '<div style="height: 110vh; width: 100%"></div>'
|
||||
|
||||
const result = new ScrollBarHelper().getWidth()
|
||||
|
||||
@@ -109,7 +103,7 @@ describe('ScrollBar', () => {
|
||||
describe('hide - reset', () => {
|
||||
it('should adjust the inline padding of fixed elements which are full-width', done => {
|
||||
fixtureEl.innerHTML = [
|
||||
'<div style="height: 110vh; width: 100%">' +
|
||||
'<div style="height: 110vh; width: 100%">',
|
||||
' <div class="fixed-top" id="fixed1" style="padding-right: 0px; width: 100vw"></div>',
|
||||
' <div class="fixed-top" id="fixed2" style="padding-right: 5px; width: 100vw"></div>',
|
||||
'</div>'
|
||||
@@ -145,7 +139,7 @@ describe('ScrollBar', () => {
|
||||
|
||||
it('should adjust the inline margin and padding of sticky elements', done => {
|
||||
fixtureEl.innerHTML = [
|
||||
'<div style="height: 110vh">' +
|
||||
'<div style="height: 110vh">',
|
||||
' <div class="sticky-top" style="margin-right: 10px; padding-right: 20px; width: 100vw; height: 10px"></div>',
|
||||
'</div>'
|
||||
].join('')
|
||||
@@ -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 = [
|
||||
'<div class="sticky-top" style="margin-right: 0px; padding-right: 0px; width: 50vw"></div>'
|
||||
].join('')
|
||||
fixtureEl.innerHTML = '<div class="sticky-top" style="margin-right: 0px; padding-right: 0px; width: 50vw"></div>'
|
||||
|
||||
const stickyTopEl = fixtureEl.querySelector('.sticky-top')
|
||||
const originalMargin = getMarginX(stickyTopEl)
|
||||
@@ -195,7 +187,7 @@ 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 = [
|
||||
'<div style="height: 110vh; width: 100%">' +
|
||||
'<div style="height: 110vh; width: 100%">',
|
||||
' <div class="sticky-top" id="sticky" style="width: 100vw"></div>',
|
||||
'</div>'
|
||||
].join('')
|
||||
@@ -243,7 +235,7 @@ describe('ScrollBar', () => {
|
||||
fixtureEl.innerHTML = [
|
||||
'<style>',
|
||||
' body {',
|
||||
` padding-right: ${styleSheetPadding} }`,
|
||||
` padding-right: ${styleSheetPadding}`,
|
||||
' }',
|
||||
'</style>'
|
||||
].join('')
|
||||
@@ -283,7 +275,7 @@ describe('ScrollBar', () => {
|
||||
fixtureEl.innerHTML = [
|
||||
'<style>',
|
||||
' body {',
|
||||
` padding-right: ${styleSheetPadding} }`,
|
||||
` padding-right: ${styleSheetPadding}`,
|
||||
' }',
|
||||
'</style>'
|
||||
].join('')
|
||||
|
@@ -49,7 +49,7 @@ describe('Swipe', () => {
|
||||
'</style>'
|
||||
].join('')
|
||||
|
||||
fixtureEl.innerHTML = '<div id="swipeEl"></div>' + cssStyle
|
||||
fixtureEl.innerHTML = `<div id="swipeEl"></div>${cssStyle}`
|
||||
swipeEl = fixtureEl.querySelector('div')
|
||||
})
|
||||
|
||||
|
@@ -113,9 +113,9 @@ describe('TemplateFactory', () => {
|
||||
describe('Content', () => {
|
||||
it('add simple text content', () => {
|
||||
const template = [
|
||||
'<div>' +
|
||||
'<div class="foo"></div>' +
|
||||
'<div class="foo2"></div>' +
|
||||
'<div>',
|
||||
' <div class="foo"></div>',
|
||||
' <div class="foo2"></div>',
|
||||
'</div>'
|
||||
].join('')
|
||||
|
||||
@@ -245,12 +245,13 @@ describe('TemplateFactory', () => {
|
||||
expect(factory.hasContent()).toBeFalse()
|
||||
})
|
||||
})
|
||||
|
||||
describe('changeContent', () => {
|
||||
it('should change Content', () => {
|
||||
const template = [
|
||||
'<div>' +
|
||||
'<div class="foo"></div>' +
|
||||
'<div class="foo2"></div>' +
|
||||
'<div>',
|
||||
' <div class="foo"></div>',
|
||||
' <div class="foo2"></div>',
|
||||
'</div>'
|
||||
].join('')
|
||||
|
||||
@@ -276,9 +277,9 @@ describe('TemplateFactory', () => {
|
||||
|
||||
it('should change only the given, content', () => {
|
||||
const template = [
|
||||
'<div>' +
|
||||
'<div class="foo"></div>' +
|
||||
'<div class="foo2"></div>' +
|
||||
'<div>',
|
||||
' <div class="foo"></div>',
|
||||
' <div class="foo2"></div>',
|
||||
'</div>'
|
||||
].join('')
|
||||
|
||||
|
Reference in New Issue
Block a user