mirror of
https://github.com/twbs/bootstrap.git
synced 2025-02-19 16:54:24 +01:00
tests: minor cleanup (#35138)
* tests: minor cleanup * tests: use the util noop function
This commit is contained in:
parent
eb0f705621
commit
a260967a55
@ -1,7 +1,5 @@
|
||||
import Alert from '../../src/alert'
|
||||
import { getTransitionDurationFromElement } from '../../src/util/index'
|
||||
|
||||
/** Test helpers */
|
||||
import { clearFixture, getFixture, jQueryMock } from '../helpers/fixture'
|
||||
|
||||
describe('Alert', () => {
|
||||
|
@ -1,11 +1,5 @@
|
||||
import Button from '../../src/button'
|
||||
|
||||
/** Test helpers */
|
||||
import {
|
||||
getFixture,
|
||||
clearFixture,
|
||||
jQueryMock
|
||||
} from '../helpers/fixture'
|
||||
import { getFixture, clearFixture, jQueryMock } from '../helpers/fixture'
|
||||
|
||||
describe('Button', () => {
|
||||
let fixtureEl
|
||||
|
@ -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)
|
||||
|
||||
|
@ -1,7 +1,5 @@
|
||||
import Collapse from '../../src/collapse'
|
||||
import EventHandler from '../../src/dom/event-handler'
|
||||
|
||||
/** Test helpers */
|
||||
import { clearFixture, getFixture, jQueryMock } from '../helpers/fixture'
|
||||
|
||||
describe('Collapse', () => {
|
||||
|
@ -1,6 +1,4 @@
|
||||
import Data from '../../../src/dom/data'
|
||||
|
||||
/** Test helpers */
|
||||
import { getFixture, clearFixture } from '../../helpers/fixture'
|
||||
|
||||
describe('Data', () => {
|
||||
@ -90,8 +88,8 @@ describe('Data', () => {
|
||||
expect(Data.get(div, TEST_KEY)).toBeNull()
|
||||
})
|
||||
|
||||
/* eslint-disable no-console */
|
||||
it('should console.error a message if called with multiple keys', () => {
|
||||
/* eslint-disable no-console */
|
||||
console.error = jasmine.createSpy('console.error')
|
||||
|
||||
const data = { ...TEST_DATA }
|
||||
@ -103,4 +101,5 @@ describe('Data', () => {
|
||||
expect(console.error).toHaveBeenCalled()
|
||||
expect(Data.get(div, UNKNOWN_KEY)).toBe(null)
|
||||
})
|
||||
/* eslint-enable no-console */
|
||||
})
|
||||
|
@ -1,6 +1,4 @@
|
||||
import EventHandler from '../../../src/dom/event-handler'
|
||||
|
||||
/** Test helpers */
|
||||
import { getFixture, clearFixture } from '../../helpers/fixture'
|
||||
|
||||
describe('EventHandler', () => {
|
||||
|
@ -1,6 +1,4 @@
|
||||
import Manipulator from '../../../src/dom/manipulator'
|
||||
|
||||
/** Test helpers */
|
||||
import { getFixture, clearFixture } from '../../helpers/fixture'
|
||||
|
||||
describe('Manipulator', () => {
|
||||
|
@ -1,6 +1,4 @@
|
||||
import SelectorEngine from '../../../src/dom/selector-engine'
|
||||
|
||||
/** Test helpers */
|
||||
import { getFixture, clearFixture } from '../../helpers/fixture'
|
||||
|
||||
describe('SelectorEngine', () => {
|
||||
|
@ -1,8 +1,6 @@
|
||||
import Dropdown from '../../src/dropdown'
|
||||
import EventHandler from '../../src/dom/event-handler'
|
||||
import { noop } from '../../src/util'
|
||||
|
||||
/** Test helpers */
|
||||
import { noop } from '../../src/util/index'
|
||||
import { clearFixture, createEvent, getFixture, jQueryMock } from '../helpers/fixture'
|
||||
|
||||
describe('Dropdown', () => {
|
||||
@ -225,7 +223,7 @@ describe('Dropdown', () => {
|
||||
const btnDropdown = fixtureEl.querySelector('[data-bs-toggle="dropdown"]')
|
||||
const dropdown = new Dropdown(btnDropdown)
|
||||
|
||||
document.documentElement.ontouchstart = () => {}
|
||||
document.documentElement.ontouchstart = noop
|
||||
spyOn(EventHandler, 'on')
|
||||
spyOn(EventHandler, 'off')
|
||||
|
||||
@ -891,7 +889,7 @@ describe('Dropdown', () => {
|
||||
const btnDropdown = fixtureEl.querySelector('[data-bs-toggle="dropdown"]')
|
||||
const dropdown = new Dropdown(btnDropdown)
|
||||
|
||||
document.documentElement.ontouchstart = () => {}
|
||||
document.documentElement.ontouchstart = noop
|
||||
spyOn(EventHandler, 'off')
|
||||
|
||||
btnDropdown.addEventListener('shown.bs.dropdown', () => {
|
||||
|
@ -1,4 +1,5 @@
|
||||
/* eslint-env jquery */
|
||||
|
||||
import Alert from '../../src/alert'
|
||||
import Button from '../../src/button'
|
||||
import Carousel from '../../src/carousel'
|
||||
@ -11,8 +12,6 @@ import ScrollSpy from '../../src/scrollspy'
|
||||
import Tab from '../../src/tab'
|
||||
import Toast from '../../src/toast'
|
||||
import Tooltip from '../../src/tooltip'
|
||||
|
||||
/** Test helpers */
|
||||
import { getFixture, clearFixture } from '../helpers/fixture'
|
||||
|
||||
describe('jQuery', () => {
|
||||
|
@ -1,8 +1,6 @@
|
||||
import Modal from '../../src/modal'
|
||||
import EventHandler from '../../src/dom/event-handler'
|
||||
import ScrollBarHelper from '../../src/util/scrollbar'
|
||||
|
||||
/** Test helpers */
|
||||
import { clearBodyAndDocument, clearFixture, createEvent, getFixture, jQueryMock } from '../helpers/fixture'
|
||||
|
||||
describe('Modal', () => {
|
||||
|
@ -1,9 +1,7 @@
|
||||
import Offcanvas from '../../src/offcanvas'
|
||||
import EventHandler from '../../src/dom/event-handler'
|
||||
|
||||
/** Test helpers */
|
||||
import { clearBodyAndDocument, clearFixture, createEvent, getFixture, jQueryMock } from '../helpers/fixture'
|
||||
import { isVisible } from '../../src/util'
|
||||
import { isVisible } from '../../src/util/index'
|
||||
import ScrollBarHelper from '../../src/util/scrollbar'
|
||||
|
||||
describe('Offcanvas', () => {
|
||||
|
@ -1,6 +1,4 @@
|
||||
import Popover from '../../src/popover'
|
||||
|
||||
/** Test helpers */
|
||||
import { clearFixture, getFixture, jQueryMock } from '../helpers/fixture'
|
||||
|
||||
describe('Popover', () => {
|
||||
|
@ -1,7 +1,5 @@
|
||||
import ScrollSpy from '../../src/scrollspy'
|
||||
import Manipulator from '../../src/dom/manipulator'
|
||||
|
||||
/** Test helpers */
|
||||
import { getFixture, clearFixture, createEvent, jQueryMock } from '../helpers/fixture'
|
||||
|
||||
describe('ScrollSpy', () => {
|
||||
|
@ -1,6 +1,4 @@
|
||||
import Tab from '../../src/tab'
|
||||
|
||||
/** Test helpers */
|
||||
import { getFixture, clearFixture, jQueryMock } from '../helpers/fixture'
|
||||
|
||||
describe('Tab', () => {
|
||||
|
@ -1,6 +1,4 @@
|
||||
import Toast from '../../src/toast'
|
||||
|
||||
/** Test helpers */
|
||||
import { getFixture, clearFixture, createEvent, jQueryMock } from '../helpers/fixture'
|
||||
|
||||
describe('Toast', () => {
|
||||
|
@ -1,8 +1,6 @@
|
||||
import Tooltip from '../../src/tooltip'
|
||||
import EventHandler from '../../src/dom/event-handler'
|
||||
import { noop } from '../../src/util/index'
|
||||
|
||||
/** Test helpers */
|
||||
import { clearFixture, createEvent, getFixture, jQueryMock } from '../helpers/fixture'
|
||||
|
||||
describe('Tooltip', () => {
|
||||
|
@ -1,6 +1,4 @@
|
||||
import * as Util from '../../../src/util/index'
|
||||
|
||||
/** Test helpers */
|
||||
import { clearFixture, getFixture } from '../../helpers/fixture'
|
||||
|
||||
describe('Util', () => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user