@@ -132,6 +132,53 @@ describe('ngAnimateSwap', function() {
132
132
expect ( two ) . toBeTruthy ( ) ;
133
133
} ) ) ;
134
134
135
+ it ( 'should create a new (non-isolate) scope for each inserted clone' , inject ( function ( ) {
136
+ var parentScope = $rootScope . $new ( ) ;
137
+ parentScope . foo = 'bar' ;
138
+
139
+ element = $compile ( '<div><div ng-animate-swap="value">{{ value }}</div></div>' ) ( parentScope ) ;
140
+
141
+ $rootScope . $apply ( 'value = 1' ) ;
142
+ var scopeOne = element . find ( 'div' ) . eq ( 0 ) . scope ( ) ;
143
+ expect ( scopeOne . foo ) . toBe ( 'bar' ) ;
144
+
145
+ $rootScope . $apply ( 'value = 2' ) ;
146
+ var scopeTwo = element . find ( 'div' ) . eq ( 0 ) . scope ( ) ;
147
+ expect ( scopeTwo . foo ) . toBe ( 'bar' ) ;
148
+
149
+ expect ( scopeOne ) . not . toBe ( scopeTwo ) ;
150
+ } ) ) ;
151
+
152
+ it ( 'should destroy the previous scope when removing the element' , inject ( function ( ) {
153
+ element = $compile ( '<div><div ng-animate-swap="value">{{ value }}</div></div>' ) ( $rootScope ) ;
154
+
155
+ $rootScope . $apply ( 'value = 1' ) ;
156
+ var scopeOne = element . find ( 'div' ) . eq ( 0 ) . scope ( ) ;
157
+ expect ( scopeOne . $$destroyed ) . toBe ( false ) ;
158
+
159
+ // Swapping the old element with a new one.
160
+ $rootScope . $apply ( 'value = 2' ) ;
161
+ expect ( scopeOne . $$destroyed ) . toBe ( true ) ;
162
+
163
+ var scopeTwo = element . find ( 'div' ) . eq ( 0 ) . scope ( ) ;
164
+ expect ( scopeTwo . $$destroyed ) . toBe ( false ) ;
165
+
166
+ // Removing the old element (without inserting a new one).
167
+ $rootScope . $apply ( 'value = null' ) ;
168
+ expect ( scopeTwo . $$destroyed ) . toBe ( true ) ;
169
+ } ) ) ;
170
+
171
+ it ( 'should destroy the previous scope when swapping elements' , inject ( function ( ) {
172
+ element = $compile ( '<div><div ng-animate-swap="value">{{ value }}</div></div>' ) ( $rootScope ) ;
173
+
174
+ $rootScope . $apply ( 'value = 1' ) ;
175
+ var scopeOne = element . find ( 'div' ) . eq ( 0 ) . scope ( ) ;
176
+ expect ( scopeOne . $$destroyed ) . toBe ( false ) ;
177
+
178
+ $rootScope . $apply ( 'value = 2' ) ;
179
+ expect ( scopeOne . $$destroyed ) . toBe ( true ) ;
180
+ } ) ) ;
181
+
135
182
136
183
describe ( 'animations' , function ( ) {
137
184
it ( 'should trigger a leave animation followed by an enter animation upon swap' ,
0 commit comments