aboutsummaryrefslogtreecommitdiffstats
path: root/test/widgetsSpec.js
diff options
context:
space:
mode:
authorIgor Minar2011-04-11 08:04:16 -0700
committerIgor Minar2011-04-11 08:04:16 -0700
commit3d388498e5c8920ca3c88d3ee1eccefcfcf99626 (patch)
tree6a976ff20a6b5d45ccd6749b02fdac3077497b1b /test/widgetsSpec.js
parent3d787ab6f4fecf9168159e460fcd148120aa4c43 (diff)
downloadangular.js-3d388498e5c8920ca3c88d3ee1eccefcfcf99626.tar.bz2
add test for ng:view sync cache regression
test for 9bd2c396
Diffstat (limited to 'test/widgetsSpec.js')
-rw-r--r--test/widgetsSpec.js39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/widgetsSpec.js b/test/widgetsSpec.js
index 8d3e0456..3cada77b 100644
--- a/test/widgetsSpec.js
+++ b/test/widgetsSpec.js
@@ -885,6 +885,45 @@ describe("widget", function(){
expect($route.current.template).toEqual('viewPartial.html');
dealoc($route.current.scope);
});
+
+
+ it('should initialize view template after the view controller was initialized even when ' +
+ 'templates were cached', function() {
+ //this is a test for a regression that was introduced by making the ng:view cache sync
+
+ $route.when('/foo', {controller: ParentCtrl, template: 'viewPartial.html'});
+
+ rootScope.log = [];
+
+ function ParentCtrl() {
+ this.log.push('parent');
+ }
+
+ rootScope.ChildCtrl = function() {
+ this.log.push('child');
+ }
+
+ $location.updateHash('/foo');
+ $browser.xhr.expectGET('viewPartial.html').
+ respond('<div ng:init="log.push(\'init\')">' +
+ '<div ng:controller="ChildCtrl"></div>' +
+ '</div>');
+ rootScope.$eval();
+ $browser.xhr.flush();
+
+ expect(rootScope.log).toEqual(['parent', 'init', 'child']);
+
+ $location.updateHash('');
+ rootScope.$eval();
+ expect(rootScope.log).toEqual(['parent', 'init', 'child']);
+
+ rootScope.log = [];
+ $location.updateHash('/foo');
+ rootScope.$eval();
+ $browser.defer.flush();
+
+ expect(rootScope.log).toEqual(['parent', 'init', 'child']);
+ });
});
});