aboutsummaryrefslogtreecommitdiffstats
path: root/test/widgetsSpec.js
diff options
context:
space:
mode:
authorIgor Minar2011-12-28 09:26:22 -0800
committerVojta Jina2012-01-09 13:17:48 -0800
commita13b5ed3bc337a493029815c595b89c39eb95af6 (patch)
tree2ca5380d5cf5aea68218280cccda5d0221517454 /test/widgetsSpec.js
parent63cca9afbcf7a772086eb4582d2f409c39e0ed12 (diff)
downloadangular.js-a13b5ed3bc337a493029815c595b89c39eb95af6.tar.bz2
fix($http): fix and cleanup $http and friends
$http: - use promises internally - get rid of XhrFuture that was previously used internally - get rid of $browser.defer calls for async stuff (serving from cache), promises will take care of asynchronicity - fix transformation bugs (when caching requested + multiple request pending + error is returned) - get rid of native header parsing and instead just lazily parse the header string $httpBackend: - don't return raw/mock XMLHttpRequest object (we don't use it for anything anymore) - call the callback with response headers string mock $httpBackend: - unify response api for expect and when - call the callback with response headers string - changed the expect/when failure error message so that EXPECTED and GOT values are aligned Conflicts: src/service/http.js test/service/compilerSpec.js test/service/httpSpec.js
Diffstat (limited to 'test/widgetsSpec.js')
-rw-r--r--test/widgetsSpec.js9
1 files changed, 0 insertions, 9 deletions
diff --git a/test/widgetsSpec.js b/test/widgetsSpec.js
index e8ff4b27..09d807b5 100644
--- a/test/widgetsSpec.js
+++ b/test/widgetsSpec.js
@@ -72,7 +72,6 @@ describe('widget', function() {
$rootScope.childScope.name = 'misko';
$rootScope.url = 'myUrl';
$rootScope.$digest();
- $browser.defer.flush();
expect(element.text()).toEqual('misko');
}));
@@ -86,7 +85,6 @@ describe('widget', function() {
$rootScope.childScope.name = 'igor';
$rootScope.url = 'myUrl';
$rootScope.$digest();
- $browser.defer.flush();
expect(element.text()).toEqual('igor');
@@ -103,7 +101,6 @@ describe('widget', function() {
element = $compile(element)($rootScope);
$rootScope.url = 'myUrl';
$rootScope.$digest();
- $browser.defer.flush();
// TODO(misko): because we are using scope==this, the eval gets registered
// during the flush phase and hence does not get called.
@@ -125,7 +122,6 @@ describe('widget', function() {
$rootScope.url = 'myUrl';
$rootScope.$digest();
- $browser.defer.flush();
expect(element.text()).toEqual('my partial');
expect($rootScope.loaded).toBe(true);
@@ -141,7 +137,6 @@ describe('widget', function() {
$rootScope.url = 'myUrl';
$rootScope.$digest();
- $browser.defer.flush();
expect($rootScope.$$childHead).toBeTruthy();
$rootScope.url = null;
@@ -166,7 +161,6 @@ describe('widget', function() {
$rootScope.url = 'myUrl';
$rootScope.$digest();
- $browser.defer.flush();
expect(element.text()).toEqual('my partial');
dealoc($rootScope);
}));
@@ -199,7 +193,6 @@ describe('widget', function() {
});
$rootScope.$digest();
- $browser.defer.flush();
expect(element.text()).toBe('my partial');
}));
@@ -746,7 +739,6 @@ describe('widget', function() {
$rootScope.log = [];
$location.path('/foo');
$rootScope.$apply();
- $browser.defer.flush();
expect($rootScope.log).toEqual(['parent', 'init', 'child']);
}));
@@ -801,7 +793,6 @@ describe('widget', function() {
});
$rootScope.$digest();
- $browser.defer.flush();
expect(element.text()).toBe('my partial');
}));
});
n> it("should copy object", function(){ var src = {a:{name:"value"}}; var dst = {b:{key:"v"}}; assertSame(dst, copy(src, dst)); assertEquals({a:{name:"value"}}, dst); assertEquals(src.a, dst.a); assertNotSame(src.a, dst.a); }); it("should copy primitives", function(){ expect(copy(null)).toEqual(null); expect(copy('')).toEqual(''); expect(copy(123)).toEqual(123); expect(copy([{key:null}])).toEqual([{key:null}]); }); }); describe('equals', function(){ it('should return true if same object', function(){ var o = {}; expect(equals(o, o)).toEqual(true); expect(equals(1, '1')).toEqual(true); expect(equals(1, '2')).toEqual(false); }); it('should recurse into object', function(){ expect(equals({}, {})).toEqual(true); expect(equals({name:'misko'}, {name:'misko'})).toEqual(true); expect(equals({name:'misko', age:1}, {name:'misko'})).toEqual(false); expect(equals({name:'misko'}, {name:'misko', age:1})).toEqual(false); expect(equals({name:'misko'}, {name:'adam'})).toEqual(false); expect(equals(['misko'], ['misko'])).toEqual(true); expect(equals(['misko'], ['adam'])).toEqual(false); expect(equals(['misko'], ['misko', 'adam'])).toEqual(false); }); it('should ignore $ member variables', function(){ expect(equals({name:'misko', $id:1}, {name:'misko', $id:2})).toEqual(true); expect(equals({name:'misko'}, {name:'misko', $id:2})).toEqual(true); expect(equals({name:'misko', $id:1}, {name:'misko'})).toEqual(true); }); }); describe('parseKeyValue', function() { it('should parse a string into key-value pairs', function() { expect(parseKeyValue('')).toEqual({}); expect(parseKeyValue('simple=pair')).toEqual({simple: 'pair'}); expect(parseKeyValue('first=1&second=2')).toEqual({first: '1', second: '2'}); expect(parseKeyValue('escaped%20key=escaped%20value')). toEqual({'escaped key': 'escaped value'}); expect(parseKeyValue('emptyKey=')).toEqual({emptyKey: ''}); expect(parseKeyValue('flag1&key=value&flag2')). toEqual({flag1: true, key: 'value', flag2: true}); }); });