aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMisko Hevery2013-05-01 20:01:27 -0400
committerMisko Hevery2013-05-02 15:22:16 -0400
commit9956baedd73d5e8d0edd04c9eed368bd3988444b (patch)
tree5c37c2b81fea497aff4075db27f4a3cd3345fbc1 /test
parent1d8e11ddfbd6b08ff02df4331f6df125f49da3dc (diff)
downloadangular.js-9956baedd73d5e8d0edd04c9eed368bd3988444b.tar.bz2
fix(ngView): accidentally compiling leaving content
closes: #2304
Diffstat (limited to 'test')
-rw-r--r--test/ng/directive/ngViewSpec.js46
1 files changed, 44 insertions, 2 deletions
diff --git a/test/ng/directive/ngViewSpec.js b/test/ng/directive/ngViewSpec.js
index 579fd0a8..c31c2449 100644
--- a/test/ng/directive/ngViewSpec.js
+++ b/test/ng/directive/ngViewSpec.js
@@ -3,7 +3,8 @@
describe('ngView', function() {
var element;
- beforeEach(module(function() {
+ beforeEach(module(function($provide) {
+ $provide.value('$window', angular.mock.createMockWindow());
return function($rootScope, $compile, $animator) {
element = $compile('<ng:view onload="load()"></ng:view>')($rootScope);
$animator.enabled(true);
@@ -621,5 +622,46 @@ describe('ngView', function() {
}
}));
+
+ it('should not double compile when route changes', function() {
+ module(function($routeProvider, $animationProvider, $provide) {
+ $routeProvider.when('/foo', {template: '<div ng-repeat="i in [1,2]">{{i}}</div>'});
+ $routeProvider.when('/bar', {template: '<div ng-repeat="i in [3,4]">{{i}}</div>'});
+ $animationProvider.register('my-animation-leave', function() {
+ return {
+ start: function(element, done) {
+ done();
+ }
+ };
+ });
+ });
+
+ inject(function($rootScope, $compile, $location, $route, $window, $rootElement, $sniffer) {
+ element = $compile(html('<ng:view onload="load()" ng-animate="\'my-animation\'"></ng:view>'))($rootScope);
+
+ $location.path('/foo');
+ $rootScope.$digest();
+ if ($sniffer.supportsTransitions) {
+ $window.setTimeout.expect(1).process();
+ $window.setTimeout.expect(0).process();
+ }
+ expect(element.text()).toEqual('12');
+
+ $location.path('/bar');
+ $rootScope.$digest();
+ expect(n(element.text())).toEqual('1234');
+ if ($sniffer.supportsTransitions) {
+ $window.setTimeout.expect(1).process();
+ $window.setTimeout.expect(1).process();
+ } else {
+ $window.setTimeout.expect(1).process();
+ }
+ expect(element.text()).toEqual('34');
+
+ function n(text) {
+ return text.replace(/\r\n/m, '').replace(/\r\n/m, '');
+ }
+ });
+ });
});
-}); \ No newline at end of file
+});