diff options
author | Johann-S <johann.servoire@gmail.com> | 2020-03-25 17:35:02 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-25 17:35:02 +0300 |
commit | 26d86fce2a10f5c9e295b0acf5e6381ff21368b4 (patch) | |
tree | 63ed06cb159ad7b625aa6b4c8d7460a1a269db43 /js/tests/unit | |
parent | 98c45986962f8ab16bc630722e96dbfb048079b3 (diff) |
fix: remove make array util function (#30430)
Diffstat (limited to 'js/tests/unit')
-rw-r--r-- | js/tests/unit/alert.spec.js | 10 | ||||
-rw-r--r-- | js/tests/unit/collapse.spec.js | 3 | ||||
-rw-r--r-- | js/tests/unit/dom/selector-engine.spec.js | 11 | ||||
-rw-r--r-- | js/tests/unit/modal.spec.js | 9 | ||||
-rw-r--r-- | js/tests/unit/popover.spec.js | 3 | ||||
-rw-r--r-- | js/tests/unit/tooltip.spec.js | 6 | ||||
-rw-r--r-- | js/tests/unit/util/index.spec.js | 14 |
7 files changed, 18 insertions, 38 deletions
diff --git a/js/tests/unit/alert.spec.js b/js/tests/unit/alert.spec.js index 8a3d33dcf8..9372215b65 100644 --- a/js/tests/unit/alert.spec.js +++ b/js/tests/unit/alert.spec.js @@ -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() }) diff --git a/js/tests/unit/collapse.spec.js b/js/tests/unit/collapse.spec.js index 3122ae6f4b..7eb0f598ec 100644 --- a/js/tests/unit/collapse.spec.js +++ b/js/tests/unit/collapse.spec.js @@ -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 diff --git a/js/tests/unit/dom/selector-engine.spec.js b/js/tests/unit/dom/selector-engine.spec.js index 727f106214..781d0ce1b5 100644 --- a/js/tests/unit/dom/selector-engine.spec.js +++ b/js/tests/unit/dom/selector-engine.spec.js @@ -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) }) diff --git a/js/tests/unit/modal.spec.js b/js/tests/unit/modal.spec.js index 62d0835ee9..c5fbc3a273 100644 --- a/js/tests/unit/modal.spec.js +++ b/js/tests/unit/modal.spec.js @@ -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' }) diff --git a/js/tests/unit/popover.spec.js b/js/tests/unit/popover.spec.js index 1c6cd389c9..acaf0a48c2 100644 --- a/js/tests/unit/popover.spec.js +++ b/js/tests/unit/popover.spec.js @@ -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) diff --git a/js/tests/unit/tooltip.spec.js b/js/tests/unit/tooltip.spec.js index 338638a2d7..ed89315e0b 100644 --- a/js/tests/unit/tooltip.spec.js +++ b/js/tests/unit/tooltip.spec.js @@ -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) }) }) diff --git a/js/tests/unit/util/index.spec.js b/js/tests/unit/util/index.spec.js index 57ca1a9c73..541c10baa7 100644 --- a/js/tests/unit/util/index.spec.js +++ b/js/tests/unit/util/index.spec.js @@ -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) |