0
0
mirror of https://github.com/twbs/bootstrap.git synced 2024-12-01 13:24:25 +01:00

tests: tweak Jasmine's matchers usage

Use:

* toBeNull
* toEqual
* toBeTrue
* toBeFalse
* toHaveSize
* toHaveClass
This commit is contained in:
XhmikosR 2021-10-14 18:16:54 +03:00
parent 5739bf7637
commit eb54e1a1ce
24 changed files with 438 additions and 437 deletions

View File

@ -35,7 +35,7 @@ Currently we're aiming for at least 90% test coverage for our code. To ensure yo
describe('getInstance', () => {
it('should return null if there is no instance', () => {
// Make assertion
expect(Tab.getInstance(fixtureEl)).toEqual(null)
expect(Tab.getInstance(fixtureEl)).toBeNull()
})
it('should return this instance', () => {

View File

@ -25,7 +25,7 @@ describe('Alert', () => {
})
it('should return version', () => {
expect(typeof Alert.VERSION).toEqual('string')
expect(Alert.VERSION).toEqual(jasmine.any(String))
})
describe('DATA_KEY', () => {
@ -45,7 +45,7 @@ describe('Alert', () => {
const button = document.querySelector('button')
button.click()
expect(document.querySelectorAll('.alert').length).toEqual(0)
expect(document.querySelectorAll('.alert')).toHaveSize(0)
})
it('should close an alert without instantiating it manually with the parent selector', () => {
@ -58,7 +58,7 @@ describe('Alert', () => {
const button = document.querySelector('button')
button.click()
expect(document.querySelectorAll('.alert').length).toEqual(0)
expect(document.querySelectorAll('.alert')).toHaveSize(0)
})
})
@ -71,7 +71,7 @@ describe('Alert', () => {
const alert = new Alert(alertEl)
alertEl.addEventListener('closed.bs.alert', () => {
expect(document.querySelectorAll('.alert').length).toEqual(0)
expect(document.querySelectorAll('.alert')).toHaveSize(0)
expect(spy).not.toHaveBeenCalled()
done()
})
@ -90,7 +90,7 @@ describe('Alert', () => {
})
alertEl.addEventListener('closed.bs.alert', () => {
expect(document.querySelectorAll('.alert').length).toEqual(0)
expect(document.querySelectorAll('.alert')).toHaveSize(0)
done()
})
@ -225,7 +225,7 @@ describe('Alert', () => {
const div = fixtureEl.querySelector('div')
expect(Alert.getInstance(div)).toEqual(null)
expect(Alert.getInstance(div)).toBeNull()
})
})
@ -246,7 +246,7 @@ describe('Alert', () => {
const div = fixtureEl.querySelector('div')
expect(Alert.getInstance(div)).toEqual(null)
expect(Alert.getInstance(div)).toBeNull()
expect(Alert.getOrCreateInstance(div)).toBeInstanceOf(Alert)
})
})

View File

@ -37,7 +37,7 @@ describe('Base Component', () => {
describe('Static Methods', () => {
describe('VERSION', () => {
it('should return version', () => {
expect(typeof DummyClass.VERSION).toEqual('string')
expect(DummyClass.VERSION).toEqual(jasmine.any(String))
})
})
@ -141,7 +141,7 @@ describe('Base Component', () => {
const div = fixtureEl.querySelector('div')
expect(DummyClass.getInstance(div)).toEqual(null)
expect(DummyClass.getInstance(div)).toBeNull()
})
})
describe('getOrCreateInstance', () => {
@ -157,7 +157,7 @@ describe('Base Component', () => {
fixtureEl.innerHTML = '<div id="foo"></div>'
element = fixtureEl.querySelector('#foo')
expect(DummyClass.getInstance(element)).toEqual(null)
expect(DummyClass.getInstance(element)).toBeNull()
expect(DummyClass.getOrCreateInstance(element)).toBeInstanceOf(DummyClass)
})
})

View File

@ -45,19 +45,19 @@ describe('Button', () => {
const divTest = fixtureEl.querySelector('.test')
const btnTestParent = fixtureEl.querySelector('.testParent')
expect(btn.classList.contains('active')).toEqual(false)
expect(btn).not.toHaveClass('active')
btn.click()
expect(btn.classList.contains('active')).toEqual(true)
expect(btn).toHaveClass('active')
btn.click()
expect(btn.classList.contains('active')).toEqual(false)
expect(btn).not.toHaveClass('active')
divTest.click()
expect(btnTestParent.classList.contains('active')).toEqual(true)
expect(btnTestParent).toHaveClass('active')
})
})
@ -69,12 +69,12 @@ describe('Button', () => {
const button = new Button(btnEl)
expect(btnEl.getAttribute('aria-pressed')).toEqual('false')
expect(btnEl.classList.contains('active')).toEqual(false)
expect(btnEl).not.toHaveClass('active')
button.toggle()
expect(btnEl.getAttribute('aria-pressed')).toEqual('true')
expect(btnEl.classList.contains('active')).toEqual(true)
expect(btnEl).toHaveClass('active')
})
})
@ -121,7 +121,7 @@ describe('Button', () => {
jQueryMock.fn.button.call(jQueryMock, 'toggle')
expect(Button.getInstance(btnEl)).not.toBeNull()
expect(btnEl.classList.contains('active')).toEqual(true)
expect(btnEl).toHaveClass('active')
})
it('should just create a button instance without calling toggle', () => {
@ -135,7 +135,7 @@ describe('Button', () => {
jQueryMock.fn.button.call(jQueryMock)
expect(Button.getInstance(btnEl)).not.toBeNull()
expect(btnEl.classList.contains('active')).toEqual(false)
expect(btnEl).not.toHaveClass('active')
})
})
@ -155,7 +155,7 @@ describe('Button', () => {
const div = fixtureEl.querySelector('div')
expect(Button.getInstance(div)).toEqual(null)
expect(Button.getInstance(div)).toBeNull()
})
})
@ -176,7 +176,7 @@ describe('Button', () => {
const div = fixtureEl.querySelector('div')
expect(Button.getInstance(div)).toEqual(null)
expect(Button.getInstance(div)).toBeNull()
expect(Button.getOrCreateInstance(div)).toBeInstanceOf(Button)
})
})

View File

