2
0
mirror of https://github.com/tenrok/bootstrap.git synced 2026-06-17 19:21:23 +03:00

tests: minor cleanup (#35138)

* tests: minor cleanup

* tests: use the util noop function
This commit is contained in:
XhmikosR
2021-10-08 12:32:11 +03:00
committed by GitHub
parent eb0f705621
commit a260967a55
18 changed files with 19 additions and 57 deletions
+11 -13
View File
@@ -1,9 +1,7 @@
import Carousel from '../../src/carousel'
import EventHandler from '../../src/dom/event-handler'
/** Test helpers */
import { clearFixture, createEvent, getFixture, jQueryMock } from '../helpers/fixture'
import * as util from '../../src/util'
import { isRTL, noop } from '../../src/util/index'
describe('Carousel', () => {
const { Simulator, PointerEvent } = window
@@ -331,7 +329,7 @@ describe('Carousel', () => {
// Headless browser does not support touch events, so need to fake it
// to test that touch events are add properly.
document.documentElement.ontouchstart = () => {}
document.documentElement.ontouchstart = noop
const carousel = new Carousel(carouselEl)
expect(carousel._addTouchEventListeners).toHaveBeenCalled()
@@ -344,7 +342,7 @@ describe('Carousel', () => {
return
}
document.documentElement.ontouchstart = () => {}
document.documentElement.ontouchstart = noop
document.head.append(stylesCarousel)
Simulator.setType('pointer')
@@ -389,7 +387,7 @@ describe('Carousel', () => {
return
}
document.documentElement.ontouchstart = () => {}
document.documentElement.ontouchstart = noop
document.head.append(stylesCarousel)
Simulator.setType('pointer')
@@ -431,7 +429,7 @@ describe('Carousel', () => {
it('should allow swiperight and call _slide (prev) with touch events', done => {
Simulator.setType('touch')
clearPointerEvents()
document.documentElement.ontouchstart = () => {}
document.documentElement.ontouchstart = noop
fixtureEl.innerHTML = [
'<div class="carousel" data-bs-interval="false">',
@@ -470,7 +468,7 @@ describe('Carousel', () => {
it('should allow swipeleft and call _slide (next) with touch events', done => {
Simulator.setType('touch')
clearPointerEvents()
document.documentElement.ontouchstart = () => {}
document.documentElement.ontouchstart = noop
fixtureEl.innerHTML = [
'<div class="carousel" data-bs-interval="false">',
@@ -510,7 +508,7 @@ describe('Carousel', () => {
it('should not slide when swiping and carousel is sliding', done => {
Simulator.setType('touch')
clearPointerEvents()
document.documentElement.ontouchstart = () => {}
document.documentElement.ontouchstart = noop
fixtureEl.innerHTML = [
'<div class="carousel" data-bs-interval="false">',
@@ -553,7 +551,7 @@ describe('Carousel', () => {
it('should not allow pinch with touch events', done => {
Simulator.setType('touch')
clearPointerEvents()
document.documentElement.ontouchstart = () => {}
document.documentElement.ontouchstart = noop
fixtureEl.innerHTML = '<div class="carousel" data-bs-interval="false"></div>'
@@ -978,7 +976,7 @@ describe('Carousel', () => {
const carouselEl = fixtureEl.querySelector('#myCarousel')
const carousel = new Carousel(carouselEl)
carousel._interval = setInterval(() => {}, 10)
carousel._interval = setInterval(noop, 10)
spyOn(window, 'setInterval').and.callThrough()
spyOn(window, 'clearInterval').and.callThrough()
@@ -1175,7 +1173,7 @@ describe('Carousel', () => {
const carouselEl = fixtureEl.querySelector('div')
const carousel = new Carousel(carouselEl, {})
expect(util.isRTL()).toEqual(true, 'rtl has to be true')
expect(isRTL()).toEqual(true, 'rtl has to be true')
expect(carousel._directionToOrder('left')).toEqual('prev')
expect(carousel._directionToOrder('prev')).toEqual('prev')
@@ -1243,7 +1241,7 @@ describe('Carousel', () => {
// Headless browser does not support touch events, so need to fake it
// to test that touch events are add/removed properly.
document.documentElement.ontouchstart = () => {}
document.documentElement.ontouchstart = noop
const carousel = new Carousel(carouselEl)