1
1
import { expect } from "chai" ;
2
- import Vue from "vue" ;
3
2
import Circle from "@/components/Circle/Circle.vue" ;
4
3
import HalfCircle from "@/components/Circle/HalfCircle.vue" ;
5
4
import CircleContainer from "@/components/Circle/CircleContainer.vue" ;
6
5
import CircleDot from "@/components/Circle/CircleDot.vue" ;
7
6
import { factory } from "@/../tests/helper" ;
7
+ import { animationParser } from "@/components/optionsParser" ;
8
8
9
9
const localFactory = ( props , container = Circle ) => {
10
10
return factory ( { container, props } ) ;
@@ -32,23 +32,19 @@ const animationTypeTests = (container, circleClass, prefix = "circle |") => {
32
32
} , 250 ) ;
33
33
} ) ;
34
34
it ( `${ prefix } applies @bounce animation class correctly` , async ( ) => {
35
- await wrapper . setProps ( { options : { ...wrapper . props ( ) . options , animation : "bounce 500 500" } } ) ;
36
- await Vue . nextTick ( ) ;
35
+ await wrapper . setProps ( { options : { ...wrapper . props ( ) . options , animation : animationParser ( "bounce 500 500" ) } } ) ;
37
36
expect ( circleProgressWrapper . classes ( ) ) . to . include ( "animation__bounce" ) ;
38
37
} ) ;
39
38
it ( `${ prefix } applies @loop animation class correctly` , async ( ) => {
40
- await wrapper . setProps ( { options : { ...wrapper . props ( ) . options , animation : "loop 500 500" } } ) ;
41
- await Vue . nextTick ( ) ;
39
+ await wrapper . setProps ( { options : { ...wrapper . props ( ) . options , animation : animationParser ( "loop 500 500" ) } } ) ;
42
40
expect ( circleProgressWrapper . classes ( ) ) . to . include ( "animation__loop" ) ;
43
41
} ) ;
44
42
it ( `${ prefix } applies @reverse animation class correctly` , async ( ) => {
45
- await wrapper . setProps ( { options : { ...wrapper . props ( ) . options , animation : "reverse 500 500" } } ) ;
46
- await Vue . nextTick ( ) ;
43
+ await wrapper . setProps ( { options : { ...wrapper . props ( ) . options , animation : animationParser ( "reverse 500 500" ) } } ) ;
47
44
expect ( circleProgressWrapper . classes ( ) ) . to . include ( "animation__reverse" ) ;
48
45
} ) ;
49
46
it ( `${ prefix } applies @rs animation class correctly` , async ( ) => {
50
- await wrapper . setProps ( { options : { ...wrapper . props ( ) . options , animation : "rs 500 500" } } ) ;
51
- await Vue . nextTick ( ) ;
47
+ await wrapper . setProps ( { options : { ...wrapper . props ( ) . options , animation : animationParser ( "rs 500 500" ) } } ) ;
52
48
expect ( circleProgressWrapper . classes ( ) ) . to . include ( "animation__rs" ) ;
53
49
} ) ;
54
50
} ;
@@ -60,13 +56,13 @@ const animationDurationTests = (container, circleClass, prefix = "circle | ") =>
60
56
expect ( circleProgressWrapper . element . style . animationDuration ) . to . equal ( "1000ms" ) ;
61
57
} ) ;
62
58
it ( `${ prefix } applies provided duration value as transition and animation duration` , ( ) => {
63
- const circleProgressWrapper = localFactory ( { animation : "rs 500" } , container ) . find ( circleClass ) ;
59
+ const circleProgressWrapper = localFactory ( { animation : animationParser ( "rs 500" ) } , container ) . find ( circleClass ) ;
64
60
65
61
expect ( circleProgressWrapper . element . style . transition ) . to . include ( "500ms" ) ;
66
62
expect ( circleProgressWrapper . element . style . animationDuration ) . to . equal ( "500ms" ) ;
67
63
} ) ;
68
64
it ( `${ prefix } applies @0 duration value as transition and animation duration` , ( ) => {
69
- const circleProgressWrapper = localFactory ( { animation : "rs 0" } , container ) . find ( circleClass ) ;
65
+ const circleProgressWrapper = localFactory ( { animation : animationParser ( "rs 0" ) } , container ) . find ( circleClass ) ;
70
66
71
67
expect ( circleProgressWrapper . element . style . transition ) . to . include ( "0ms" ) ;
72
68
expect ( circleProgressWrapper . element . style . animationDuration ) . to . equal ( "0ms" ) ;
@@ -77,7 +73,7 @@ const animationDelayTests = (container, circleClass, prefix = "circle | ") => {
77
73
expect ( localFactory ( { } , container ) . vm . parsedAnimation . delay ) . to . equal ( 400 ) ;
78
74
} ) ;
79
75
it ( `${ prefix } applies @0 delay value as animation-delay` , ( ) => {
80
- expect ( localFactory ( { animation : "rs 0 0" } , container ) . vm . parsedAnimation . delay ) . to . equal ( 0 ) ;
76
+ expect ( localFactory ( { animation : animationParser ( "rs 0 0" ) } , container ) . vm . parsedAnimation . delay ) . to . equal ( 0 ) ;
81
77
} ) ;
82
78
83
79
const progress = 60 ;
@@ -93,7 +89,7 @@ const animationDelayTests = (container, circleClass, prefix = "circle | ") => {
93
89
94
90
it ( `${ prefix } don not applies progress before delay` , ( ) => {
95
91
const wrapper = localFactory (
96
- { progress, size, thickness, emptyThickness : thickness , animation : "rs 500 100" } ,
92
+ { progress, size, thickness, emptyThickness : thickness , animation : animationParser ( "rs 500 100" ) } ,
97
93
container
98
94
) ;
99
95
const circleProgressWrapper = wrapper . find ( circleClass ) ;
@@ -102,7 +98,7 @@ const animationDelayTests = (container, circleClass, prefix = "circle | ") => {
102
98
} ) ;
103
99
it ( `${ prefix } applies the progress after delay` , ( done ) => {
104
100
const wrapper = localFactory (
105
- { progress, size, thickness, emptyThickness : thickness , animation : "rs 500 100" } ,
101
+ { progress, size, thickness, emptyThickness : thickness , animation : animationParser ( "rs 500 100" ) } ,
106
102
container
107
103
) ;
108
104
const circleProgressWrapper = wrapper . find ( circleClass ) ;
@@ -115,11 +111,14 @@ const animationDelayTests = (container, circleClass, prefix = "circle | ") => {
115
111
} ;
116
112
117
113
describe ( "#animation" , ( ) => {
118
- const circleContainerWrapper = localFactory ( { progress : 50 , dot : 5 , animation : "rs 500 5" } , CircleContainer ) ;
114
+ const circleContainerWrapper = localFactory (
115
+ { progress : 50 , dot : 5 , animation : animationParser ( "rs 500 5" ) } ,
116
+ CircleContainer
117
+ ) ;
119
118
const circleDotWrapper = circleContainerWrapper . findComponent ( CircleDot ) ;
120
119
121
120
it ( "it parses the #animation property correctly" , ( ) => {
122
- const wrapper = localFactory ( { animation : "rs 2000 200" } ) ;
121
+ const wrapper = localFactory ( { animation : animationParser ( "rs 2000 200" ) } ) ;
123
122
124
123
expect ( wrapper . vm . parsedAnimation . type ) . to . equal ( "rs" ) ;
125
124
expect ( wrapper . vm . parsedAnimation . duration ) . to . equal ( 2000 ) ;
@@ -161,7 +160,7 @@ describe("#animation", () => {
161
160
animationDelayTests ( HalfCircle , "path.ep-half-circle--progress" , "half circle |" ) ;
162
161
163
162
const progress = 50 ;
164
- const wrapper = localFactory ( { dot : 5 , animation : "rs 500 50" } , CircleContainer ) ;
163
+ const wrapper = localFactory ( { dot : 5 , animation : animationParser ( "rs 500 50" ) } , CircleContainer ) ;
165
164
const cdWrapper = wrapper . findComponent ( CircleDot ) ;
166
165
const startRotation = wrapper . props ( "angle" ) + 90 ;
167
166
0 commit comments