@ -143,7 +143,7 @@ describe('Carousel', () => {
carouselEl.addEventListener('keydown', event => {
expect(carousel._keydown).toHaveBeenCalled()
expect(event.defaultPrevented).toEqual(false)
expect(event.defaultPrevented).toBeFalse()
done()
})
@ -285,7 +285,7 @@ describe('Carousel', () => {
carousel.prev()
setTimeout(() => {
expect(firstElement.classList.contains('active')).toEqual(true)
expect(firstElement).toHaveClass('active')
done()
}, 10)
})
@ -368,7 +368,7 @@ describe('Carousel', () => {
spyOn(carousel, '_slide').and.callThrough()
carouselEl.addEventListener('slid.bs.carousel', event => {
expect(item.classList.contains('active')).toEqual(true)
expect(item).toHaveClass('active')
expect(carousel._slide).toHaveBeenCalledWith('right')
expect(event.direction).toEqual('right')
stylesCarousel.remove()
@ -413,7 +413,7 @@ describe('Carousel', () => {
spyOn(carousel, '_slide').and.callThrough()
carouselEl.addEventListener('slid.bs.carousel', event => {
expect(item.classList.contains('active')).toEqual(false)
expect(item).not.toHaveClass('active')
expect(carousel._slide).toHaveBeenCalledWith('left')
expect(event.direction).toEqual('left')
stylesCarousel.remove()
@ -453,7 +453,7 @@ describe('Carousel', () => {
spyOn(carousel, '_slide').and.callThrough()
carouselEl.addEventListener('slid.bs.carousel', event => {
expect(item.classList.contains('active')).toEqual(true)
expect(item).toHaveClass('active')
expect(carousel._slide).toHaveBeenCalledWith('right')
expect(event.direction).toEqual('right')
delete document.documentElement.ontouchstart
@ -492,7 +492,7 @@ describe('Carousel', () => {
spyOn(carousel, '_slide').and.callThrough()
carouselEl.addEventListener('slid.bs.carousel', event => {
expect(item.classList.contains('active')).toEqual(false)
expect(item).not.toHaveClass('active')
expect(carousel._slide).toHaveBeenCalledWith('left')
expect(event.direction).toEqual('left')
delete document.documentElement.ontouchstart
@ -632,7 +632,7 @@ describe('Carousel', () => {
const doneTest = () => {
setTimeout(() => {
expect(slidEvent).toEqual(false)
expect(slidEvent).toBeFalse()
done()
}, 20)
}
@ -665,7 +665,7 @@ describe('Carousel', () => {
const onSlide = event => {
expect(event.direction).toEqual('left')
expect(event.relatedTarget.classList.contains('carousel-item')).toEqual(true)
expect(event.relatedTarget).toHaveClass('carousel-item')
expect(event.from).toEqual(0)
expect(event.to).toEqual(1)
@ -700,7 +700,7 @@ describe('Carousel', () => {
const onSlid = event => {
expect(event.direction).toEqual('left')
expect(event.relatedTarget.classList.contains('carousel-item')).toEqual(true)
expect(event.relatedTarget).toHaveClass('carousel-item')
expect(event.from).toEqual(0)
expect(event.to).toEqual(1)
@ -761,9 +761,9 @@ describe('Carousel', () => {
const carousel = new Carousel(carouselEl)
carouselEl.addEventListener('slid.bs.carousel', () => {
expect(firstIndicator.classList.contains('active')).toEqual(false)
expect(firstIndicator.hasAttribute('aria-current')).toEqual(false)
expect(secondIndicator.classList.contains('active')).toEqual(true)
expect(firstIndicator).not.toHaveClass('active')
expect(firstIndicator.hasAttribute('aria-current')).toBeFalse()
expect(secondIndicator).toHaveClass('active')
expect(secondIndicator.getAttribute('aria-current')).toEqual('true')
done()
})
@ -859,7 +859,7 @@ describe('Carousel', () => {
expect(carousel.cycle).toHaveBeenCalledWith(true)
expect(window.clearInterval).toHaveBeenCalled()
expect(carousel._isPaused).toEqual(true)
expect(carousel._isPaused).toBeTrue()
})
it('should not call cycle if nothing is in transition', () => {
@ -885,7 +885,7 @@ describe('Carousel', () => {
expect(carousel.cycle).not.toHaveBeenCalled()
expect(window.clearInterval).toHaveBeenCalled()
expect(carousel._isPaused).toEqual(true)
expect(carousel._isPaused).toBeTrue()
})
it('should not set is paused at true if an event is passed', () => {
@ -910,7 +910,7 @@ describe('Carousel', () => {
carousel.pause(event)
expect(window.clearInterval).toHaveBeenCalled()
expect(carousel._isPaused).toEqual(false)
expect(carousel._isPaused).toBeFalse()
})
})
@ -1175,7 +1175,7 @@ describe('Carousel', () => {
const carouselEl = fixtureEl.querySelector('div')
const carousel = new Carousel(carouselEl, {})
expect(isRTL()).toEqual(true, 'rtl has to be true')
expect(isRTL()).toBeTrue()
expect(carousel._directionToOrder('left')).toEqual('prev')
expect(carousel._directionToOrder('prev')).toEqual('prev')
@ -1292,7 +1292,7 @@ describe('Carousel', () => {
const div = fixtureEl.querySelector('div')
expect(Carousel.getInstance(div)).toEqual(null)
expect(Carousel.getInstance(div)).toBeNull()
})
})
@ -1313,7 +1313,7 @@ describe('Carousel', () => {
const div = fixtureEl.querySelector('div')
expect(Carousel.getInstance(div)).toEqual(null)
expect(Carousel.getInstance(div)).toBeNull()
expect(Carousel.getOrCreateInstance(div)).toBeInstanceOf(Carousel)
})
@ -1322,7 +1322,7 @@ describe('Carousel', () => {
const div = fixtureEl.querySelector('div')
expect(Carousel.getInstance(div)).toEqual(null)
expect(Carousel.getInstance(div)).toBeNull()
const carousel = Carousel.getOrCreateInstance(div, {
interval: 1
})
@ -1441,7 +1441,7 @@ describe('Carousel', () => {
next.click()
setTimeout(() => {
expect(item2.classList.contains('active')).toEqual(true)
expect(item2).toHaveClass('active')
done()
}, 10)
})
@ -1465,7 +1465,7 @@ describe('Carousel', () => {
next.click()
setTimeout(() => {
expect(item2.classList.contains('active')).toEqual(true)
expect(item2).toHaveClass('active')
done()
}, 10)
})
@ -1488,7 +1488,7 @@ describe('Carousel', () => {
next.click()
setTimeout(() => {
expect(item2.classList.contains('active')).toEqual(true)
expect(item2).toHaveClass('active')
done()
}, 10)
})

View File

@ -159,8 +159,8 @@ describe('Collapse', () => {
}))
collapseEl2.addEventListener('shown.bs.collapse', () => {
expect(collapseEl2.classList.contains('show')).toEqual(true)
expect(collapseEl1.classList.contains('show')).toEqual(false)
expect(collapseEl2).toHaveClass('show')
expect(collapseEl1).not.toHaveClass('show')
done()
})
@ -212,7 +212,7 @@ describe('Collapse', () => {
expect(collapseEl.style.height).toEqual('0px')
})
collapseEl.addEventListener('shown.bs.collapse', () => {
expect(collapseEl.classList.contains('show')).toEqual(true)
expect(collapseEl).toHaveClass('show')
expect(collapseEl.style.height).toEqual('')
done()
})
@ -232,7 +232,7 @@ describe('Collapse', () => {
expect(collapseEl.style.width).toEqual('0px')
})
collapseEl.addEventListener('shown.bs.collapse', () => {
expect(collapseEl.classList.contains('show')).toEqual(true)
expect(collapseEl).toHaveClass('show')
expect(collapseEl.style.width).toEqual('')
done()
})
@ -257,8 +257,8 @@ describe('Collapse', () => {
})
el1.addEventListener('shown.bs.collapse', () => {
expect(el1.classList.contains('show')).toEqual(true)
expect(el2.classList.contains('show')).toEqual(true)
expect(el1).toHaveClass('show')
expect(el2).toHaveClass('show')
done()
})
@ -307,16 +307,16 @@ describe('Collapse', () => {
const childCollapseEl2 = el('#childContent2')
parentCollapseEl.addEventListener('shown.bs.collapse', () => {
expect(parentCollapseEl.classList.contains('show')).toEqual(true)
expect(parentCollapseEl).toHaveClass('show')
childBtn1.click()
})
childCollapseEl1.addEventListener('shown.bs.collapse', () => {
expect(childCollapseEl1.classList.contains('show')).toEqual(true)
expect(childCollapseEl1).toHaveClass('show')
childBtn2.click()
})
childCollapseEl2.addEventListener('shown.bs.collapse', () => {
expect(childCollapseEl2.classList.contains('show')).toEqual(true)
expect(childCollapseEl1.classList.contains('show')).toEqual(false)
expect(childCollapseEl2).toHaveClass('show')
expect(childCollapseEl1).not.toHaveClass('show')
done()
})
@ -359,7 +359,7 @@ describe('Collapse', () => {
})
el.addEventListener('shown.bs.collapse', () => {
expect(activeTabPane.classList.contains('show')).toEqual(true)
expect(activeTabPane).toHaveClass('show')
times++
if (times === 2) {
done()
@ -440,7 +440,7 @@ describe('Collapse', () => {
})
collapseEl.addEventListener('hidden.bs.collapse', () => {
expect(collapseEl.classList.contains('show')).toEqual(false)
expect(collapseEl).not.toHaveClass('show')
expect(collapseEl.style.height).toEqual('')
done()
})
@ -489,7 +489,7 @@ describe('Collapse', () => {
collapse.dispose()
expect(Collapse.getInstance(collapseEl)).toEqual(null)
expect(Collapse.getInstance(collapseEl)).toBeNull()
})
})
@ -508,8 +508,8 @@ describe('Collapse', () => {
spyOn(Event.prototype, 'preventDefault').and.callThrough()
triggerEl.addEventListener('click', event => {
expect(event.target.isEqualNode(nestedTriggerEl)).toEqual(true)
expect(event.delegateTarget.isEqualNode(triggerEl)).toEqual(true)
expect(event.target.isEqualNode(nestedTriggerEl)).toBeTrue()
expect(event.delegateTarget.isEqualNode(triggerEl)).toBeTrue()
expect(Event.prototype.preventDefault).toHaveBeenCalled()
done()
})
@ -530,9 +530,9 @@ describe('Collapse', () => {
collapse2.addEventListener('shown.bs.collapse', () => {
expect(trigger.getAttribute('aria-expanded')).toEqual('true')
expect(trigger.classList.contains('collapsed')).toEqual(false)
expect(collapse1.classList.contains('show')).toEqual(true)
expect(collapse1.classList.contains('show')).toEqual(true)
expect(trigger).not.toHaveClass('collapsed')
expect(collapse1).toHaveClass('show')
expect(collapse1).toHaveClass('show')
done()
})
@ -552,9 +552,9 @@ describe('Collapse', () => {
collapse2.addEventListener('hidden.bs.collapse', () => {
expect(trigger.getAttribute('aria-expanded')).toEqual('false')
expect(trigger.classList.contains('collapsed')).toEqual(true)
expect(collapse1.classList.contains('show')).toEqual(false)
expect(collapse1.classList.contains('show')).toEqual(false)
expect(trigger).toHaveClass('collapsed')
expect(collapse1).not.toHaveClass('show')
expect(collapse1).not.toHaveClass('show')
done()
})
@ -575,8 +575,8 @@ describe('Collapse', () => {
collapseTest1.addEventListener('shown.bs.collapse', () => {
expect(link1.getAttribute('aria-expanded')).toEqual('true')
expect(link2.getAttribute('aria-expanded')).toEqual('true')
expect(link1.classList.contains('collapsed')).toEqual(false)
expect(link2.classList.contains('collapsed')).toEqual(false)
expect(link1).not.toHaveClass('collapsed')
expect(link2).not.toHaveClass('collapsed')
done()
})
@ -597,8 +597,8 @@ describe('Collapse', () => {
collapseTest1.addEventListener('hidden.bs.collapse', () => {
expect(link1.getAttribute('aria-expanded')).toEqual('false')
expect(link2.getAttribute('aria-expanded')).toEqual('false')
expect(link1.classList.contains('collapsed')).toEqual(true)
expect(link2.classList.contains('collapsed')).toEqual(true)
expect(link1).toHaveClass('collapsed')
expect(link2).toHaveClass('collapsed')
done()
})
@ -625,12 +625,12 @@ describe('Collapse', () => {
const collapseTwo = fixtureEl.querySelector('#collapseTwo')
collapseOne.addEventListener('shown.bs.collapse', () => {
expect(collapseOne.classList.contains('show')).toEqual(true)
expect(collapseTwo.classList.contains('show')).toEqual(false)
expect(collapseOne).toHaveClass('show')
expect(collapseTwo).not.toHaveClass('show')
collapseTwo.addEventListener('shown.bs.collapse', () => {
expect(collapseOne.classList.contains('show')).toEqual(false)
expect(collapseTwo.classList.contains('show')).toEqual(true)
expect(collapseOne).not.toHaveClass('show')
expect(collapseTwo).toHaveClass('show')
done()
})
@ -650,8 +650,8 @@ describe('Collapse', () => {
const collapseEl = fixtureEl.querySelector('#collapsediv1')
collapseEl.addEventListener('shown.bs.collapse', () => {
expect(collapseEl.classList.contains('show')).toEqual(true)
expect(target.checked).toEqual(true)
expect(collapseEl).toHaveClass('show')
expect(target.checked).toBeTrue()
done()
})
@ -684,21 +684,21 @@ describe('Collapse', () => {
const collapseTwoEl = fixtureEl.querySelector('#collapseTwo')
collapseOneEl.addEventListener('shown.bs.collapse', () => {
expect(collapseOneEl.classList.contains('show')).toEqual(true)
expect(triggerEl.classList.contains('collapsed')).toEqual(false)
expect(collapseOneEl).toHaveClass('show')
expect(triggerEl).not.toHaveClass('collapsed')
expect(triggerEl.getAttribute('aria-expanded')).toEqual('true')
expect(collapseTwoEl.classList.contains('show')).toEqual(false)
expect(triggerTwoEl.classList.contains('collapsed')).toEqual(true)
expect(collapseTwoEl).not.toHaveClass('show')
expect(triggerTwoEl).toHaveClass('collapsed')
expect(triggerTwoEl.getAttribute('aria-expanded')).toEqual('false')
collapseTwoEl.addEventListener('shown.bs.collapse', () => {
expect(collapseOneEl.classList.contains('show')).toEqual(false)
expect(triggerEl.classList.contains('collapsed')).toEqual(true)
expect(collapseOneEl).not.toHaveClass('show')
expect(triggerEl).toHaveClass('collapsed')
expect(triggerEl.getAttribute('aria-expanded')).toEqual('false')
expect(collapseTwoEl.classList.contains('show')).toEqual(true)
expect(triggerTwoEl.classList.contains('collapsed')).toEqual(false)
expect(collapseTwoEl).toHaveClass('show')
expect(triggerTwoEl).not.toHaveClass('collapsed')
expect(triggerTwoEl.getAttribute('aria-expanded')).toEqual('true')
done()
})
@ -733,21 +733,21 @@ describe('Collapse', () => {
}
function firstTest() {
expect(collapseOneOne.classList.contains('show')).toEqual(true)
expect(collapseOneTwo.classList.contains('show')).toEqual(true)
expect(collapseOneOne).toHaveClass('show')
expect(collapseOneTwo).toHaveClass('show')
expect(collapseTwoOne.classList.contains('show')).toEqual(false)
expect(collapseTwoTwo.classList.contains('show')).toEqual(false)
expect(collapseTwoOne).not.toHaveClass('show')
expect(collapseTwoTwo).not.toHaveClass('show')
triggerTwo.click()
}
function secondTest() {
expect(collapseOneOne.classList.contains('show')).toEqual(false)
expect(collapseOneTwo.classList.contains('show')).toEqual(false)
expect(collapseOneOne).not.toHaveClass('show')
expect(collapseOneTwo).not.toHaveClass('show')
expect(collapseTwoOne.classList.contains('show')).toEqual(true)
expect(collapseTwoTwo.classList.contains('show')).toEqual(true)
expect(collapseTwoOne).toHaveClass('show')
expect(collapseTwoTwo).toHaveClass('show')
done()
}
@ -815,9 +815,9 @@ describe('Collapse', () => {
const nestedCollapseOne = fixtureEl.querySelector('#nestedCollapseOne')
function handlerCollapseOne() {
expect(collapseOne.classList.contains('show')).toEqual(true)
expect(collapseTwo.classList.contains('show')).toEqual(false)
expect(nestedCollapseOne.classList.contains('show')).toEqual(false)
expect(collapseOne).toHaveClass('show')
expect(collapseTwo).not.toHaveClass('show')
expect(nestedCollapseOne).not.toHaveClass('show')
nestedCollapseOne.addEventListener('shown.bs.collapse', handlerNestedCollapseOne)
nestedTrigger.click()
@ -825,14 +825,14 @@ describe('Collapse', () => {
}
function handlerNestedCollapseOne() {
expect(collapseOne.classList.contains('show')).toEqual(true)
expect(collapseTwo.classList.contains('show')).toEqual(false)
expect(nestedCollapseOne.classList.contains('show')).toEqual(true)
expect(collapseOne).toHaveClass('show')
expect(collapseTwo).not.toHaveClass('show')
expect(nestedCollapseOne).toHaveClass('show')
collapseTwo.addEventListener('shown.bs.collapse', () => {
expect(collapseOne.classList.contains('show')).toEqual(false)
expect(collapseTwo.classList.contains('show')).toEqual(true)
expect(nestedCollapseOne.classList.contains('show')).toEqual(true)
expect(collapseOne).not.toHaveClass('show')
expect(collapseTwo).toHaveClass('show')
expect(nestedCollapseOne).toHaveClass('show')
done()
})
@ -860,33 +860,33 @@ describe('Collapse', () => {
const target2 = fixtureEl.querySelector('#test2')
const target2Shown = () => {
expect(trigger1.classList.contains('collapsed')).toEqual(false)
expect(trigger1).not.toHaveClass('collapsed')
expect(trigger1.getAttribute('aria-expanded')).toEqual('true')
expect(trigger2.classList.contains('collapsed')).toEqual(false)
expect(trigger2).not.toHaveClass('collapsed')
expect(trigger2.getAttribute('aria-expanded')).toEqual('true')
expect(trigger3.classList.contains('collapsed')).toEqual(false)
expect(trigger3).not.toHaveClass('collapsed')
expect(trigger3.getAttribute('aria-expanded')).toEqual('true')
target2.addEventListener('hidden.bs.collapse', () => {
expect(trigger1.classList.contains('collapsed')).toEqual(false)
expect(trigger1).not.toHaveClass('collapsed')
expect(trigger1.getAttribute('aria-expanded')).toEqual('true')
expect(trigger2.classList.contains('collapsed')).toEqual(true)
expect(trigger2).toHaveClass('collapsed')
expect(trigger2.getAttribute('aria-expanded')).toEqual('false')
expect(trigger3.classList.contains('collapsed')).toEqual(false)
expect(trigger3).not.toHaveClass('collapsed')
expect(trigger3.getAttribute('aria-expanded')).toEqual('true')
target1.addEventListener('hidden.bs.collapse', () => {
expect(trigger1.classList.contains('collapsed')).toEqual(true)
expect(trigger1).toHaveClass('collapsed')
expect(trigger1.getAttribute('aria-expanded')).toEqual('false')
expect(trigger2.classList.contains('collapsed')).toEqual(true)
expect(trigger2).toHaveClass('collapsed')
expect(trigger2.getAttribute('aria-expanded')).toEqual('false')
expect(trigger3.classList.contains('collapsed')).toEqual(true)
expect(trigger3).toHaveClass('collapsed')
expect(trigger3.getAttribute('aria-expanded')).toEqual('false')
done()
})
@ -961,7 +961,7 @@ describe('Collapse', () => {
const div = fixtureEl.querySelector('div')
expect(Collapse.getInstance(div)).toEqual(null)
expect(Collapse.getInstance(div)).toBeNull()
})
})
@ -982,7 +982,7 @@ describe('Collapse', () => {
const div = fixtureEl.querySelector('div')
expect(Collapse.getInstance(div)).toEqual(null)
expect(Collapse.getInstance(div)).toBeNull()
expect(Collapse.getOrCreateInstance(div)).toBeInstanceOf(Collapse)
})
@ -991,13 +991,13 @@ describe('Collapse', () => {
const div = fixtureEl.querySelector('div')
expect(Collapse.getInstance(div)).toEqual(null)
expect(Collapse.getInstance(div)).toBeNull()
const collapse = Collapse.getOrCreateInstance(div, {
toggle: false
})
expect(collapse).toBeInstanceOf(Collapse)
expect(collapse._config.toggle).toEqual(false)
expect(collapse._config.toggle).toBeFalse()
})
it('should return the instance when exists without given configuration', () => {
@ -1015,7 +1015,7 @@ describe('Collapse', () => {
expect(collapse).toBeInstanceOf(Collapse)
expect(collapse2).toEqual(collapse)
expect(collapse2._config.toggle).toEqual(false)
expect(collapse2._config.toggle).toBeFalse()
})
})
})

View File

@ -50,7 +50,7 @@ describe('Data', () => {
Data.set(div, TEST_KEY, data)
expect(Data.get(div, TEST_KEY)).toBe(data)
expect(Data.get(div, TEST_KEY)).toEqual(data)
})
it('should overwrite data if something is already stored', () => {
@ -60,6 +60,7 @@ describe('Data', () => {
Data.set(div, TEST_KEY, data)
Data.set(div, TEST_KEY, copy)
// Using `toBe` since spread creates a shallow copy
expect(Data.get(div, TEST_KEY)).not.toBe(data)
expect(Data.get(div, TEST_KEY)).toBe(copy)
})
@ -76,7 +77,7 @@ describe('Data', () => {
Data.set(div, TEST_KEY, data)
Data.remove(div, UNKNOWN_KEY)
expect(Data.get(div, TEST_KEY)).toBe(data)
expect(Data.get(div, TEST_KEY)).toEqual(data)
})
it('should remove data for a given key', () => {
@ -99,7 +100,7 @@ describe('Data', () => {
Data.set(div, UNKNOWN_KEY, copy)
expect(console.error).toHaveBeenCalled()
expect(Data.get(div, UNKNOWN_KEY)).toBe(null)
expect(Data.get(div, UNKNOWN_KEY)).toBeNull()
})
/* eslint-enable no-console */
})

View File

@ -105,10 +105,10 @@ describe('EventHandler', () => {
EventHandler.on(outer, 'mouseleave', '.inner', delegateLeaveSpy)
EventHandler.on(sibling, 'mouseenter', () => {
expect(enterSpy.calls.count()).toBe(2)
expect(leaveSpy.calls.count()).toBe(2)
expect(delegateEnterSpy.calls.count()).toBe(2)
expect(delegateLeaveSpy.calls.count()).toBe(2)
expect(enterSpy.calls.count()).toEqual(2)
expect(leaveSpy.calls.count()).toEqual(2)
expect(delegateEnterSpy.calls.count()).toEqual(2)
expect(delegateLeaveSpy.calls.count()).toEqual(2)
done()
})
@ -133,10 +133,10 @@ describe('EventHandler', () => {
moveMouse(inner, outer)
setTimeout(() => {
expect(enterSpy.calls.count()).toBe(1)
expect(leaveSpy.calls.count()).toBe(1)
expect(delegateEnterSpy.calls.count()).toBe(1)
expect(delegateLeaveSpy.calls.count()).toBe(1)
expect(enterSpy.calls.count()).toEqual(1)
expect(leaveSpy.calls.count()).toEqual(1)
expect(delegateEnterSpy.calls.count()).toEqual(1)
expect(delegateLeaveSpy.calls.count()).toEqual(1)
// from outer to inner to sibling (adjacent)
moveMouse(outer, inner)

View File

@ -96,10 +96,10 @@ describe('Manipulator', () => {
const div = fixtureEl.querySelector('div')
expect(Manipulator.getDataAttribute(div, 'test')).toEqual(false)
expect(Manipulator.getDataAttribute(div, 'test')).toBeFalse()
div.setAttribute('data-bs-test', 'true')
expect(Manipulator.getDataAttribute(div, 'test')).toEqual(true)
expect(Manipulator.getDataAttribute(div, 'test')).toBeTrue()
div.setAttribute('data-bs-test', '1')
expect(Manipulator.getDataAttribute(div, 'test')).toEqual(1)
@ -152,8 +152,8 @@ describe('Manipulator', () => {
body.append(forceScrollBars)
const scrollHandler = () => {
expect(window.pageYOffset).toBe(scrollY)
expect(window.pageXOffset).toBe(scrollX)
expect(window.pageYOffset).toEqual(scrollY)
expect(window.pageXOffset).toEqual(scrollX)
const newOffset = Manipulator.offset(div)

View File

@ -73,7 +73,7 @@ describe('SelectorEngine', () => {
describe('parents', () => {
it('should return parents', () => {
expect(SelectorEngine.parents(fixtureEl, 'body').length).toEqual(1)
expect(SelectorEngine.parents(fixtureEl, 'body')).toHaveSize(1)
})
})

View File

@ -165,7 +165,7 @@ describe('Dropdown', () => {
const dropdown = new Dropdown(btnDropdown)
btnDropdown.addEventListener('shown.bs.dropdown', () => {
expect(btnDropdown.classList.contains('show')).toEqual(true)
expect(btnDropdown).toHaveClass('show')
expect(btnDropdown.getAttribute('aria-expanded')).toEqual('true')
done()
})
@ -196,7 +196,7 @@ describe('Dropdown', () => {
const dropdown1 = new Dropdown(btnDropdown1)
firstDropdownEl.addEventListener('shown.bs.dropdown', () => {
expect(btnDropdown1.classList.contains('show')).toEqual(true)
expect(btnDropdown1).toHaveClass('show')
spyOn(dropdown1._popper, 'destroy')
btnDropdown2.click()
})
@ -228,7 +228,7 @@ describe('Dropdown', () => {
spyOn(EventHandler, 'off')
btnDropdown.addEventListener('shown.bs.dropdown', () => {
expect(btnDropdown.classList.contains('show')).toEqual(true)
expect(btnDropdown).toHaveClass('show')
expect(btnDropdown.getAttribute('aria-expanded')).toEqual('true')
expect(EventHandler.on).toHaveBeenCalledWith(jasmine.any(Object), 'mouseover', noop)
@ -236,7 +236,7 @@ describe('Dropdown', () => {
})
btnDropdown.addEventListener('hidden.bs.dropdown', () => {
expect(btnDropdown.classList.contains('show')).toEqual(false)
expect(btnDropdown).not.toHaveClass('show')
expect(btnDropdown.getAttribute('aria-expanded')).toEqual('false')
expect(EventHandler.off).toHaveBeenCalledWith(jasmine.any(Object), 'mouseover', noop)
@ -261,7 +261,7 @@ describe('Dropdown', () => {
const dropdown = new Dropdown(btnDropdown)
btnDropdown.addEventListener('shown.bs.dropdown', () => {
expect(btnDropdown.classList.contains('show')).toEqual(true)
expect(btnDropdown).toHaveClass('show')
expect(btnDropdown.getAttribute('aria-expanded')).toEqual('true')
done()
})
@ -284,7 +284,7 @@ describe('Dropdown', () => {
const dropdown = new Dropdown(btnDropdown)
dropupEl.addEventListener('shown.bs.dropdown', () => {
expect(btnDropdown.classList.contains('show')).toEqual(true)
expect(btnDropdown).toHaveClass('show')
expect(btnDropdown.getAttribute('aria-expanded')).toEqual('true')
done()
})
@ -307,7 +307,7 @@ describe('Dropdown', () => {
const dropdown = new Dropdown(btnDropdown)
dropupEl.addEventListener('shown.bs.dropdown', () => {
expect(btnDropdown.classList.contains('show')).toEqual(true)
expect(btnDropdown).toHaveClass('show')
expect(btnDropdown.getAttribute('aria-expanded')).toEqual('true')
done()
})
@ -330,7 +330,7 @@ describe('Dropdown', () => {
const dropdown = new Dropdown(btnDropdown)
dropendEl.addEventListener('shown.bs.dropdown', () => {
expect(btnDropdown.classList.contains('show')).toEqual(true)
expect(btnDropdown).toHaveClass('show')
expect(btnDropdown.getAttribute('aria-expanded')).toEqual('true')
done()
})
@ -353,7 +353,7 @@ describe('Dropdown', () => {
const dropdown = new Dropdown(btnDropdown)
dropstartEl.addEventListener('shown.bs.dropdown', () => {
expect(btnDropdown.classList.contains('show')).toEqual(true)
expect(btnDropdown).toHaveClass('show')
expect(btnDropdown.getAttribute('aria-expanded')).toEqual('true')
done()
})
@ -377,7 +377,7 @@ describe('Dropdown', () => {
})
btnDropdown.addEventListener('shown.bs.dropdown', () => {
expect(btnDropdown.classList.contains('show')).toEqual(true)
expect(btnDropdown).toHaveClass('show')
expect(btnDropdown.getAttribute('aria-expanded')).toEqual('true')
done()
})
@ -401,7 +401,7 @@ describe('Dropdown', () => {
})
btnDropdown.addEventListener('shown.bs.dropdown', () => {
expect(btnDropdown.classList.contains('show')).toEqual(true)
expect(btnDropdown).toHaveClass('show')
expect(btnDropdown.getAttribute('aria-expanded')).toEqual('true')
done()
})
@ -425,7 +425,7 @@ describe('Dropdown', () => {
})
btnDropdown.addEventListener('shown.bs.dropdown', () => {
expect(btnDropdown.classList.contains('show')).toEqual(true)
expect(btnDropdown).toHaveClass('show')
expect(btnDropdown.getAttribute('aria-expanded')).toEqual('true')
done()
})
@ -474,7 +474,7 @@ describe('Dropdown', () => {
popperConfig: {
onFirstUpdate() {
expect(virtualElement.getBoundingClientRect).toHaveBeenCalled()
expect(btnDropdown.classList.contains('show')).toEqual(true)
expect(btnDropdown).toHaveClass('show')
expect(btnDropdown.getAttribute('aria-expanded')).toEqual('true')
done()
}
@ -606,7 +606,7 @@ describe('Dropdown', () => {
const dropdown = new Dropdown(btnDropdown)
btnDropdown.addEventListener('shown.bs.dropdown', () => {
expect(btnDropdown.classList.contains('show')).toEqual(true)
expect(btnDropdown).toHaveClass('show')
done()
})
@ -734,7 +734,7 @@ describe('Dropdown', () => {
const dropdown = new Dropdown(btnDropdown)
btnDropdown.addEventListener('hidden.bs.dropdown', () => {
expect(dropdownMenu.classList.contains('show')).toEqual(false)
expect(dropdownMenu).not.toHaveClass('show')
expect(btnDropdown.getAttribute('aria-expanded')).toEqual('false')
done()
})
@ -789,7 +789,7 @@ describe('Dropdown', () => {
dropdown.hide()
setTimeout(() => {
expect(dropdownMenu.classList.contains('show')).toEqual(true)
expect(dropdownMenu).toHaveClass('show')
done()
}, 10)
})
@ -815,7 +815,7 @@ describe('Dropdown', () => {
dropdown.hide()
setTimeout(() => {
expect(dropdownMenu.classList.contains('show')).toEqual(true)
expect(dropdownMenu).toHaveClass('show')
done()
}, 10)
})
@ -870,7 +870,7 @@ describe('Dropdown', () => {
dropdown.hide()
setTimeout(() => {
expect(dropdownMenu.classList.contains('show')).toEqual(true)
expect(dropdownMenu).toHaveClass('show')
done()
})
})
@ -897,7 +897,7 @@ describe('Dropdown', () => {
})
btnDropdown.addEventListener('hidden.bs.dropdown', () => {
expect(btnDropdown.classList.contains('show')).toEqual(false)
expect(btnDropdown).not.toHaveClass('show')
expect(btnDropdown.getAttribute('aria-expanded')).toEqual('false')
expect(EventHandler.off).toHaveBeenCalled()
@ -1032,9 +1032,9 @@ describe('Dropdown', () => {
})
btnDropdown.addEventListener('shown.bs.dropdown', event => setTimeout(() => {
expect(btnDropdown.classList.contains('show')).toEqual(true)
expect(btnDropdown).toHaveClass('show')
expect(btnDropdown.getAttribute('aria-expanded')).toEqual('true')
expect(showEventTriggered).toEqual(true)
expect(showEventTriggered).toBeTrue()
expect(event.relatedTarget).toEqual(btnDropdown)
document.body.click()
}))
@ -1044,9 +1044,9 @@ describe('Dropdown', () => {
})
btnDropdown.addEventListener('hidden.bs.dropdown', event => {
expect(btnDropdown.classList.contains('show')).toEqual(false)
expect(btnDropdown).not.toHaveClass('show')
expect(btnDropdown.getAttribute('aria-expanded')).toEqual('false')
expect(hideEventTriggered).toEqual(true)
expect(hideEventTriggered).toBeTrue()
expect(event.relatedTarget).toEqual(btnDropdown)
done()
})
@ -1072,7 +1072,7 @@ describe('Dropdown', () => {
btnDropdown.addEventListener('shown.bs.dropdown', () => {
expect(dropdown._popper).toBeNull()
expect(dropdownMenu.getAttribute('style')).toEqual(null, 'no inline style applied by Popper')
expect(dropdownMenu.getAttribute('style')).toBeNull()
done()
})
@ -1164,7 +1164,7 @@ describe('Dropdown', () => {
btnDropdown.addEventListener('shown.bs.dropdown', () => {
// Popper adds this attribute when we use it
expect(dropdownMenu.getAttribute('data-popper-placement')).toEqual(null)
expect(dropdownMenu.getAttribute('data-popper-placement')).toBeNull()
done()
})
@ -1211,7 +1211,7 @@ describe('Dropdown', () => {
const btnDropdown = fixtureEl.querySelector('[data-bs-toggle="dropdown"]')
btnDropdown.addEventListener('shown.bs.dropdown', () => {
expect(btnDropdown.classList.contains('show')).toEqual(true)
expect(btnDropdown).toHaveClass('show')
const keyup = createEvent('keyup')
@ -1220,7 +1220,7 @@ describe('Dropdown', () => {
})
btnDropdown.addEventListener('hidden.bs.dropdown', () => {
expect(btnDropdown.classList.contains('show')).toEqual(false)
expect(btnDropdown).not.toHaveClass('show')
done()
})
@ -1248,29 +1248,29 @@ describe('Dropdown', () => {
const triggerDropdownList = fixtureEl.querySelectorAll('[data-bs-toggle="dropdown"]')
expect(triggerDropdownList.length).toEqual(2)
expect(triggerDropdownList).toHaveSize(2)
const [triggerDropdownFirst, triggerDropdownLast] = triggerDropdownList
triggerDropdownFirst.addEventListener('shown.bs.dropdown', () => {
expect(triggerDropdownFirst.classList.contains('show')).toEqual(true)
expect(fixtureEl.querySelectorAll('.dropdown-menu.show').length).toEqual(1)
expect(triggerDropdownFirst).toHaveClass('show')
expect(fixtureEl.querySelectorAll('.dropdown-menu.show')).toHaveSize(1)
document.body.click()
})
triggerDropdownFirst.addEventListener('hidden.bs.dropdown', () => {
expect(fixtureEl.querySelectorAll('.dropdown-menu.show').length).toEqual(0)
expect(fixtureEl.querySelectorAll('.dropdown-menu.show')).toHaveSize(0)
triggerDropdownLast.click()
})
triggerDropdownLast.addEventListener('shown.bs.dropdown', () => {
expect(triggerDropdownLast.classList.contains('show')).toEqual(true)
expect(fixtureEl.querySelectorAll('.dropdown-menu.show').length).toEqual(1)
expect(triggerDropdownLast).toHaveClass('show')
expect(fixtureEl.querySelectorAll('.dropdown-menu.show')).toHaveSize(1)
document.body.click()
})
triggerDropdownLast.addEventListener('hidden.bs.dropdown', () => {
expect(fixtureEl.querySelectorAll('.dropdown-menu.show').length).toEqual(0)
expect(fixtureEl.querySelectorAll('.dropdown-menu.show')).toHaveSize(0)
done()
})
@ -1296,13 +1296,13 @@ describe('Dropdown', () => {
const triggerDropdownList = fixtureEl.querySelectorAll('[data-bs-toggle="dropdown"]')
expect(triggerDropdownList.length).toEqual(2)
expect(triggerDropdownList).toHaveSize(2)
const [triggerDropdownFirst, triggerDropdownLast] = triggerDropdownList
triggerDropdownFirst.addEventListener('shown.bs.dropdown', () => {
expect(triggerDropdownFirst.classList.contains('show')).toEqual(true, '"show" class added on click')
expect(fixtureEl.querySelectorAll('.dropdown-menu.show').length).toEqual(1, 'only one dropdown is shown')
expect(triggerDropdownFirst).toHaveClass('show')
expect(fixtureEl.querySelectorAll('.dropdown-menu.show')).toHaveSize(1)
const keyup = createEvent('keyup')
keyup.key = 'Tab'
@ -1311,13 +1311,13 @@ describe('Dropdown', () => {
})
triggerDropdownFirst.addEventListener('hidden.bs.dropdown', () => {
expect(fixtureEl.querySelectorAll('.dropdown-menu.show').length).toEqual(0, '"show" class removed')
expect(fixtureEl.querySelectorAll('.dropdown-menu.show')).toHaveSize(0)
triggerDropdownLast.click()
})
triggerDropdownLast.addEventListener('shown.bs.dropdown', () => {
expect(triggerDropdownLast.classList.contains('show')).toEqual(true, '"show" class added on click')
expect(fixtureEl.querySelectorAll('.dropdown-menu.show').length).toEqual(1, 'only one dropdown is shown')
expect(triggerDropdownLast).toHaveClass('show')
expect(fixtureEl.querySelectorAll('.dropdown-menu.show')).toHaveSize(1)
const keyup = createEvent('keyup')
keyup.key = 'Tab'
@ -1326,7 +1326,7 @@ describe('Dropdown', () => {
})
triggerDropdownLast.addEventListener('hidden.bs.dropdown', () => {
expect(fixtureEl.querySelectorAll('.dropdown-menu.show').length).toEqual(0, '"show" class removed')
expect(fixtureEl.querySelectorAll('.dropdown-menu.show')).toHaveSize(0)
done()
})
@ -1456,8 +1456,8 @@ describe('Dropdown', () => {
triggerDropdown.dispatchEvent(keydown)
triggerDropdown.dispatchEvent(keydown)
expect(document.activeElement.classList.contains('disabled')).toEqual(false, '.disabled not focused')
expect(document.activeElement.hasAttribute('disabled')).toEqual(false, ':disabled not focused')
expect(document.activeElement).not.toHaveClass('disabled')
expect(document.activeElement.hasAttribute('disabled')).toBeFalse()
done()
})
@ -1490,9 +1490,9 @@ describe('Dropdown', () => {
triggerDropdown.dispatchEvent(keydown)
expect(document.activeElement.classList.contains('d-none')).toEqual(false, '.d-none not focused')
expect(document.activeElement.style.display).not.toBe('none', '"display: none" not focused')
expect(document.activeElement.style.visibility).not.toBe('hidden', '"visibility: hidden" not focused')
expect(document.activeElement).not.toHaveClass('d-none')
expect(document.activeElement.style.display).not.toEqual('none')
expect(document.activeElement.style.visibility).not.toEqual('hidden')
done()
})
@ -1603,12 +1603,12 @@ describe('Dropdown', () => {
const input = fixtureEl.querySelector('input')
input.addEventListener('click', () => {
expect(triggerDropdown.classList.contains('show')).toEqual(true, 'dropdown menu is shown')
expect(triggerDropdown).toHaveClass('show')
done()
})
triggerDropdown.addEventListener('shown.bs.dropdown', () => {
expect(triggerDropdown.classList.contains('show')).toEqual(true, 'dropdown menu is shown')
expect(triggerDropdown).toHaveClass('show')
input.dispatchEvent(createEvent('click'))
})
@ -1629,12 +1629,12 @@ describe('Dropdown', () => {
const textarea = fixtureEl.querySelector('textarea')
textarea.addEventListener('click', () => {
expect(triggerDropdown.classList.contains('show')).toEqual(true, 'dropdown menu is shown')
expect(triggerDropdown).toHaveClass('show')
done()
})
triggerDropdown.addEventListener('shown.bs.dropdown', () => {
expect(triggerDropdown.classList.contains('show')).toEqual(true, 'dropdown menu is shown')
expect(triggerDropdown).toHaveClass('show')
textarea.dispatchEvent(createEvent('click'))
})
@ -1734,7 +1734,7 @@ describe('Dropdown', () => {
input.focus()
input.dispatchEvent(keydownEscape)
expect(triggerDropdown.classList.contains('show')).toEqual(false, 'dropdown menu is not shown')
expect(triggerDropdown).not.toHaveClass('show')
done()
})
@ -1771,7 +1771,7 @@ describe('Dropdown', () => {
setTimeout(() => {
expect(dropdown.toggle).not.toHaveBeenCalled()
expect(triggerDropdown.classList.contains('show')).toEqual(false)
expect(triggerDropdown).not.toHaveClass('show')
done()
}, 20)
})
@ -1823,7 +1823,7 @@ describe('Dropdown', () => {
const dropdownMenu = fixtureEl.querySelector('.dropdown-menu')
const expectDropdownToBeOpened = () => setTimeout(() => {
expect(dropdownToggle.classList.contains('show')).toEqual(true)
expect(dropdownToggle).toHaveClass('show')
dropdownMenu.click()
}, 150)
@ -1833,7 +1833,7 @@ describe('Dropdown', () => {
})
dropdownToggle.addEventListener('hidden.bs.dropdown', () => setTimeout(() => {
expect(dropdownToggle.classList.contains('show')).toEqual(false)
expect(dropdownToggle).not.toHaveClass('show')
done()
}))
@ -1854,7 +1854,7 @@ describe('Dropdown', () => {
const dropdownMenu = fixtureEl.querySelector('.dropdown-menu')
const expectDropdownToBeOpened = () => setTimeout(() => {
expect(dropdownToggle.classList.contains('show')).toEqual(true)
expect(dropdownToggle).toHaveClass('show')
document.documentElement.click()
}, 150)
@ -1864,7 +1864,7 @@ describe('Dropdown', () => {
})
dropdownToggle.addEventListener('hidden.bs.dropdown', () => {
expect(dropdownToggle.classList.contains('show')).toEqual(false)
expect(dropdownToggle).not.toHaveClass('show')
done()
})
@ -1885,7 +1885,7 @@ describe('Dropdown', () => {
const dropdownMenu = fixtureEl.querySelector('.dropdown-menu')
const expectDropdownToBeOpened = (shouldTriggerClick = true) => setTimeout(() => {
expect(dropdownToggle.classList.contains('show')).toEqual(true)
expect(dropdownToggle).toHaveClass('show')
if (shouldTriggerClick) {
document.documentElement.click()
} else {
@ -1963,7 +1963,7 @@ describe('Dropdown', () => {
const div = fixtureEl.querySelector('div')
expect(Dropdown.getInstance(div)).toEqual(null)
expect(Dropdown.getInstance(div)).toBeNull()
})
})
@ -1984,7 +1984,7 @@ describe('Dropdown', () => {
const div = fixtureEl.querySelector('div')
expect(Dropdown.getInstance(div)).toEqual(null)
expect(Dropdown.getInstance(div)).toBeNull()
expect(Dropdown.getOrCreateInstance(div)).toBeInstanceOf(Dropdown)
})
@ -1993,7 +1993,7 @@ describe('Dropdown', () => {
const div = fixtureEl.querySelector('div')
expect(Dropdown.getInstance(div)).toEqual(null)
expect(Dropdown.getInstance(div)).toBeNull()
const dropdown = Dropdown.getOrCreateInstance(div, {
display: 'dynamic'
})
@ -2043,7 +2043,7 @@ describe('Dropdown', () => {
keyup.key = 'ArrowUp'
const handleArrowDown = () => {
expect(triggerDropdown.classList.contains('show')).toEqual(true)
expect(triggerDropdown).toHaveClass('show')
expect(triggerDropdown.getAttribute('aria-expanded')).toEqual('true')
setTimeout(() => {
dropdown.hide()
@ -2053,7 +2053,7 @@ describe('Dropdown', () => {
}
const handleArrowUp = () => {
expect(triggerDropdown.classList.contains('show')).toEqual(true)
expect(triggerDropdown).toHaveClass('show')
expect(triggerDropdown.getAttribute('aria-expanded')).toEqual('true')
done()
}
@ -2108,7 +2108,7 @@ describe('Dropdown', () => {
const childElement = fixtureEl.querySelector('#childElement')
btnDropdown.addEventListener('shown.bs.dropdown', () => setTimeout(() => {
expect(btnDropdown.classList.contains('show')).toEqual(true)
expect(btnDropdown).toHaveClass('show')
expect(btnDropdown.getAttribute('aria-expanded')).toEqual('true')
done()
}))

View File

@ -49,7 +49,7 @@ describe('jQuery', () => {
$(fixtureEl).find('.alert')
.one('closed.bs.alert', () => {
expect($(fixtureEl).find('.alert').length).toEqual(0)
expect($(fixtureEl).find('.alert')).toHaveSize(0)
done()
})

View File

@ -234,12 +234,12 @@ describe('Modal', () => {
modalEl.addEventListener('show.bs.modal', () => {
setTimeout(() => {
expect(modal._isTransitioning).toEqual(true)
expect(modal._isTransitioning).toBeTrue()
})
})
modalEl.addEventListener('shown.bs.modal', () => {
expect(modal._isTransitioning).toEqual(false)
expect(modal._isTransitioning).toBeFalse()
done()
})
@ -474,7 +474,7 @@ describe('Modal', () => {
const shownCallback = () => {
setTimeout(() => {
expect(modal._isShown).toEqual(true)
expect(modal._isShown).toBeTrue()
done()
}, 10)
}
@ -501,7 +501,7 @@ describe('Modal', () => {
const shownCallback = () => {
setTimeout(() => {
expect(modal._isShown).toEqual(true)
expect(modal._isShown).toBeTrue()
done()
}, 10)
}
@ -529,7 +529,7 @@ describe('Modal', () => {
const shownCallback = () => {
setTimeout(() => {
expect(modal._isShown).toEqual(false)
expect(modal._isShown).toBeFalse()
done()
}, 10)
}
@ -555,7 +555,7 @@ describe('Modal', () => {
const shownCallback = () => {
setTimeout(() => {
expect(modal._isShown).toEqual(true)
expect(modal._isShown).toBeTrue()
done()
}, 10)
}
@ -719,7 +719,7 @@ describe('Modal', () => {
const hideCallback = () => {
setTimeout(() => {
expect(modal._isShown).toEqual(true)
expect(modal._isShown).toBeTrue()
done()
}, 10)
}
@ -1026,7 +1026,7 @@ describe('Modal', () => {
})
modalEl1.addEventListener('hidden.bs.modal', () => {
expect(Modal.getInstance(modalEl2)).not.toBeNull()
expect(modalEl2.classList.contains('show')).toBeTrue()
expect(modalEl2).toHaveClass('show')
done()
})
modal1.show()
@ -1061,7 +1061,7 @@ describe('Modal', () => {
const modal = Modal.getInstance(div)
expect(modal).not.toBeNull()
expect(modal._config.keyboard).toBe(false)
expect(modal._config.keyboard).toBeFalse()
})
it('should not re create a modal', () => {
@ -1161,7 +1161,7 @@ describe('Modal', () => {
const div = fixtureEl.querySelector('div')
expect(Modal.getInstance(div)).toEqual(null)
expect(Modal.getInstance(div)).toBeNull()
expect(Modal.getOrCreateInstance(div)).toBeInstanceOf(Modal)
})
@ -1170,13 +1170,13 @@ describe('Modal', () => {
const div = fixtureEl.querySelector('div')
expect(Modal.getInstance(div)).toEqual(null)
expect(Modal.getInstance(div)).toBeNull()
const modal = Modal.getOrCreateInstance(div, {
backdrop: true
})
expect(modal).toBeInstanceOf(Modal)
expect(modal._config.backdrop).toEqual(true)
expect(modal._config.backdrop).toBeTrue()
})
it('should return the instance when exists without given configuration', () => {
@ -1194,7 +1194,7 @@ describe('Modal', () => {
expect(modal).toBeInstanceOf(Modal)
expect(modal2).toEqual(modal)
expect(modal2._config.backdrop).toEqual(true)
expect(modal2._config.backdrop).toBeTrue()
})
})
})

View File

@ -55,7 +55,7 @@ describe('Offcanvas', () => {
closeEl.click()
expect(offCanvas._config.keyboard).toBe(true)
expect(offCanvas._config.keyboard).toBeTrue()
expect(offCanvas.hide).toHaveBeenCalled()
})
@ -101,7 +101,7 @@ describe('Offcanvas', () => {
document.dispatchEvent(keyDownEsc)
expect(offCanvas._config.keyboard).toBe(false)
expect(offCanvas._config.keyboard).toBeFalse()
expect(offCanvas.hide).not.toHaveBeenCalled()
})
})
@ -116,10 +116,10 @@ describe('Offcanvas', () => {
const offCanvasEl = fixtureEl.querySelector('.offcanvas')
const offCanvas = new Offcanvas(offCanvasEl)
expect(offCanvas._config.backdrop).toEqual(true)
expect(offCanvas._backdrop._config.isVisible).toEqual(true)
expect(offCanvas._config.keyboard).toEqual(true)
expect(offCanvas._config.scroll).toEqual(false)
expect(offCanvas._config.backdrop).toBeTrue()
expect(offCanvas._backdrop._config.isVisible).toBeTrue()
expect(offCanvas._config.keyboard).toBeTrue()
expect(offCanvas._config.scroll).toBeFalse()
})
it('should read data attributes and override default config', () => {
@ -131,10 +131,10 @@ describe('Offcanvas', () => {
const offCanvasEl = fixtureEl.querySelector('.offcanvas')
const offCanvas = new Offcanvas(offCanvasEl)
expect(offCanvas._config.backdrop).toEqual(false)
expect(offCanvas._backdrop._config.isVisible).toEqual(false)
expect(offCanvas._config.keyboard).toEqual(false)
expect(offCanvas._config.scroll).toEqual(true)
expect(offCanvas._config.backdrop).toBeFalse()
expect(offCanvas._backdrop._config.isVisible).toBeFalse()
expect(offCanvas._config.keyboard).toBeFalse()
expect(offCanvas._config.scroll).toBeTrue()
})
it('given a config object must override data attributes', () => {
@ -149,9 +149,9 @@ describe('Offcanvas', () => {
keyboard: true,
scroll: false
})
expect(offCanvas._config.backdrop).toEqual(true)
expect(offCanvas._config.keyboard).toEqual(true)
expect(offCanvas._config.scroll).toEqual(false)
expect(offCanvas._config.backdrop).toBeTrue()
expect(offCanvas._config.keyboard).toBeTrue()
expect(offCanvas._config.scroll).toBeFalse()
})
})
describe('options', () => {
@ -204,7 +204,7 @@ describe('Offcanvas', () => {
spyOn(offCanvas._backdrop._config, 'clickCallback').and.callThrough()
offCanvasEl.addEventListener('shown.bs.offcanvas', () => {
expect(typeof offCanvas._backdrop._config.clickCallback).toBe('function')
expect(offCanvas._backdrop._config.clickCallback).toEqual(jasmine.any(Function))
offCanvas._backdrop._getElement().dispatchEvent(clickEvent)
})
@ -256,7 +256,7 @@ describe('Offcanvas', () => {
const offCanvasEl = fixtureEl.querySelector('.offcanvas')
const offCanvas = new Offcanvas(offCanvasEl)
offCanvas.show()
expect(offCanvasEl.classList.contains('show')).toBe(true)
expect(offCanvasEl).toHaveClass('show')
spyOn(offCanvas, 'hide')
@ -274,7 +274,7 @@ describe('Offcanvas', () => {
const offCanvas = new Offcanvas(offCanvasEl)
offCanvas.show()
expect(offCanvasEl.classList.contains('show')).toBe(true)
expect(offCanvasEl).toHaveClass('show')
spyOn(offCanvas._backdrop, 'show').and.callThrough()
spyOn(EventHandler, 'trigger').and.callThrough()
@ -292,7 +292,7 @@ describe('Offcanvas', () => {
spyOn(offCanvas._backdrop, 'show').and.callThrough()
offCanvasEl.addEventListener('shown.bs.offcanvas', () => {
expect(offCanvasEl.classList.contains('show')).toEqual(true)
expect(offCanvasEl).toHaveClass('show')
expect(offCanvas._backdrop.show).toHaveBeenCalled()
done()
})
@ -384,7 +384,7 @@ describe('Offcanvas', () => {
offCanvas.show()
offCanvasEl.addEventListener('hidden.bs.offcanvas', () => {
expect(offCanvasEl.classList.contains('show')).toEqual(false)
expect(offCanvasEl).not.toHaveClass('show')
expect(offCanvas._backdrop.hide).toHaveBeenCalled()
done()
})
@ -458,7 +458,7 @@ describe('Offcanvas', () => {
expect(offCanvas._backdrop).toBeNull()
expect(focustrap.deactivate).toHaveBeenCalled()
expect(offCanvas._focustrap).toBeNull()
expect(Offcanvas.getInstance(offCanvasEl)).toEqual(null)
expect(Offcanvas.getInstance(offCanvasEl)).toBeNull()
})
})
@ -473,8 +473,8 @@ describe('Offcanvas', () => {
const offCanvasEl = fixtureEl.querySelector('#offcanvasdiv1')
offCanvasEl.addEventListener('shown.bs.offcanvas', () => {
expect(offCanvasEl.classList.contains('show')).toEqual(true)
expect(target.checked).toEqual(true)
expect(offCanvasEl).toHaveClass('show')
expect(target.checked).toBeTrue()
done()
})
@ -559,7 +559,7 @@ describe('Offcanvas', () => {
})
offcanvasEl.addEventListener('hidden.bs.offcanvas', () => {
setTimeout(() => {
expect(isVisible(trigger)).toBe(false)
expect(isVisible(trigger)).toBeFalse()
expect(trigger.focus).not.toHaveBeenCalled()
done()
}, 5)
@ -665,7 +665,7 @@ describe('Offcanvas', () => {
const offcanvas = Offcanvas.getInstance(div)
expect(offcanvas).not.toBeNull()
expect(offcanvas._config.scroll).toBe(true)
expect(offcanvas._config.scroll).toBeTrue()
})
})
@ -706,7 +706,7 @@ describe('Offcanvas', () => {
const div = fixtureEl.querySelector('div')
expect(Offcanvas.getInstance(div)).toEqual(null)
expect(Offcanvas.getInstance(div)).toBeNull()
expect(Offcanvas.getOrCreateInstance(div)).toBeInstanceOf(Offcanvas)
})
@ -715,13 +715,13 @@ describe('Offcanvas', () => {
const div = fixtureEl.querySelector('div')
expect(Offcanvas.getInstance(div)).toEqual(null)
expect(Offcanvas.getInstance(div)).toBeNull()
const offcanvas = Offcanvas.getOrCreateInstance(div, {
scroll: true
})
expect(offcanvas).toBeInstanceOf(Offcanvas)
expect(offcanvas._config.scroll).toEqual(true)
expect(offcanvas._config.scroll).toBeTrue()
})
it('should return the instance when exists without given configuration', () => {
@ -739,7 +739,7 @@ describe('Offcanvas', () => {
expect(offcanvas).toBeInstanceOf(Offcanvas)
expect(offcanvas2).toEqual(offcanvas)
expect(offcanvas2._config.scroll).toEqual(true)
expect(offcanvas2._config.scroll).toBeTrue()
})
})
})

View File

@ -196,7 +196,7 @@ describe('Popover', () => {
popoverEl.addEventListener('shown.bs.popover', () => {
const tip = document.querySelector('.popover')
expect(tip).not.toBeNull()
expect(tip.classList.contains('custom-class')).toBeTrue()
expect(tip).toHaveClass('custom-class')
done()
})
@ -314,7 +314,7 @@ describe('Popover', () => {
const popoverEl = fixtureEl.querySelector('a')
expect(Popover.getInstance(popoverEl)).toEqual(null)
expect(Popover.getInstance(popoverEl)).toBeNull()
})
})
@ -335,7 +335,7 @@ describe('Popover', () => {
const div = fixtureEl.querySelector('div')
expect(Popover.getInstance(div)).toEqual(null)
expect(Popover.getInstance(div)).toBeNull()
expect(Popover.getOrCreateInstance(div)).toBeInstanceOf(Popover)
})
@ -344,7 +344,7 @@ describe('Popover', () => {
const div = fixtureEl.querySelector('div')
expect(Popover.getInstance(div)).toEqual(null)
expect(Popover.getInstance(div)).toBeNull()
const popover = Popover.getOrCreateInstance(div, {
placement: 'top'
})

View File

@ -14,7 +14,7 @@ describe('ScrollSpy', () => {
const scrollHeight = Math.ceil(contentEl.scrollTop + Manipulator.position(target).top) + paddingTop
function listener() {
expect(element.classList.contains('active')).toEqual(true)
expect(element).toHaveClass('active')
contentEl.removeEventListener('scroll', listener)
expect(scrollSpy._process).toHaveBeenCalled()
spy.calls.reset()
@ -82,7 +82,7 @@ describe('ScrollSpy', () => {
target: '#navigation'
})
expect(scrollSpy._targets.length).toEqual(2)
expect(scrollSpy._targets).toHaveSize(2)
})
it('should only switch "active" class on current target', done => {
@ -120,7 +120,7 @@ describe('ScrollSpy', () => {
spyOn(scrollSpy, '_process').and.callThrough()
scrollSpyEl.addEventListener('scroll', () => {
expect(rootEl.classList.contains('active')).toEqual(true)
expect(rootEl).toHaveClass('active')
expect(scrollSpy._process).toHaveBeenCalled()
done()
})
@ -163,7 +163,7 @@ describe('ScrollSpy', () => {
spyOn(scrollSpy, '_process').and.callThrough()
scrollSpyEl.addEventListener('scroll', () => {
expect(rootEl.classList.contains('active')).toEqual(true)
expect(rootEl).toHaveClass('active')
expect(scrollSpy._process).toHaveBeenCalled()
done()
})
@ -197,9 +197,9 @@ describe('ScrollSpy', () => {
spyOn(scrollSpy, '_process').and.callThrough()
contentEl.addEventListener('scroll', () => {
expect(fixtureEl.querySelector('#one-link').classList.contains('active')).toEqual(false)
expect(fixtureEl.querySelector('#two-link').classList.contains('active')).toEqual(true)
expect(fixtureEl.querySelector('#three-link').classList.contains('active')).toEqual(false)
expect(fixtureEl.querySelector('#one-link')).not.toHaveClass('active')
expect(fixtureEl.querySelector('#two-link')).toHaveClass('active')
expect(fixtureEl.querySelector('#three-link')).not.toHaveClass('active')
expect(scrollSpy._process).toHaveBeenCalled()
done()
})
@ -361,7 +361,7 @@ describe('ScrollSpy', () => {
expect(spy).toHaveBeenCalled()
spy.calls.reset()
if (firstTime) {
expect(fixtureEl.querySelectorAll('.active').length).toEqual(1)
expect(fixtureEl.querySelectorAll('.active')).toHaveSize(1)
expect(active.getAttribute('id')).toEqual('two-link')
firstTime = false
contentEl.scrollTop = 0
@ -409,12 +409,12 @@ describe('ScrollSpy', () => {
expect(spy).toHaveBeenCalled()
spy.calls.reset()
if (firstTime) {
expect(fixtureEl.querySelectorAll('.active').length).toEqual(1)
expect(fixtureEl.querySelectorAll('.active')).toHaveSize(1)
expect(active.getAttribute('id')).toEqual('two-link')
firstTime = false
contentEl.scrollTop = negativeHeight
} else {
expect(fixtureEl.querySelectorAll('.active').length).toEqual(1)
expect(fixtureEl.querySelectorAll('.active')).toHaveSize(1)
expect(active.getAttribute('id')).toEqual('one-link')
done()
}
@ -602,7 +602,7 @@ describe('ScrollSpy', () => {
const scrollspy = ScrollSpy.getInstance(div)
expect(scrollspy).not.toBeNull()
expect(scrollspy._config.offset).toBe(15)
expect(scrollspy._config.offset).toEqual(15)
})
it('should not re create a scrollspy', () => {
@ -663,7 +663,7 @@ describe('ScrollSpy', () => {
})
it('should return null if there is no instance', () => {
expect(ScrollSpy.getInstance(fixtureEl)).toEqual(null)
expect(ScrollSpy.getInstance(fixtureEl)).toBeNull()
})
})
@ -684,7 +684,7 @@ describe('ScrollSpy', () => {
const div = fixtureEl.querySelector('div')
expect(ScrollSpy.getInstance(div)).toEqual(null)
expect(ScrollSpy.getInstance(div)).toBeNull()
expect(ScrollSpy.getOrCreateInstance(div)).toBeInstanceOf(ScrollSpy)
})
@ -693,7 +693,7 @@ describe('ScrollSpy', () => {
const div = fixtureEl.querySelector('div')
expect(ScrollSpy.getInstance(div)).toEqual(null)
expect(ScrollSpy.getInstance(div)).toBeNull()
const scrollspy = ScrollSpy.getOrCreateInstance(div, {
offset: 1
})

View File

@ -51,7 +51,7 @@ describe('Tab', () => {
const tab = new Tab(profileTriggerEl)
profileTriggerEl.addEventListener('shown.bs.tab', () => {
expect(fixtureEl.querySelector('#profile').classList.contains('active')).toEqual(true)
expect(fixtureEl.querySelector('#profile')).toHaveClass('active')
expect(profileTriggerEl.getAttribute('aria-selected')).toEqual('true')
done()
})
@ -75,7 +75,7 @@ describe('Tab', () => {
const tab = new Tab(profileTriggerEl)
profileTriggerEl.addEventListener('shown.bs.tab', () => {
expect(fixtureEl.querySelector('#profile').classList.contains('active')).toEqual(true)
expect(fixtureEl.querySelector('#profile')).toHaveClass('active')
expect(profileTriggerEl.getAttribute('aria-selected')).toEqual('true')
done()
})
@ -99,7 +99,7 @@ describe('Tab', () => {
const tab = new Tab(profileTriggerEl)
profileTriggerEl.addEventListener('shown.bs.tab', () => {
expect(fixtureEl.querySelector('#profile').classList.contains('active')).toEqual(true)
expect(fixtureEl.querySelector('#profile')).toHaveClass('active')
done()
})
@ -119,7 +119,7 @@ describe('Tab', () => {
const tab = new Tab(profileTriggerEl)
profileTriggerEl.addEventListener('shown.bs.tab', () => {
expect(fixtureEl.querySelector('#profile').classList.contains('active')).toEqual(true)
expect(fixtureEl.querySelector('#profile')).toHaveClass('active')
done()
})
@ -139,7 +139,7 @@ describe('Tab', () => {
const tab = new Tab(profileTriggerEl)
profileTriggerEl.addEventListener('shown.bs.tab', () => {
expect(fixtureEl.querySelector('#profile').classList.contains('active')).toEqual(true)
expect(fixtureEl.querySelector('#profile')).toHaveClass('active')
done()
})
@ -248,7 +248,7 @@ describe('Tab', () => {
})
triggerList[0].addEventListener('hidden.bs.tab', ev => {
expect(hideCalled).toEqual(true)
expect(hideCalled).toBeTrue()
expect(ev.relatedTarget.getAttribute('data-bs-target')).toEqual('#profile')
done()
})
@ -321,7 +321,7 @@ describe('Tab', () => {
const secondNavTab = new Tab(secondNavEl)
secondNavEl.addEventListener('shown.bs.tab', () => {
expect(fixtureEl.querySelectorAll('.nav-tab').length).toEqual(2)
expect(fixtureEl.querySelectorAll('.nav-tab')).toHaveSize(2)
done()
})
@ -417,7 +417,7 @@ describe('Tab', () => {
describe('getInstance', () => {
it('should return null if there is no instance', () => {
expect(Tab.getInstance(fixtureEl)).toEqual(null)
expect(Tab.getInstance(fixtureEl)).toBeNull()
})
it('should return this instance', () => {
@ -448,7 +448,7 @@ describe('Tab', () => {
const div = fixtureEl.querySelector('div')
expect(Tab.getInstance(div)).toEqual(null)
expect(Tab.getInstance(div)).toBeNull()
expect(Tab.getOrCreateInstance(div)).toBeInstanceOf(Tab)
})
})
@ -469,8 +469,8 @@ describe('Tab', () => {
const secondTabTrigger = fixtureEl.querySelector('#triggerProfile')
secondTabTrigger.addEventListener('shown.bs.tab', () => {
expect(secondTabTrigger.classList.contains('active')).toEqual(true)
expect(fixtureEl.querySelector('#profile').classList.contains('active')).toEqual(true)
expect(secondTabTrigger).toHaveClass('active')
expect(fixtureEl.querySelector('#profile')).toHaveClass('active')
done()
})
@ -495,9 +495,9 @@ describe('Tab', () => {
const firstLiLinkEl = fixtureEl.querySelector('li:first-child a')
firstLiLinkEl.click()
expect(firstLiLinkEl.classList.contains('active')).toEqual(true)
expect(fixtureEl.querySelector('li:last-child a').classList.contains('active')).toEqual(false)
expect(fixtureEl.querySelector('li:last-child .dropdown-menu a:first-child').classList.contains('active')).toEqual(false)
expect(firstLiLinkEl).toHaveClass('active')
expect(fixtureEl.querySelector('li:last-child a')).not.toHaveClass('active')
expect(fixtureEl.querySelector('li:last-child .dropdown-menu a:first-child')).not.toHaveClass('active')
})
it('selecting a dropdown tab does not activate another', () => {
@ -529,10 +529,10 @@ describe('Tab', () => {
const firstDropItem = fixtureEl.querySelector('#nav1 .dropdown-item')
firstDropItem.click()
expect(firstDropItem.classList.contains('active')).toEqual(true)
expect(fixtureEl.querySelector('#nav1 .dropdown-toggle').classList.contains('active')).toEqual(true)
expect(fixtureEl.querySelector('#nav2 .dropdown-toggle').classList.contains('active')).toEqual(false)
expect(fixtureEl.querySelector('#nav2 .dropdown-item').classList.contains('active')).toEqual(false)
expect(firstDropItem).toHaveClass('active')
expect(fixtureEl.querySelector('#nav1 .dropdown-toggle')).toHaveClass('active')
expect(fixtureEl.querySelector('#nav2 .dropdown-toggle')).not.toHaveClass('active')
expect(fixtureEl.querySelector('#nav2 .dropdown-item')).not.toHaveClass('active')
})
it('should support li > .dropdown-item', () => {
@ -553,8 +553,8 @@ describe('Tab', () => {
const firstDropItem = fixtureEl.querySelector('.dropdown-item')
firstDropItem.click()
expect(firstDropItem.classList.contains('active')).toEqual(true)
expect(fixtureEl.querySelector('.nav-link').classList.contains('active')).toEqual(false)
expect(firstDropItem).toHaveClass('active')
expect(fixtureEl.querySelector('.nav-link')).not.toHaveClass('active')
})
it('should handle nested tabs', done => {
@ -585,12 +585,12 @@ describe('Tab', () => {
const xTab1El = fixtureEl.querySelector('#x-tab1')
tabNested2El.addEventListener('shown.bs.tab', () => {
expect(xTab1El.classList.contains('active')).toEqual(true)
expect(xTab1El).toHaveClass('active')
done()
})
tab1El.addEventListener('shown.bs.tab', () => {
expect(xTab1El.classList.contains('active')).toEqual(true)
expect(xTab1El).toHaveClass('active')
tabNested2El.click()
})
@ -615,15 +615,15 @@ describe('Tab', () => {
const tabHomeEl = fixtureEl.querySelector('#home')
triggerTabProfileEl.addEventListener('shown.bs.tab', () => {
expect(tabProfileEl.classList.contains('fade')).toEqual(true)
expect(tabProfileEl.classList.contains('show')).toEqual(true)
expect(tabProfileEl).toHaveClass('fade')
expect(tabProfileEl).toHaveClass('show')
triggerTabHomeEl.addEventListener('shown.bs.tab', () => {
expect(tabProfileEl.classList.contains('fade')).toEqual(true)
expect(tabProfileEl.classList.contains('show')).toEqual(false)
expect(tabProfileEl).toHaveClass('fade')
expect(tabProfileEl).not.toHaveClass('show')
expect(tabHomeEl.classList.contains('fade')).toEqual(true)
expect(tabHomeEl.classList.contains('show')).toEqual(true)
expect(tabHomeEl).toHaveClass('fade')
expect(tabHomeEl).toHaveClass('show')
done()
})
@ -653,7 +653,7 @@ describe('Tab', () => {
const secondNavEl = fixtureEl.querySelector('#secondNav')
secondNavEl.addEventListener('shown.bs.tab', () => {
expect(fixtureEl.querySelectorAll('.show').length).toEqual(0)
expect(fixtureEl.querySelectorAll('.show')).toHaveSize(0)
done()
})
@ -679,7 +679,7 @@ describe('Tab', () => {
const secondNavEl = fixtureEl.querySelector('#secondNav')
secondNavEl.addEventListener('shown.bs.tab', () => {
expect(fixtureEl.querySelectorAll('.show').length).toEqual(1)
expect(fixtureEl.querySelectorAll('.show')).toHaveSize(1)
done()
})
@ -698,7 +698,7 @@ describe('Tab', () => {
spyOn(Event.prototype, 'preventDefault').and.callThrough()
tabEl.addEventListener('shown.bs.tab', () => {
expect(tabEl.classList.contains('active')).toEqual(true)
expect(tabEl).toHaveClass('active')
expect(Event.prototype.preventDefault).toHaveBeenCalled()
done()
})

View File

@ -51,7 +51,7 @@ describe('Toast', () => {
})
toastEl.addEventListener('shown.bs.toast', () => {
expect(toastEl.classList.contains('show')).toEqual(true)
expect(toastEl).toHaveClass('show')
done()
})
@ -69,7 +69,7 @@ describe('Toast', () => {
const toast = new Toast(toastEl)
toastEl.addEventListener('shown.bs.toast', () => {
expect(toastEl.classList.contains('show')).toEqual(true)
expect(toastEl).toHaveClass('show')
const button = toastEl.querySelector('.btn-close')
@ -77,7 +77,7 @@ describe('Toast', () => {
})
toastEl.addEventListener('hidden.bs.toast', () => {
expect(toastEl.classList.contains('show')).toEqual(false)
expect(toastEl).not.toHaveClass('show')
done()
})
@ -124,7 +124,7 @@ describe('Toast', () => {
const toast = new Toast(toastEl)
toastEl.addEventListener('hidden.bs.toast', () => {
expect(toastEl.classList.contains('show')).toEqual(false)
expect(toastEl).not.toHaveClass('show')
done()
})
@ -144,7 +144,7 @@ describe('Toast', () => {
const toast = new Toast(toastEl)
toastEl.addEventListener('shown.bs.toast', () => {
expect(toastEl.classList.contains('fade')).toEqual(false)
expect(toastEl).not.toHaveClass('fade')
done()
})
@ -165,7 +165,7 @@ describe('Toast', () => {
const assertDone = () => {
setTimeout(() => {
expect(toastEl.classList.contains('show')).toEqual(false)
expect(toastEl).not.toHaveClass('show')
done()
}, 20)
}
@ -404,7 +404,7 @@ describe('Toast', () => {
})
toastEl.addEventListener('hidden.bs.toast', () => {
expect(toastEl.classList.contains('show')).toEqual(false)
expect(toastEl).not.toHaveClass('show')
done()
})
@ -438,7 +438,7 @@ describe('Toast', () => {
const assertDone = () => {
setTimeout(() => {
expect(toastEl.classList.contains('show')).toEqual(true)
expect(toastEl).toHaveClass('show')
done()
}, 20)
}
@ -487,13 +487,13 @@ describe('Toast', () => {
const toastEl = fixtureEl.querySelector('div')
const toast = new Toast(toastEl)
const expected = () => {
expect(toastEl.classList.contains('show')).toEqual(true)
expect(toastEl).toHaveClass('show')
expect(Toast.getInstance(toastEl)).not.toBeNull()
toast.dispose()
expect(Toast.getInstance(toastEl)).toBeNull()
expect(toastEl.classList.contains('show')).toEqual(false)
expect(toastEl).not.toHaveClass('show')
done()
}
@ -582,7 +582,7 @@ describe('Toast', () => {
const div = fixtureEl.querySelector('div')
expect(Toast.getInstance(div)).toEqual(null)
expect(Toast.getInstance(div)).toBeNull()
})
})
@ -603,7 +603,7 @@ describe('Toast', () => {
const div = fixtureEl.querySelector('div')
expect(Toast.getInstance(div)).toEqual(null)
expect(Toast.getInstance(div)).toBeNull()
expect(Toast.getOrCreateInstance(div)).toBeInstanceOf(Toast)
})
@ -612,7 +612,7 @@ describe('Toast', () => {
const div = fixtureEl.querySelector('div')
expect(Toast.getInstance(div)).toEqual(null)
expect(Toast.getInstance(div)).toBeNull()
const toast = Toast.getOrCreateInstance(div, {
delay: 1
})

View File

@ -78,7 +78,7 @@ describe('Tooltip', () => {
const tooltipEl = fixtureEl.querySelector('a')
const tooltip = new Tooltip(tooltipEl)
expect(tooltip._config.sanitize).toEqual(true)
expect(tooltip._config.sanitize).toBeTrue()
})
it('should convert title and content to string if numbers', () => {
@ -137,7 +137,7 @@ describe('Tooltip', () => {
const offset = tooltip._getOffset()
expect(typeof offset).toEqual('function')
expect(offset).toEqual(jasmine.any(Function))
tooltip.show()
})
@ -229,11 +229,11 @@ describe('Tooltip', () => {
const tooltipEl = fixtureEl.querySelector('a')
const tooltip = new Tooltip(tooltipEl)
expect(tooltip._isEnabled).toEqual(true)
expect(tooltip._isEnabled).toBeTrue()
tooltip.toggleEnabled()
expect(tooltip._isEnabled).toEqual(false)
expect(tooltip._isEnabled).toBeFalse()
})
})
@ -354,7 +354,7 @@ describe('Tooltip', () => {
tooltip.dispose()
expect(Tooltip.getInstance(tooltipEl)).toEqual(null)
expect(Tooltip.getInstance(tooltipEl)).toBeNull()
expect(removeEventSpy.calls.allArgs()).toEqual(expectedArgs)
})
@ -369,8 +369,8 @@ describe('Tooltip', () => {
})
tooltipEl.addEventListener('hidden.bs.tooltip', () => {
tooltip.dispose()
expect(tooltip.tip).toEqual(null)
expect(Tooltip.getInstance(tooltipEl)).toEqual(null)
expect(tooltip.tip).toBeNull()
expect(Tooltip.getInstance(tooltipEl)).toBeNull()
done()
})
@ -465,11 +465,11 @@ describe('Tooltip', () => {
})
tooltipEl.addEventListener('inserted.bs.tooltip', () => {
expect(tooltip.getTipElement().classList.contains('bs-tooltip-auto')).toEqual(true)
expect(tooltip.getTipElement()).toHaveClass('bs-tooltip-auto')
})
tooltipEl.addEventListener('shown.bs.tooltip', () => {
expect(tooltip.getTipElement().classList.contains('bs-tooltip-auto')).toEqual(true)
expect(tooltip.getTipElement()).toHaveClass('bs-tooltip-auto')
expect(tooltip.getTipElement().getAttribute('data-popper-placement')).toEqual('bottom')
done()
})
@ -585,7 +585,7 @@ describe('Tooltip', () => {
const tip = document.querySelector('.tooltip')
expect(tip).not.toBeNull()
expect(tip.classList.contains('fade')).toEqual(false)
expect(tip).not.toHaveClass('fade')
done()
})
@ -669,7 +669,7 @@ describe('Tooltip', () => {
setTimeout(() => {
expect(tooltip.show).toHaveBeenCalled()
expect(document.querySelectorAll('.tooltip').length).toEqual(0)
expect(document.querySelectorAll('.tooltip')).toHaveSize(0)
done()
}, 200)
@ -688,17 +688,17 @@ describe('Tooltip', () => {
})
setTimeout(() => {
expect(tooltip.getTipElement().classList.contains('show')).toEqual(true)
expect(tooltip.getTipElement()).toHaveClass('show')
tooltipEl.dispatchEvent(createEvent('mouseout'))
setTimeout(() => {
expect(tooltip.getTipElement().classList.contains('show')).toEqual(true)
expect(tooltip.getTipElement()).toHaveClass('show')
tooltipEl.dispatchEvent(createEvent('mouseover'))
}, 100)
setTimeout(() => {
expect(tooltip.getTipElement().classList.contains('show')).toEqual(true)
expect(document.querySelectorAll('.tooltip').length).toEqual(1)
expect(tooltip.getTipElement()).toHaveClass('show')
expect(document.querySelectorAll('.tooltip')).toHaveSize(1)
done()
}, 200)
}, 0)
@ -751,17 +751,17 @@ describe('Tooltip', () => {
setTimeout(() => {
expect(tooltip._popper).not.toBeNull()
expect(tooltip.getTipElement().getAttribute('data-popper-placement')).toBe('top')
expect(tooltip.getTipElement().getAttribute('data-popper-placement')).toEqual('top')
tooltipEl.dispatchEvent(createEvent('mouseout'))
setTimeout(() => {
expect(tooltip.getTipElement().classList.contains('show')).toEqual(false)
expect(tooltip.getTipElement()).not.toHaveClass('show')
tooltipEl.dispatchEvent(createEvent('mouseover'))
}, 100)
setTimeout(() => {
expect(tooltip._popper).not.toBeNull()
expect(tooltip.getTipElement().getAttribute('data-popper-placement')).toBe('top')
expect(tooltip.getTipElement().getAttribute('data-popper-placement')).toEqual('top')
done()
}, 200)
}, 0)
@ -809,7 +809,7 @@ describe('Tooltip', () => {
tooltipEl.addEventListener('shown.bs.tooltip', () => {
const tip = document.querySelector('.tooltip')
expect(tip).not.toBeNull()
expect(tip.classList.contains('custom-class')).toBeTrue()
expect(tip).toHaveClass('custom-class')
done()
})
@ -827,8 +827,8 @@ describe('Tooltip', () => {
tooltipEl.addEventListener('shown.bs.tooltip', () => {
const tip = document.querySelector('.tooltip')
expect(tip).not.toBeNull()
expect(tip.classList.contains('custom-class')).toBeTrue()
expect(tip.classList.contains('custom-class-2')).toBeTrue()
expect(tip).toHaveClass('custom-class')
expect(tip).toHaveClass('custom-class-2')
done()
})
@ -848,7 +848,7 @@ describe('Tooltip', () => {
const tip = document.querySelector('.tooltip')
expect(tip).not.toBeNull()
expect(spy).toHaveBeenCalled()
expect(tip.classList.contains('custom-class')).toBeTrue()
expect(tip).toHaveClass('custom-class')
done()
})
@ -992,7 +992,7 @@ describe('Tooltip', () => {
const tooltipEl = fixtureEl.querySelector('a')
const tooltip = new Tooltip(tooltipEl)
expect(tooltip.isWithContent()).toEqual(true)
expect(tooltip.isWithContent()).toBeTrue()
})
it('should return false if there is no content', () => {
@ -1001,7 +1001,7 @@ describe('Tooltip', () => {
const tooltipEl = fixtureEl.querySelector('a')
const tooltip = new Tooltip(tooltipEl)
expect(tooltip.isWithContent()).toEqual(false)
expect(tooltip.isWithContent()).toBeFalse()
})
})
@ -1047,8 +1047,8 @@ describe('Tooltip', () => {
tooltip.setContent(tip)
expect(tip.classList.contains('show')).toEqual(false)
expect(tip.classList.contains('fade')).toEqual(false)
expect(tip).not.toHaveClass('show')
expect(tip).not.toHaveClass('fade')
expect(tip.querySelector('.tooltip-inner').textContent).toEqual('Another tooltip')
})
@ -1060,10 +1060,10 @@ describe('Tooltip', () => {
tooltip.show()
const tip = () => tooltip.getTipElement()
expect(tip().classList.contains('show')).toEqual(true)
expect(tip()).toHaveClass('show')
tooltip.setContent({ '.tooltip-inner': 'foo' })
expect(tip().classList.contains('show')).toEqual(true)
expect(tip()).toHaveClass('show')
expect(tip().querySelector('.tooltip-inner').textContent).toEqual('foo')
})
@ -1074,10 +1074,10 @@ describe('Tooltip', () => {
const tooltip = new Tooltip(tooltipEl)
const tip = () => tooltip.getTipElement()
expect(tip().classList.contains('show')).toEqual(false)
expect(tip()).not.toHaveClass('show')
tooltip.setContent({ '.tooltip-inner': 'foo' })
expect(tip().classList.contains('show')).toEqual(false)
expect(tip()).not.toHaveClass('show')
expect(tip().querySelector('.tooltip-inner').textContent).toEqual('foo')
})
})
@ -1092,7 +1092,7 @@ describe('Tooltip', () => {
})
tooltipEl.addEventListener('inserted.bs.tooltip', () => {
expect(tooltip.getTipElement().classList.contains('bs-tooltip-auto')).toEqual(true)
expect(tooltip.getTipElement()).toHaveClass('bs-tooltip-auto')
done()
})
@ -1108,7 +1108,7 @@ describe('Tooltip', () => {
})
tooltipEl.addEventListener('inserted.bs.tooltip', () => {
expect(tooltip.getTipElement().classList.contains('bs-tooltip-auto')).toEqual(true)
expect(tooltip.getTipElement()).toHaveClass('bs-tooltip-auto')
done()
})
@ -1207,7 +1207,7 @@ describe('Tooltip', () => {
tooltip.setContent({ '.tooltip': content })
expect(tooltip.getTipElement().querySelector('div').id).toEqual('childContent')
expect(tooltip.getTipElement().querySelector('button')).toEqual(null)
expect(tooltip.getTipElement().querySelector('button')).toBeNull()
})
it('should add text content', () => {
@ -1260,7 +1260,7 @@ describe('Tooltip', () => {
const div = fixtureEl.querySelector('div')
expect(Tooltip.getInstance(div)).toEqual(null)
expect(Tooltip.getInstance(div)).toBeNull()
})
})
@ -1334,7 +1334,7 @@ describe('Tooltip', () => {
const div = fixtureEl.querySelector('div')
expect(Tooltip.getInstance(div)).toEqual(null)
expect(Tooltip.getInstance(div)).toBeNull()
expect(Tooltip.getOrCreateInstance(div)).toBeInstanceOf(Tooltip)
})
@ -1343,7 +1343,7 @@ describe('Tooltip', () => {
const div = fixtureEl.querySelector('div')
expect(Tooltip.getInstance(div)).toEqual(null)
expect(Tooltip.getInstance(div)).toBeNull()
const tooltip = Tooltip.getOrCreateInstance(div, {
title: () => 'test'
})

View File

@ -30,13 +30,13 @@ describe('Backdrop', () => {
})
const getElements = () => document.querySelectorAll(CLASS_BACKDROP)
expect(getElements().length).toEqual(0)
expect(getElements()).toHaveSize(0)
instance.show()
instance.show(() => {
expect(getElements().length).toEqual(1)
expect(getElements()).toHaveSize(1)
for (const el of getElements()) {
expect(el.classList.contains(CLASS_NAME_SHOW)).toEqual(true)
expect(el).toHaveClass(CLASS_NAME_SHOW)
}
done()
@ -50,9 +50,9 @@ describe('Backdrop', () => {
})
const getElements = () => document.querySelectorAll(CLASS_BACKDROP)
expect(getElements().length).toEqual(0)
expect(getElements()).toHaveSize(0)
instance.show(() => {
expect(getElements().length).toEqual(0)
expect(getElements()).toHaveSize(0)
done()
})
})
@ -64,12 +64,12 @@ describe('Backdrop', () => {
})
const getElements = () => document.querySelectorAll(CLASS_BACKDROP)
expect(getElements().length).toEqual(0)
expect(getElements()).toHaveSize(0)
instance.show(() => {
expect(getElements().length).toEqual(1)
expect(getElements()).toHaveSize(1)
for (const el of getElements()) {
expect(el.classList.contains(CLASS_NAME_FADE)).toEqual(true)
expect(el).toHaveClass(CLASS_NAME_FADE)
}
done()
@ -86,11 +86,11 @@ describe('Backdrop', () => {
const getElements = () => document.body.querySelectorAll(CLASS_BACKDROP)
expect(getElements().length).toEqual(0)
expect(getElements()).toHaveSize(0)
instance.show(() => {
expect(getElements().length).toEqual(1)
expect(getElements()).toHaveSize(1)
instance.hide(() => {
expect(getElements().length).toEqual(0)
expect(getElements()).toHaveSize(0)
done()
})
})
@ -105,7 +105,7 @@ describe('Backdrop', () => {
instance.show()
instance.hide(() => {
expect(elem.classList.contains(CLASS_NAME_SHOW)).toEqual(false)
expect(elem).not.toHaveClass(CLASS_NAME_SHOW)
done()
})
})
@ -118,13 +118,13 @@ describe('Backdrop', () => {
const getElements = () => document.querySelectorAll(CLASS_BACKDROP)
const spy = spyOn(instance, 'dispose').and.callThrough()
expect(getElements().length).toEqual(0)
expect(instance._isAppended).toEqual(false)
expect(getElements()).toHaveSize(0)
expect(instance._isAppended).toBeFalse()
instance.show(() => {
instance.hide(() => {
expect(getElements().length).toEqual(0)
expect(getElements()).toHaveSize(0)
expect(spy).not.toHaveBeenCalled()
expect(instance._isAppended).toEqual(false)
expect(instance._isAppended).toBeFalse()
done()
})
})
@ -145,7 +145,7 @@ describe('Backdrop', () => {
instance.show(() => {
wrapper.remove()
instance.hide(() => {
expect(getElements().length).toEqual(0)
expect(getElements()).toHaveSize(0)
done()
})
})

View File

@ -182,10 +182,10 @@ describe('FocusTrap', () => {
it('should flag itself as no longer active', () => {
const focustrap = new FocusTrap({ trapElement: fixtureEl })
focustrap.activate()
expect(focustrap._isActive).toBe(true)
expect(focustrap._isActive).toBeTrue()
focustrap.deactivate()
expect(focustrap._isActive).toBe(false)
expect(focustrap._isActive).toBeFalse()
})
it('should remove all event listeners', () => {

View File

@ -179,9 +179,9 @@ describe('Util', () => {
const el = fixtureEl.querySelector('#foo')
expect(Util.isElement(el)).toEqual(true)
expect(Util.isElement({})).toEqual(false)
expect(Util.isElement(fixtureEl.querySelectorAll('.test'))).toEqual(false)
expect(Util.isElement(el)).toBeTrue()
expect(Util.isElement({})).toBeFalse()
expect(Util.isElement(fixtureEl.querySelectorAll('.test'))).toBeFalse()
})
it('should detect jQuery element', () => {
@ -193,7 +193,7 @@ describe('Util', () => {
jquery: 'foo'
}
expect(Util.isElement(fakejQuery)).toEqual(true)
expect(Util.isElement(fakejQuery)).toBeTrue()
})
})
@ -274,12 +274,12 @@ describe('Util', () => {
describe('isVisible', () => {
it('should return false if the element is not defined', () => {
expect(Util.isVisible(null)).toEqual(false)
expect(Util.isVisible(undefined)).toEqual(false)
expect(Util.isVisible(null)).toBeFalse()
expect(Util.isVisible(undefined)).toBeFalse()
})
it('should return false if the element provided is not a dom element', () => {
expect(Util.isVisible({})).toEqual(false)
expect(Util.isVisible({})).toBeFalse()
})
it('should return false if the element is not visible with display none', () => {
@ -287,7 +287,7 @@ describe('Util', () => {
const div = fixtureEl.querySelector('div')
expect(Util.isVisible(div)).toEqual(false)
expect(Util.isVisible(div)).toBeFalse()
})
it('should return false if the element is not visible with visibility hidden', () => {
@ -295,7 +295,7 @@ describe('Util', () => {
const div = fixtureEl.querySelector('div')
expect(Util.isVisible(div)).toEqual(false)
expect(Util.isVisible(div)).toBeFalse()
})
it('should return false if an ancestor element is display none', () => {
@ -311,7 +311,7 @@ describe('Util', () => {
const div = fixtureEl.querySelector('.content')
expect(Util.isVisible(div)).toEqual(false)
expect(Util.isVisible(div)).toBeFalse()
})
it('should return false if an ancestor element is visibility hidden', () => {
@ -327,7 +327,7 @@ describe('Util', () => {
const div = fixtureEl.querySelector('.content')
expect(Util.isVisible(div)).toEqual(false)
expect(Util.isVisible(div)).toBeFalse()
})
it('should return true if an ancestor element is visibility hidden, but reverted', () => {
@ -343,7 +343,7 @@ describe('Util', () => {
const div = fixtureEl.querySelector('.content')
expect(Util.isVisible(div)).toEqual(true)
expect(Util.isVisible(div)).toBeTrue()
})
it('should return true if the element is visible', () => {
@ -355,7 +355,7 @@ describe('Util', () => {
const div = fixtureEl.querySelector('#element')
expect(Util.isVisible(div)).toEqual(true)
expect(Util.isVisible(div)).toBeTrue()
})
it('should return false if the element is hidden, but not via display or visibility', () => {
@ -367,20 +367,20 @@ describe('Util', () => {
const div = fixtureEl.querySelector('#element')
expect(Util.isVisible(div)).toEqual(false)
expect(Util.isVisible(div)).toBeFalse()
})
})
describe('isDisabled', () => {
it('should return true if the element is not defined', () => {
expect(Util.isDisabled(null)).toEqual(true)
expect(Util.isDisabled(undefined)).toEqual(true)
expect(Util.isDisabled()).toEqual(true)
expect(Util.isDisabled(null)).toBeTrue()
expect(Util.isDisabled(undefined)).toBeTrue()
expect(Util.isDisabled()).toBeTrue()
})
it('should return true if the element provided is not a dom element', () => {
expect(Util.isDisabled({})).toEqual(true)
expect(Util.isDisabled('test')).toEqual(true)
expect(Util.isDisabled({})).toBeTrue()
expect(Util.isDisabled('test')).toBeTrue()
})
it('should return true if the element has disabled attribute', () => {
@ -396,9 +396,9 @@ describe('Util', () => {
const div1 = fixtureEl.querySelector('#element1')
const div2 = fixtureEl.querySelector('#element2')
expect(Util.isDisabled(div)).toEqual(true)
expect(Util.isDisabled(div1)).toEqual(true)
expect(Util.isDisabled(div2)).toEqual(true)
expect(Util.isDisabled(div)).toBeTrue()
expect(Util.isDisabled(div1)).toBeTrue()
expect(Util.isDisabled(div2)).toBeTrue()
})
it('should return false if the element has disabled attribute with "false" value, or doesn\'t have attribute', () => {
@ -412,8 +412,8 @@ describe('Util', () => {
const div = fixtureEl.querySelector('#element')
const div1 = fixtureEl.querySelector('#element1')
expect(Util.isDisabled(div)).toEqual(false)
expect(Util.isDisabled(div1)).toEqual(false)
expect(Util.isDisabled(div)).toBeFalse()
expect(Util.isDisabled(div1)).toBeFalse()
})
it('should return false if the element is not disabled ', () => {
@ -427,9 +427,9 @@ describe('Util', () => {
const el = selector => fixtureEl.querySelector(selector)
expect(Util.isDisabled(el('#button'))).toEqual(false)
expect(Util.isDisabled(el('#select'))).toEqual(false)
expect(Util.isDisabled(el('#input'))).toEqual(false)
expect(Util.isDisabled(el('#button'))).toBeFalse()
expect(Util.isDisabled(el('#select'))).toBeFalse()
expect(Util.isDisabled(el('#input'))).toBeFalse()
})
it('should return true if the element has disabled attribute', () => {
fixtureEl.innerHTML = [
@ -446,12 +446,12 @@ describe('Util', () => {
const el = selector => fixtureEl.querySelector(selector)
expect(Util.isDisabled(el('#input'))).toEqual(true)
expect(Util.isDisabled(el('#input1'))).toEqual(true)
expect(Util.isDisabled(el('#button'))).toEqual(true)
expect(Util.isDisabled(el('#button1'))).toEqual(true)
expect(Util.isDisabled(el('#button2'))).toEqual(true)
expect(Util.isDisabled(el('#input'))).toEqual(true)
expect(Util.isDisabled(el('#input'))).toBeTrue()
expect(Util.isDisabled(el('#input1'))).toBeTrue()
expect(Util.isDisabled(el('#button'))).toBeTrue()
expect(Util.isDisabled(el('#button1'))).toBeTrue()
expect(Util.isDisabled(el('#button2'))).toBeTrue()
expect(Util.isDisabled(el('#input'))).toBeTrue()
})
it('should return true if the element has class "disabled"', () => {
@ -463,7 +463,7 @@ describe('Util', () => {
const div = fixtureEl.querySelector('#element')
expect(Util.isDisabled(div)).toEqual(true)
expect(Util.isDisabled(div)).toBeTrue()
})
it('should return true if the element has class "disabled" but disabled attribute is false', () => {
@ -475,7 +475,7 @@ describe('Util', () => {
const div = fixtureEl.querySelector('#input')
expect(Util.isDisabled(div)).toEqual(true)
expect(Util.isDisabled(div)).toBeTrue()
})
})
@ -493,7 +493,7 @@ describe('Util', () => {
spyOn(document.documentElement, 'attachShadow').and.returnValue(null)
expect(Util.findShadowRoot(div)).toEqual(null)
expect(Util.findShadowRoot(div)).toBeNull()
})
it('should return null when we do not find a shadow root', () => {
@ -505,7 +505,7 @@ describe('Util', () => {
spyOn(document, 'getRootNode').and.returnValue(undefined)
expect(Util.findShadowRoot(document)).toEqual(null)
expect(Util.findShadowRoot(document)).toBeNull()
})
it('should return the shadow root when found', () => {
@ -532,7 +532,7 @@ describe('Util', () => {
describe('noop', () => {
it('should be a function', () => {
expect(typeof Util.noop).toEqual('function')
expect(Util.noop).toEqual(jasmine.any(Function))
})
})
@ -569,14 +569,14 @@ describe('Util', () => {
document.body.setAttribute('data-bs-no-jquery', '')
expect(window.jQuery).toEqual(fakejQuery)
expect(Util.getjQuery()).toEqual(null)
expect(Util.getjQuery()).toBeNull()
document.body.removeAttribute('data-bs-no-jquery')
})
it('should not return jQuery if not present', () => {
window.jQuery = undefined
expect(Util.getjQuery()).toEqual(null)
expect(Util.getjQuery()).toBeNull()
})
})
@ -628,9 +628,9 @@ describe('Util', () => {
pluginMock.jQueryInterface = function () {}
Util.defineJQueryPlugin(pluginMock)
expect(fakejQuery.fn.test).toBe(pluginMock.jQueryInterface)
expect(fakejQuery.fn.test.Constructor).toBe(pluginMock)
expect(typeof fakejQuery.fn.test.noConflict).toEqual('function')
expect(fakejQuery.fn.test).toEqual(pluginMock.jQueryInterface)
expect(fakejQuery.fn.test.Constructor).toEqual(pluginMock)
expect(fakejQuery.fn.test.noConflict).toEqual(jasmine.any(Function))
})
})

View File

@ -58,9 +58,9 @@ describe('ScrollBar', () => {
const result = new ScrollBarHelper().isOverflowing()
if (isScrollBarHidden()) {
expect(result).toEqual(false)
expect(result).toBeFalse()
} else {
expect(result).toEqual(true)
expect(result).toBeTrue()
}
})
@ -73,7 +73,7 @@ describe('ScrollBar', () => {
const scrollBar = new ScrollBarHelper()
const result = scrollBar.isOverflowing()
expect(result).toEqual(false)
expect(result).toBeFalse()
})
})
@ -87,7 +87,7 @@ describe('ScrollBar', () => {
const result = new ScrollBarHelper().getWidth()
if (isScrollBarHidden()) {
expect(result).toBe(0)
expect(result).toEqual(0)
} else {
expect(result).toBeGreaterThan(1)
}
@ -128,18 +128,18 @@ describe('ScrollBar', () => {
let currentPadding = getPaddingX(fixedEl)
let currentPadding2 = getPaddingX(fixedEl2)
expect(getPaddingAttr(fixedEl)).toEqual(`${originalPadding}px`, 'original fixed element padding should be stored in data-bs-padding-right')
expect(getPaddingAttr(fixedEl2)).toEqual(`${originalPadding2}px`, 'original fixed element padding should be stored in data-bs-padding-right')
expect(currentPadding).toEqual(expectedPadding, 'fixed element padding should be adjusted while opening')
expect(currentPadding2).toEqual(expectedPadding2, 'fixed element padding should be adjusted while opening')
expect(getPaddingAttr(fixedEl)).toEqual(`${originalPadding}px`)
expect(getPaddingAttr(fixedEl2)).toEqual(`${originalPadding2}px`)
expect(currentPadding).toEqual(expectedPadding)
expect(currentPadding2).toEqual(expectedPadding2)
scrollBar.reset()
currentPadding = getPaddingX(fixedEl)
currentPadding2 = getPaddingX(fixedEl2)
expect(getPaddingAttr(fixedEl)).toEqual(null, 'data-bs-padding-right should be cleared after closing')
expect(getPaddingAttr(fixedEl2)).toEqual(null, 'data-bs-padding-right should be cleared after closing')
expect(currentPadding).toEqual(originalPadding, 'fixed element padding should be reset after closing')
expect(currentPadding2).toEqual(originalPadding2, 'fixed element padding should be reset after closing')
expect(getPaddingAttr(fixedEl)).toBeNull()
expect(getPaddingAttr(fixedEl2)).toBeNull()
expect(currentPadding).toEqual(originalPadding)
expect(currentPadding2).toEqual(originalPadding2)
done()
})
@ -159,16 +159,16 @@ describe('ScrollBar', () => {
const expectedPadding = originalPadding + scrollBar.getWidth()
scrollBar.hide()
expect(getMarginAttr(stickyTopEl)).toEqual(`${originalMargin}px`, 'original sticky element margin should be stored in data-bs-margin-right')
expect(getMarginX(stickyTopEl)).toEqual(expectedMargin, 'sticky element margin should be adjusted while opening')
expect(getPaddingAttr(stickyTopEl)).toEqual(`${originalPadding}px`, 'original sticky element margin should be stored in data-bs-margin-right')
expect(getPaddingX(stickyTopEl)).toEqual(expectedPadding, 'sticky element margin should be adjusted while opening')
expect(getMarginAttr(stickyTopEl)).toEqual(`${originalMargin}px`)
expect(getMarginX(stickyTopEl)).toEqual(expectedMargin)
expect(getPaddingAttr(stickyTopEl)).toEqual(`${originalPadding}px`)
expect(getPaddingX(stickyTopEl)).toEqual(expectedPadding)
scrollBar.reset()
expect(getMarginAttr(stickyTopEl)).toEqual(null, 'data-bs-margin-right should be cleared after closing')
expect(getMarginX(stickyTopEl)).toEqual(originalMargin, 'sticky element margin should be reset after closing')
expect(getPaddingAttr(stickyTopEl)).toEqual(null, 'data-bs-margin-right should be cleared after closing')
expect(getPaddingX(stickyTopEl)).toEqual(originalPadding, 'sticky element margin should be reset after closing')
expect(getMarginAttr(stickyTopEl)).toBeNull()
expect(getMarginX(stickyTopEl)).toEqual(originalMargin)
expect(getPaddingAttr(stickyTopEl)).toBeNull()
expect(getPaddingX(stickyTopEl)).toEqual(originalPadding)
done()
})
@ -187,8 +187,8 @@ describe('ScrollBar', () => {
const currentMargin = getMarginX(stickyTopEl)
const currentPadding = getPaddingX(stickyTopEl)
expect(currentMargin).toEqual(originalMargin, 'sticky element\'s margin should not be adjusted while opening')
expect(currentPadding).toEqual(originalPadding, 'sticky element\'s padding should not be adjusted while opening')
expect(currentMargin).toEqual(originalMargin)
expect(currentPadding).toEqual(originalPadding)
scrollBar.reset()
})
@ -232,8 +232,8 @@ describe('ScrollBar', () => {
const scrollBarWidth = scrollBar.getWidth()
scrollBar.hide()
expect(getPaddingX(document.body)).toEqual(scrollBarWidth, 'body does not have inline padding set')
expect(document.body.style.color).toEqual('red', 'body still has other inline styles set')
expect(getPaddingX(document.body)).toEqual(scrollBarWidth)
expect(document.body.style.color).toEqual('red')
scrollBar.reset()
})
@ -273,9 +273,9 @@ describe('ScrollBar', () => {
const currentPadding1 = getPaddingX(el)
expect(currentPadding1).toEqual(originalPadding)
expect(getPaddingAttr(el)).toEqual(null)
expect(getPaddingAttr(el)).toBeNull()
expect(getOverFlow(el)).toEqual(originalOverFlow)
expect(getOverFlowAttr(el)).toEqual(null)
expect(getOverFlowAttr(el)).toBeNull()
})
it('should hide scrollbar and reset it to its initial value - respecting css rules', () => {
@ -308,9 +308,9 @@ describe('ScrollBar', () => {
const currentPadding1 = getPaddingX(el)
expect(currentPadding1).toEqual(originalPadding)
expect(getPaddingAttr(el)).toEqual(null)
expect(getPaddingAttr(el)).toBeNull()
expect(getOverFlow(el)).toEqual(originalOverFlow)
expect(getOverFlowAttr(el)).toEqual(null)
expect(getOverFlowAttr(el)).toBeNull()
})
it('should not adjust the inline body padding when it does not overflow', () => {
@ -324,7 +324,7 @@ describe('ScrollBar', () => {
scrollBar.hide()
const currentPadding = getPaddingX(document.body)
expect(currentPadding).toEqual(originalPadding, 'body padding should not be adjusted')
expect(currentPadding).toEqual(originalPadding)
scrollBar.reset()
})
@ -344,7 +344,7 @@ describe('ScrollBar', () => {
const currentPadding = getPaddingX(document.body)
expect(currentPadding).toEqual(originalPadding, 'body padding should not be adjusted')
expect(currentPadding).toEqual(originalPadding)
scrollBar.reset()
})

View File

@ -86,15 +86,15 @@ describe('TemplateFactory', () => {
const factory = new TemplateFactory({
extraClass: 'testClass'
})
expect(factory.toHtml().classList.contains('testClass')).toBeTrue()
expect(factory.toHtml()).toHaveClass('testClass')
})
it('should add extra classes', () => {
const factory = new TemplateFactory({
extraClass: 'testClass testClass2'
})
expect(factory.toHtml().classList.contains('testClass')).toBeTrue()
expect(factory.toHtml().classList.contains('testClass2')).toBeTrue()
expect(factory.toHtml()).toHaveClass('testClass')
expect(factory.toHtml()).toHaveClass('testClass2')
})
it('should resolve class if function is given', () => {
@ -105,7 +105,7 @@ describe('TemplateFactory', () => {
}
})
expect(factory.toHtml().classList.contains('testClass')).toBeTrue()
expect(factory.toHtml()).toHaveClass('testClass')
})
})
})
@ -128,8 +128,8 @@ describe('TemplateFactory', () => {
})
const html = factory.toHtml()
expect(html.querySelector('.foo').textContent).toBe('bar')
expect(html.querySelector('.foo2').textContent).toBe('bar2')
expect(html.querySelector('.foo').textContent).toEqual('bar')
expect(html.querySelector('.foo2').textContent).toEqual('bar2')
})
it('should not fill template if selector not exists', () => {
@ -140,7 +140,7 @@ describe('TemplateFactory', () => {
content: { '#bar': 'test' }
})
expect(factory.toHtml().outerHTML).toBe('<div id="foo"></div>')
expect(factory.toHtml().outerHTML).toEqual('<div id="foo"></div>')
})
it('should remove template selector, if content is null', () => {
@ -151,7 +151,7 @@ describe('TemplateFactory', () => {
content: { '#foo': null }
})
expect(factory.toHtml().outerHTML).toBe('<div></div>')
expect(factory.toHtml().outerHTML).toEqual('<div></div>')
})
it('should resolve content if is function', () => {
@ -162,7 +162,7 @@ describe('TemplateFactory', () => {
content: { '#foo': () => null }
})
expect(factory.toHtml().outerHTML).toBe('<div></div>')
expect(factory.toHtml().outerHTML).toEqual('<div></div>')
})
it('if content is element and "config.html=false", should put content\'s textContent', () => {
@ -176,9 +176,9 @@ describe('TemplateFactory', () => {
})
const fooEl = factory.toHtml().querySelector('#foo')
expect(fooEl.innerHTML).not.toBe(contentElement.innerHTML)
expect(fooEl.textContent).toBe(contentElement.textContent)
expect(fooEl.textContent).toBe('foobar')
expect(fooEl.innerHTML).not.toEqual(contentElement.innerHTML)
expect(fooEl.textContent).toEqual(contentElement.textContent)
expect(fooEl.textContent).toEqual('foobar')
})
it('if content is element and "config.html=true", should put content\'s outerHtml as child', () => {
@ -192,8 +192,8 @@ describe('TemplateFactory', () => {
})
const fooEl = factory.toHtml().querySelector('#foo')
expect(fooEl.innerHTML).toBe(contentElement.outerHTML)
expect(fooEl.textContent).toBe(contentElement.textContent)
expect(fooEl.innerHTML).toEqual(contentElement.outerHTML)
expect(fooEl.textContent).toEqual(contentElement.textContent)
})
})