aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMisko Hevery2010-07-13 15:53:13 -0700
committerMisko Hevery2010-07-13 15:53:13 -0700
commit32361d03a147213747762e17d279639666ed85fb (patch)
tree53a8364a6779a89d50d1e09e588d5ac3cac1f3d1 /test
parentf084fd37dbc80d9701f417a726b4ac3232039d93 (diff)
parentac3c2736c786abe996acc3d01d857dd5f0b3328a (diff)
downloadangular.js-32361d03a147213747762e17d279639666ed85fb.tar.bz2
Changed cacheThanRetrieve to verifyCache(by Rob Spies)
Diffstat (limited to 'test')
-rw-r--r--test/ResourceSpec.js20
1 files changed, 17 insertions, 3 deletions
diff --git a/test/ResourceSpec.js b/test/ResourceSpec.js
index 2f285bcf..4882e70e 100644
--- a/test/ResourceSpec.js
+++ b/test/ResourceSpec.js
@@ -34,7 +34,6 @@ describe("resource", function() {
var item = LineItem.get({id:456});
xhr.flush();
nakedExpect(item).toEqual({id:'abc'});
-
});
it("should create resource", function(){
@@ -66,8 +65,6 @@ describe("resource", function() {
nakedExpect(cc).toEqual({id:{key:123}, name:'misko'});
expect(callback).wasNotCalled();
xhr.flush();
- nakedExpect(cc).toEqual({id:{key:123}, name:'rama'});
- expect(callback).wasCalledWith(cc);
});
it("should query resource", function(){
@@ -138,6 +135,23 @@ describe("resource", function() {
expect(person.name).toEqual('misko');
});
+ it('should return the same object when verifying the cache', function(){
+ var scope = angular.compile('<div></div>');
+ var Person = scope.$resource('/Person/:id', null, {query: {method:'GET', isArray: true, verifyCache: true}});
+ scope.$browser.xhr.expectGET('/Person/123').respond('[\n{\nname:\n"misko"\n}\n]');
+ var person = Person.query({id:123});
+ scope.$browser.xhr.flush();
+ expect(person[0].name).toEqual('misko');
+
+ scope.$browser.xhr.expectGET('/Person/123').respond('[\n{\nname:\n"rob"\n}\n]');
+ var person2 = Person.query({id:123});
+ expect(person2[0].name).toEqual('misko');
+ var person2Cache = person2;
+ scope.$browser.xhr.flush();
+ expect(person2Cache).toEqual(person2);
+ expect(person2[0].name).toEqual('rob');
+ });
+
describe('failure mode', function(){
it('should report error when non 200', function(){
xhr.expectGET('/CreditCard/123').respond(500, "Server Error");