aboutsummaryrefslogtreecommitdiff
path: root/js/tests
diff options
context:
space:
mode:
authorGeoSot <[email protected]>2022-03-02 02:07:36 +0200
committerXhmikosR <[email protected]>2022-03-09 17:25:47 +0200
commit699402bee5d02659acaab69208549f26f9b3313d (patch)
treef1ad7902952d64f93504b8734c40d82e937f1c5d /js/tests
parentfcc2c809767525a32357fc4877a6dbbac6ba1370 (diff)
downloadbootstrap-699402bee5d02659acaab69208549f26f9b3313d.tar.xz
bootstrap-699402bee5d02659acaab69208549f26f9b3313d.zip
Carousel: refactor `_slide` method te accept only order as first argument
Diffstat (limited to 'js/tests')
-rw-r--r--js/tests/unit/carousel.spec.js35
1 files changed, 15 insertions, 20 deletions
diff --git a/js/tests/unit/carousel.spec.js b/js/tests/unit/carousel.spec.js
index 4070f0f9d..d6320debf 100644
--- a/js/tests/unit/carousel.spec.js
+++ b/js/tests/unit/carousel.spec.js
@@ -378,7 +378,7 @@ describe('Carousel', () => {
carouselEl.addEventListener('slid.bs.carousel', event => {
expect(item).toHaveClass('active')
- expect(carousel._slide).toHaveBeenCalledWith('right')
+ expect(carousel._slide).toHaveBeenCalledWith('prev')
expect(event.direction).toEqual('right')
stylesCarousel.remove()
delete document.documentElement.ontouchstart
@@ -425,7 +425,7 @@ describe('Carousel', () => {
carouselEl.addEventListener('slid.bs.carousel', event => {
expect(item).not.toHaveClass('active')
- expect(carousel._slide).toHaveBeenCalledWith('left')
+ expect(carousel._slide).toHaveBeenCalledWith('next')
expect(event.direction).toEqual('left')
stylesCarousel.remove()
delete document.documentElement.ontouchstart
@@ -467,7 +467,7 @@ describe('Carousel', () => {
carouselEl.addEventListener('slid.bs.carousel', event => {
expect(item).toHaveClass('active')
- expect(carousel._slide).toHaveBeenCalledWith('right')
+ expect(carousel._slide).toHaveBeenCalledWith('prev')
expect(event.direction).toEqual('right')
delete document.documentElement.ontouchstart
restorePointerEvents()
@@ -508,7 +508,7 @@ describe('Carousel', () => {
carouselEl.addEventListener('slid.bs.carousel', event => {
expect(item).not.toHaveClass('active')
- expect(carousel._slide).toHaveBeenCalledWith('left')
+ expect(carousel._slide).toHaveBeenCalledWith('next')
expect(event.direction).toEqual('left')
delete document.documentElement.ontouchstart
restorePointerEvents()
@@ -1231,16 +1231,14 @@ describe('Carousel', () => {
const carouselEl = fixtureEl.querySelector('div')
const carousel = new Carousel(carouselEl, {})
- const spy = spyOn(carousel, '_directionToOrder').and.callThrough()
- const spy2 = spyOn(carousel, '_orderToDirection').and.callThrough()
- carousel._slide('left')
- expect(spy).toHaveBeenCalledWith('left')
- expect(spy2).toHaveBeenCalledWith('next')
+ const spy = spyOn(carousel, '_orderToDirection').and.callThrough()
- carousel._slide('right')
- expect(spy).toHaveBeenCalledWith('right')
- expect(spy2).toHaveBeenCalledWith('prev')
+ carousel._slide(carousel._directionToOrder('left'))
+ expect(spy).toHaveBeenCalledWith('next')
+
+ carousel._slide(carousel._directionToOrder('right'))
+ expect(spy).toHaveBeenCalledWith('prev')
})
it('"_slide" has to call "_directionToOrder" and "_orderToDirection" when rtl=true', () => {
@@ -1249,16 +1247,13 @@ describe('Carousel', () => {
const carouselEl = fixtureEl.querySelector('div')
const carousel = new Carousel(carouselEl, {})
- const spy = spyOn(carousel, '_directionToOrder').and.callThrough()
- const spy2 = spyOn(carousel, '_orderToDirection').and.callThrough()
+ const spy = spyOn(carousel, '_orderToDirection').and.callThrough()
- carousel._slide('left')
- expect(spy).toHaveBeenCalledWith('left')
- expect(spy2).toHaveBeenCalledWith('prev')
+ carousel._slide(carousel._directionToOrder('left'))
+ expect(spy).toHaveBeenCalledWith('prev')
- carousel._slide('right')
- expect(spy).toHaveBeenCalledWith('right')
- expect(spy2).toHaveBeenCalledWith('next')
+ carousel._slide(carousel._directionToOrder('right'))
+ expect(spy).toHaveBeenCalledWith('next')
document.documentElement.dir = 'ltl'
})