Skip to content

Commit

Permalink
add _orderToDirection tests
Browse files Browse the repository at this point in the history
  • Loading branch information
GeoSot committed Mar 16, 2021
1 parent ee52f92 commit 76d2222
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions js/tests/unit/carousel.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1073,6 +1073,9 @@ describe('Carousel', () => {
expect(carousel._directionToOrder('prev')).toEqual('prev')
expect(carousel._directionToOrder('right')).toEqual('next')
expect(carousel._directionToOrder('next')).toEqual('next')

expect(carousel._orderToDirection('next')).toEqual('right')
expect(carousel._orderToDirection('prev')).toEqual('left')
})

it('rtl left has to return "next" order', () => {
Expand All @@ -1087,6 +1090,9 @@ describe('Carousel', () => {
expect(carousel._directionToOrder('prev')).toEqual('prev')
expect(carousel._directionToOrder('right')).toEqual('prev')
expect(carousel._directionToOrder('next')).toEqual('next')

expect(carousel._orderToDirection('next')).toEqual('left')
expect(carousel._orderToDirection('prev')).toEqual('right')
document.documentElement.dir = 'ltl'
})

Expand All @@ -1096,12 +1102,15 @@ 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('prev')

carousel._slide('right')
expect(spy).toHaveBeenCalledWith('right')
expect(spy2).toHaveBeenCalledWith('next')
})
})

Expand Down

0 comments on commit 76d2222

Please sign in to comment.