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