mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-13 09:04:14 +02:00
fix: remove make array util function (#30430)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import Alert from '../../src/alert'
|
||||
import { makeArray, getTransitionDurationFromElement } from '../../src/util/index'
|
||||
import { getTransitionDurationFromElement } from '../../src/util/index'
|
||||
|
||||
/** Test helpers */
|
||||
import { getFixture, clearFixture, jQueryMock } from '../helpers/fixture'
|
||||
@@ -30,7 +30,7 @@ describe('Alert', () => {
|
||||
const button = document.querySelector('button')
|
||||
|
||||
button.click()
|
||||
expect(makeArray(document.querySelectorAll('.alert')).length).toEqual(0)
|
||||
expect(document.querySelectorAll('.alert').length).toEqual(0)
|
||||
})
|
||||
|
||||
it('should close an alert without instantiating it manually with the parent selector', () => {
|
||||
@@ -43,7 +43,7 @@ describe('Alert', () => {
|
||||
const button = document.querySelector('button')
|
||||
|
||||
button.click()
|
||||
expect(makeArray(document.querySelectorAll('.alert')).length).toEqual(0)
|
||||
expect(document.querySelectorAll('.alert').length).toEqual(0)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -56,7 +56,7 @@ describe('Alert', () => {
|
||||
const alert = new Alert(alertEl)
|
||||
|
||||
alertEl.addEventListener('closed.bs.alert', () => {
|
||||
expect(makeArray(document.querySelectorAll('.alert')).length).toEqual(0)
|
||||
expect(document.querySelectorAll('.alert').length).toEqual(0)
|
||||
expect(spy).not.toHaveBeenCalled()
|
||||
done()
|
||||
})
|
||||
@@ -75,7 +75,7 @@ describe('Alert', () => {
|
||||
})
|
||||
|
||||
alertEl.addEventListener('closed.bs.alert', () => {
|
||||
expect(makeArray(document.querySelectorAll('.alert')).length).toEqual(0)
|
||||
expect(document.querySelectorAll('.alert').length).toEqual(0)
|
||||
done()
|
||||
})
|
||||
|
||||
|
@@ -1,6 +1,5 @@
|
||||
import Collapse from '../../src/collapse'
|
||||
import EventHandler from '../../src/dom/event-handler'
|
||||
import { makeArray } from '../../src/util/index'
|
||||
|
||||
/** Test helpers */
|
||||
import { getFixture, clearFixture, jQueryMock } from '../helpers/fixture'
|
||||
@@ -139,7 +138,7 @@ describe('Collapse', () => {
|
||||
const collapseEl1 = fixtureEl.querySelector('#collapse1')
|
||||
const collapseEl2 = fixtureEl.querySelector('#collapse2')
|
||||
|
||||
const collapseList = makeArray(fixtureEl.querySelectorAll('.collapse'))
|
||||
const collapseList = [].concat(...fixtureEl.querySelectorAll('.collapse'))
|
||||
.map(el => new Collapse(el, {
|
||||
parent,
|
||||
toggle: false
|
||||
|
@@ -1,5 +1,4 @@
|
||||
import SelectorEngine from '../../../src/dom/selector-engine'
|
||||
import { makeArray } from '../../../src/util/index'
|
||||
|
||||
/** Test helpers */
|
||||
import { getFixture, clearFixture } from '../../helpers/fixture'
|
||||
@@ -29,7 +28,7 @@ describe('SelectorEngine', () => {
|
||||
|
||||
const div = fixtureEl.querySelector('div')
|
||||
|
||||
expect(makeArray(SelectorEngine.find('div', fixtureEl))).toEqual([div])
|
||||
expect(SelectorEngine.find('div', fixtureEl)).toEqual([div])
|
||||
})
|
||||
|
||||
it('should find elements globaly', () => {
|
||||
@@ -37,7 +36,7 @@ describe('SelectorEngine', () => {
|
||||
|
||||
const div = fixtureEl.querySelector('#test')
|
||||
|
||||
expect(makeArray(SelectorEngine.find('#test'))).toEqual([div])
|
||||
expect(SelectorEngine.find('#test')).toEqual([div])
|
||||
})
|
||||
|
||||
it('should handle :scope selectors', () => {
|
||||
@@ -52,7 +51,7 @@ describe('SelectorEngine', () => {
|
||||
const listEl = fixtureEl.querySelector('ul')
|
||||
const aActive = fixtureEl.querySelector('.active')
|
||||
|
||||
expect(makeArray(SelectorEngine.find(':scope > li > .active', listEl))).toEqual([aActive])
|
||||
expect(SelectorEngine.find(':scope > li > .active', listEl)).toEqual([aActive])
|
||||
})
|
||||
})
|
||||
|
||||
@@ -75,8 +74,8 @@ describe('SelectorEngine', () => {
|
||||
</ul>`
|
||||
|
||||
const list = fixtureEl.querySelector('ul')
|
||||
const liList = makeArray(fixtureEl.querySelectorAll('li'))
|
||||
const result = makeArray(SelectorEngine.children(list, 'li'))
|
||||
const liList = [].concat(...fixtureEl.querySelectorAll('li'))
|
||||
const result = SelectorEngine.children(list, 'li')
|
||||
|
||||
expect(result).toEqual(liList)
|
||||
})
|
||||
|
@@ -1,6 +1,5 @@
|
||||
import Modal from '../../src/modal'
|
||||
import EventHandler from '../../src/dom/event-handler'
|
||||
import { makeArray } from '../../src/util/index'
|
||||
|
||||
/** Test helpers */
|
||||
import { getFixture, clearFixture, createEvent, jQueryMock } from '../helpers/fixture'
|
||||
@@ -31,11 +30,11 @@ describe('Modal', () => {
|
||||
document.body.classList.remove('modal-open')
|
||||
document.body.removeAttribute('style')
|
||||
document.body.removeAttribute('data-padding-right')
|
||||
const backdropList = makeArray(document.querySelectorAll('.modal-backdrop'))
|
||||
|
||||
backdropList.forEach(backdrop => {
|
||||
document.body.removeChild(backdrop)
|
||||
})
|
||||
document.querySelectorAll('.modal-backdrop')
|
||||
.forEach(backdrop => {
|
||||
document.body.removeChild(backdrop)
|
||||
})
|
||||
|
||||
document.body.style.paddingRight = '0px'
|
||||
})
|
||||
|
@@ -1,5 +1,4 @@
|
||||
import Popover from '../../src/popover'
|
||||
import { makeArray } from '../../src/util/index'
|
||||
|
||||
/** Test helpers */
|
||||
import { getFixture, clearFixture, jQueryMock } from '../helpers/fixture'
|
||||
@@ -14,7 +13,7 @@ describe('Popover', () => {
|
||||
afterEach(() => {
|
||||
clearFixture()
|
||||
|
||||
const popoverList = makeArray(document.querySelectorAll('.popover'))
|
||||
const popoverList = document.querySelectorAll('.popover')
|
||||
|
||||
popoverList.forEach(popoverEl => {
|
||||
document.body.removeChild(popoverEl)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import Tooltip from '../../src/tooltip'
|
||||
import EventHandler from '../../src/dom/event-handler'
|
||||
import { makeArray, noop } from '../../src/util/index'
|
||||
import { noop } from '../../src/util/index'
|
||||
|
||||
/** Test helpers */
|
||||
import { getFixture, clearFixture, jQueryMock, createEvent } from '../helpers/fixture'
|
||||
@@ -15,9 +15,7 @@ describe('Tooltip', () => {
|
||||
afterEach(() => {
|
||||
clearFixture()
|
||||
|
||||
const tooltipList = makeArray(document.querySelectorAll('.tooltip'))
|
||||
|
||||
tooltipList.forEach(tooltipEl => {
|
||||
document.querySelectorAll('.tooltip').forEach(tooltipEl => {
|
||||
document.body.removeChild(tooltipEl)
|
||||
})
|
||||
})
|
||||
|
@@ -244,20 +244,6 @@ describe('Util', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('makeArray', () => {
|
||||
it('should convert node list to array', () => {
|
||||
const nodeList = document.querySelectorAll('div')
|
||||
|
||||
expect(Array.isArray(nodeList)).toEqual(false)
|
||||
expect(Array.isArray(Util.makeArray(nodeList))).toEqual(true)
|
||||
})
|
||||
|
||||
it('should return an empty array if the nodeList is undefined', () => {
|
||||
expect(Util.makeArray(null)).toEqual([])
|
||||
expect(Util.makeArray(undefined)).toEqual([])
|
||||
})
|
||||
})
|
||||
|
||||
describe('isVisible', () => {
|
||||
it('should return false if the element is not defined', () => {
|
||||
expect(Util.isVisible(null)).toEqual(false)
|
||||
|
Reference in New Issue
Block a user