This repository was archived by the owner on Feb 24, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +60
-14
lines changed Expand file tree Collapse file tree 5 files changed +60
-14
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,10 @@ const mixin = {
48
48
* Prepare slides active/current classes
49
49
*/
50
50
prepareSlidesClasses ( ) {
51
+ if ( this . currentSlide === null ) {
52
+ return false
53
+ }
54
+
51
55
// Remove active & current classes
52
56
for ( let i = 0 ; i < this . slidesCount ; i ++ ) {
53
57
this . slides [ i ] . classList . remove ( 'agile__slide--active' )
@@ -84,7 +88,7 @@ const mixin = {
84
88
if ( this . settings . unagile ) {
85
89
this . translateX = 0
86
90
} else {
87
- if ( this . currentSlide === null ) {
91
+ if ( this . currentSlide === null && this . slidesCount ) {
88
92
this . currentSlide = this . settings . initialSlide
89
93
}
90
94
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ const testsContext = require . context ( './specs' , true , / \. s p e c $ / )
2
+ testsContext . keys ( ) . forEach ( testsContext )
Original file line number Diff line number Diff line change
1
+ import { expect } from 'chai'
2
+ import { shallowMount } from '@vue/test-utils'
3
+ import Agile from '@/Agile.vue'
4
+
5
+ const slides = '<div>1</div><div>2</div><div>3</div><div>4</div><div>5</div><div>6</div>'
6
+
7
+ describe ( 'Events emitting:' , ( ) => {
8
+ describe ( '@afterChange' , ( ) => {
9
+ it ( 'should be called after a current slide changes' , async ( ) => {
10
+ const wrapper = shallowMount ( Agile , {
11
+ slots : {
12
+ default : slides
13
+ }
14
+ } )
15
+
16
+ const nextButton = wrapper . find ( { ref : 'nextButton' } )
17
+ await nextButton . trigger ( 'click' )
18
+
19
+ expect ( wrapper . emitted ( ) . afterChange ) . to . deep . equal ( [ [ { currentSlide : 1 } ] ] )
20
+ } )
21
+ } )
22
+
23
+ describe ( '@beforeChange' , ( ) => {
24
+ it ( 'should be called before a current slide changes' , ( ) => {
25
+ const wrapper = shallowMount ( Agile , {
26
+ slots : {
27
+ default : slides
28
+ }
29
+ } )
30
+
31
+ const nextButton = wrapper . find ( { ref : 'nextButton' } )
32
+ nextButton . trigger ( 'click' )
33
+
34
+ expect ( wrapper . emitted ( ) . beforeChange ) . to . deep . equal ( [ [ { currentSlide : 0 , nextSlide : 1 } ] ] )
35
+ } )
36
+ } )
37
+ } )
Original file line number Diff line number Diff line change
1
+ import { expect } from 'chai'
2
+ import { shallowMount } from '@vue/test-utils'
3
+ import Agile from '@/Agile.vue'
4
+
5
+ describe ( 'Renders:' , ( ) => {
6
+ it ( 'should render nav buttons' , ( ) => {
7
+ const wrapper = shallowMount ( Agile , {
8
+ slots : {
9
+ prevButton : 'prev' ,
10
+ nextButton : 'next'
11
+ }
12
+ } )
13
+ expect ( wrapper . text ( ) ) . to . include ( 'prev' )
14
+ expect ( wrapper . text ( ) ) . to . include ( 'next' )
15
+ } )
16
+ } )
You can’t perform that action at this time.
0 commit comments