@@ -130,6 +130,24 @@ describe("animations", function() {
130
130
} ;
131
131
} ) ) ;
132
132
133
+ it ( "should not alter the provided options input in any way throughout the animation" , inject ( function ( $animate , $rootElement , $rootScope ) {
134
+ var initialOptions = {
135
+ from : { height : '50px' } ,
136
+ to : { width : '50px' } ,
137
+ addClass : 'one' ,
138
+ removeClass : 'two'
139
+ } ;
140
+
141
+ var copiedOptions = copy ( initialOptions ) ;
142
+ expect ( copiedOptions ) . toEqual ( initialOptions ) ;
143
+
144
+ var runner = $animate . enter ( element , parent , null , copiedOptions ) ;
145
+ expect ( copiedOptions ) . toEqual ( initialOptions ) ;
146
+
147
+ $rootScope . $digest ( ) ;
148
+ expect ( copiedOptions ) . toEqual ( initialOptions ) ;
149
+ } ) ) ;
150
+
133
151
it ( 'should animate only the specified CSS className matched within $animateProvider.classNameFilter' , function ( ) {
134
152
module ( function ( $animateProvider ) {
135
153
$animateProvider . classNameFilter ( / o n l y - a l l o w - t h i s - a n i m a t i o n / ) ;
@@ -149,32 +167,40 @@ describe("animations", function() {
149
167
} ) ;
150
168
} ) ;
151
169
152
- they ( 'should nullify both options.$prop when passed into an animation if it is not a string or an array' , [ 'addClass' , 'removeClass' ] , function ( prop ) {
170
+ they ( 'should not apply the provided options.$prop value unless it\'s a string or string-based array' , [ 'addClass' , 'removeClass' ] , function ( prop ) {
153
171
inject ( function ( $animate , $rootScope ) {
172
+ var startingCssClasses = element . attr ( 'class' ) || '' ;
173
+
154
174
var options1 = { } ;
155
175
options1 [ prop ] = function ( ) { } ;
156
176
$animate . enter ( element , parent , null , options1 ) ;
157
177
158
- expect ( options1 [ prop ] ) . toBeFalsy ( ) ;
178
+ expect ( element . attr ( 'class' ) ) . toEqual ( startingCssClasses ) ;
179
+
159
180
$rootScope . $digest ( ) ;
160
181
161
182
var options2 = { } ;
162
183
options2 [ prop ] = true ;
163
184
$animate . leave ( element , options2 ) ;
164
185
165
- expect ( options2 [ prop ] ) . toBeFalsy ( ) ;
186
+ expect ( element . attr ( 'class' ) ) . toEqual ( startingCssClasses ) ;
187
+
166
188
$rootScope . $digest ( ) ;
167
189
168
190
capturedAnimation = null ;
169
191
170
192
var options3 = { } ;
171
193
if ( prop === 'removeClass' ) {
172
194
element . addClass ( 'fatias' ) ;
195
+ startingCssClasses = element . attr ( 'class' ) ;
173
196
}
174
197
175
198
options3 [ prop ] = [ 'fatias' ] ;
176
199
$animate . enter ( element , parent , null , options3 ) ;
177
- expect ( options3 [ prop ] ) . toBe ( 'fatias' ) ;
200
+
201
+ $rootScope . $digest ( ) ;
202
+
203
+ expect ( element . attr ( 'class' ) ) . not . toEqual ( startingCssClasses ) ;
178
204
} ) ;
179
205
} ) ;
180
206
0 commit comments