From 011fa39c2a0b5da843395b538fc4e52e5ade8287 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Sat, 4 Dec 2010 23:49:26 -0800 Subject: 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 --- test/widgetsSpec.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'test/widgetsSpec.js') 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); -- cgit v1.2.3