aboutsummaryrefslogtreecommitdiffstats
path: root/test/widgetsSpec.js
diff options
context:
space:
mode:
authorIgor Minar2010-12-04 23:49:26 -0800
committerIgor Minar2010-12-06 16:45:59 -0800
commit011fa39c2a0b5da843395b538fc4e52e5ade8287 (patch)
treeb5cc7ee72fb2fbcc76da2588822a21c2cedb614c /test/widgetsSpec.js
parent58d0e8945d772eddbfecbe6a645b2f1c4dd38bf2 (diff)
downloadangular.js-011fa39c2a0b5da843395b538fc4e52e5ade8287.tar.bz2
add $browser.defer and $defer service and fix async xhr cache issue
- Closes #152 ($resource().query() sometimes calls callback before returning, and it shouldn't) - add $browser.defer method - add $defer service - integrate $browser.defer with outstandingRequests counter in $browser - fix all old tests that relied on buggy behavior
Diffstat (limited to 'test/widgetsSpec.js')
-rw-r--r--test/widgetsSpec.js11
1 files changed, 8 insertions, 3 deletions
diff --git a/test/widgetsSpec.js b/test/widgetsSpec.js
index cb3b76a1..ceec2c90 100644
--- a/test/widgetsSpec.js
+++ b/test/widgetsSpec.js
@@ -530,6 +530,7 @@ describe("widget", function(){
scope.url = 'myUrl';
scope.$inject('$xhr.cache').data.myUrl = {value:'{{name}}'};
scope.$init();
+ scope.$inject('$browser').defer.flush();
expect(element.text()).toEqual('misko');
dealoc(scope);
});
@@ -542,6 +543,7 @@ describe("widget", function(){
scope.url = 'myUrl';
scope.$inject('$xhr.cache').data.myUrl = {value:'{{name}}'};
scope.$init();
+ scope.$inject('$browser').defer.flush();
expect(element.text()).toEqual('igor');
@@ -558,9 +560,11 @@ describe("widget", function(){
scope.url = 'myUrl';
scope.$inject('$xhr.cache').data.myUrl = {value:'{{c=c+1}}'};
scope.$init();
- // This should not be 4, but to fix this properly
- // we need to have real events on the scopes.
- expect(element.text()).toEqual('4');
+ scope.$inject('$browser').defer.flush();
+
+ // this one should really be just '1', but due to lack of real events things are not working
+ // properly. see discussion at: http://is.gd/ighKk
+ expect(element.text()).toEqual('2');
dealoc(scope);
});
@@ -573,6 +577,7 @@ describe("widget", function(){
scope.url = 'myUrl';
scope.$inject('$xhr.cache').data.myUrl = {value:'my partial'};
scope.$init();
+ scope.$inject('$browser').defer.flush();
expect(element.text()).toEqual('my partial');
expect(scope.loaded).toBe(true);
dealoc(scope);