aboutsummaryrefslogtreecommitdiff
path: root/js/tests
diff options
context:
space:
mode:
Diffstat (limited to 'js/tests')
-rw-r--r--js/tests/helpers/fixture.js8
-rw-r--r--js/tests/unit/carousel.spec.js6
-rw-r--r--js/tests/unit/modal.spec.js7
-rw-r--r--js/tests/unit/popover.spec.js4
-rw-r--r--js/tests/unit/tooltip.spec.js4
-rw-r--r--js/tests/unit/util/backdrop.spec.js14
6 files changed, 22 insertions, 21 deletions
diff --git a/js/tests/helpers/fixture.js b/js/tests/helpers/fixture.js
index 29fa91896..02915af44 100644
--- a/js/tests/helpers/fixture.js
+++ b/js/tests/helpers/fixture.js
@@ -34,17 +34,17 @@ export const jQueryMock = {
elements: undefined,
fn: {},
each(fn) {
- this.elements.forEach(el => {
+ for (const el of this.elements) {
fn.call(el)
- })
+ }
}
}
export const clearBodyAndDocument = () => {
const attributes = ['data-bs-padding-right', 'style']
- attributes.forEach(attr => {
+ for (const attr of attributes) {
document.documentElement.removeAttribute(attr)
document.body.removeAttribute(attr)
- })
+ }
}
diff --git a/js/tests/unit/carousel.spec.js b/js/tests/unit/carousel.spec.js
index 83ba28912..9e5cfea86 100644
--- a/js/tests/unit/carousel.spec.js
+++ b/js/tests/unit/carousel.spec.js
@@ -211,14 +211,14 @@ describe('Carousel', () => {
spyOn(carousel, '_triggerSlideEvent')
- carousel._isSliding = true;
+ carousel._isSliding = true
- ['ArrowLeft', 'ArrowRight'].forEach(key => {
+ for (const key of ['ArrowLeft', 'ArrowRight']) {
const keydown = createEvent('keydown')
keydown.key = key
carouselEl.dispatchEvent(keydown)
- })
+ }
expect(carousel._triggerSlideEvent).not.toHaveBeenCalled()
})
diff --git a/js/tests/unit/modal.spec.js b/js/tests/unit/modal.spec.js
index 9632fa6cf..211c7140f 100644
--- a/js/tests/unit/modal.spec.js
+++ b/js/tests/unit/modal.spec.js
@@ -17,10 +17,9 @@ describe('Modal', () => {
clearBodyAndDocument()
document.body.classList.remove('modal-open')
- document.querySelectorAll('.modal-backdrop')
- .forEach(backdrop => {
- backdrop.remove()
- })
+ for (const backdrop of document.querySelectorAll('.modal-backdrop')) {
+ backdrop.remove()
+ }
})
beforeEach(() => {
diff --git a/js/tests/unit/popover.spec.js b/js/tests/unit/popover.spec.js
index c54fc49ee..c068e2fab 100644
--- a/js/tests/unit/popover.spec.js
+++ b/js/tests/unit/popover.spec.js
@@ -15,9 +15,9 @@ describe('Popover', () => {
const popoverList = document.querySelectorAll('.popover')
- popoverList.forEach(popoverEl => {
+ for (const popoverEl of popoverList) {
popoverEl.remove()
- })
+ }
})
describe('VERSION', () => {
diff --git a/js/tests/unit/tooltip.spec.js b/js/tests/unit/tooltip.spec.js
index 22a7edd01..01ab1b149 100644
--- a/js/tests/unit/tooltip.spec.js
+++ b/js/tests/unit/tooltip.spec.js
@@ -15,9 +15,9 @@ describe('Tooltip', () => {
afterEach(() => {
clearFixture()
- document.querySelectorAll('.tooltip').forEach(tooltipEl => {
+ for (const tooltipEl of document.querySelectorAll('.tooltip')) {
tooltipEl.remove()
- })
+ }
})
describe('VERSION', () => {
diff --git a/js/tests/unit/util/backdrop.spec.js b/js/tests/unit/util/backdrop.spec.js
index b885b60b5..818ddf221 100644
--- a/js/tests/unit/util/backdrop.spec.js
+++ b/js/tests/unit/util/backdrop.spec.js
@@ -17,9 +17,9 @@ describe('Backdrop', () => {
clearFixture()
const list = document.querySelectorAll(CLASS_BACKDROP)
- list.forEach(el => {
+ for (const el of list) {
el.remove()
- })
+ }
})
describe('show', () => {
@@ -35,9 +35,10 @@ describe('Backdrop', () => {
instance.show()
instance.show(() => {
expect(getElements().length).toEqual(1)
- getElements().forEach(el => {
+ for (const el of getElements()) {
expect(el.classList.contains(CLASS_NAME_SHOW)).toEqual(true)
- })
+ }
+
done()
})
})
@@ -67,9 +68,10 @@ describe('Backdrop', () => {
instance.show(() => {
expect(getElements().length).toEqual(1)
- getElements().forEach(el => {
+ for (const el of getElements()) {
expect(el.classList.contains(CLASS_NAME_FADE)).toEqual(true)
- })
+ }
+
done()
})
})