1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-02-19 15:40:59 +00:00

tests: try to fix a few random failures (#35184)

* Change `Swipe` dispose spy on EventHandler
* Modal hide spy on backdrop hide
This commit is contained in:
GeoSot 2021-10-13 17:45:39 +03:00 committed by GitHub
parent 9640e2d5dd
commit b991a6b851
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 5 deletions

View File

@ -1268,6 +1268,7 @@ describe('Carousel', () => {
carousel.dispose()
expect(carousel._swipeHelper).toBeNull()
expect(removeEventSpy).toHaveBeenCalledWith(carouselEl, Carousel.EVENT_KEY)
expect(swipeHelperSpy).toHaveBeenCalled()

View File

@ -608,6 +608,7 @@ describe('Modal', () => {
const modalEl = fixtureEl.querySelector('.modal')
const modal = new Modal(modalEl)
const backdropSpy = spyOn(modal._backdrop, 'hide').and.callThrough()
modalEl.addEventListener('shown.bs.modal', () => {
modal.hide()
@ -622,7 +623,7 @@ describe('Modal', () => {
expect(modalEl.getAttribute('role')).toBeNull()
expect(modalEl.getAttribute('aria-hidden')).toEqual('true')
expect(modalEl.style.display).toEqual('none')
expect(document.querySelector('.modal-backdrop')).toBeNull()
expect(backdropSpy).toHaveBeenCalled()
done()
})

View File

@ -232,7 +232,7 @@ describe('Swipe', () => {
it('should destroy', () => {
const addEventSpy = spyOn(fixtureEl, 'addEventListener').and.callThrough()
const removeEventSpy = spyOn(fixtureEl, 'removeEventListener').and.callThrough()
const removeEventSpy = spyOn(EventHandler, 'off').and.callThrough()
defineDocumentElementOntouchstart()
const swipe = new Swipe(fixtureEl)
@ -253,9 +253,8 @@ describe('Swipe', () => {
swipe.dispose()
expect(removeEventSpy.calls.allArgs()).toEqual(expectedArgs)
delete document.documentElement.ontouchstart
expect(removeEventSpy).toHaveBeenCalledWith(fixtureEl, '.bs.swipe')
deleteDocumentElementOntouchstart()
})
})