aboutsummaryrefslogtreecommitdiffstats
path: root/test/BrowserSpecs.js
diff options
context:
space:
mode:
authorIgor Minar2010-09-25 15:29:48 -0700
committerIgor Minar2010-09-26 23:54:31 -0700
commit3eec8c1a517f8b93a5afd15b7f83b33c5df7e54b (patch)
tree9d9574d2245257456966bb0d15853f8f0d620958 /test/BrowserSpecs.js
parent9171a2b2b50d0a8217c98e0017a7d2a0a1a37380 (diff)
downloadangular.js-3eec8c1a517f8b93a5afd15b7f83b33c5df7e54b.tar.bz2
Properly initialize cookie service in order to preserve existing cookies
- previously the poller initialized the cookie cache too late which was causing previously existing cookies to be deleted by cookie service - refactored the poller api so that the addPollFn returns the added fn - fixed older cookie service tests - removed "this.$onEval(PRIORITY_LAST, update);" because it is not needed
Diffstat (limited to 'test/BrowserSpecs.js')
-rw-r--r--test/BrowserSpecs.js28
1 files changed, 17 insertions, 11 deletions
diff --git a/test/BrowserSpecs.js b/test/BrowserSpecs.js
index 148fbca4..1a4e8585 100644
--- a/test/BrowserSpecs.js
+++ b/test/BrowserSpecs.js
@@ -76,11 +76,11 @@ describe('browser', function(){
beforeEach(function() {
deleteAllCookies();
- logs = {log:[], warn:[], info:[], error:[]}
- log = {log: function() {logs.log.push(Array.prototype.slice.call(arguments))},
- warn: function() {logs.warn.push(Array.prototype.slice.call(arguments))},
- info: function() {logs.info.push(Array.prototype.slice.call(arguments))},
- error: function() {logs.error.push(Array.prototype.slice.call(arguments))}};
+ logs = {log:[], warn:[], info:[], error:[]};
+ log = {log: function() { logs.log.push(slice.call(arguments)); },
+ warn: function() { logs.warn.push(slice.call(arguments)); },
+ info: function() { logs.info.push(slice.call(arguments)); },
+ error: function() { logs.error.push(slice.call(arguments)); }};
browser = new Browser({}, jqLite(document), undefined, XHR, log);
expect(document.cookie).toEqual('');
});
@@ -102,7 +102,7 @@ describe('browser', function(){
});
- describe('remove via (cookieName, undefined)', function() {
+ describe('remove via cookies(cookieName, undefined)', function() {
it('should remove a cookie when it is present', function() {
document.cookie = 'foo=bar';
@@ -122,7 +122,7 @@ describe('browser', function(){
});
- describe('put via (cookieName, string)', function() {
+ describe('put via cookies(cookieName, string)', function() {
it('should create and store a cookie', function() {
browser.cookies('cookieName', 'cookieValue');
@@ -194,10 +194,10 @@ describe('browser', function(){
});
- describe('get via (cookieName)', function() {
+ describe('get via cookies()[cookieName]', function() {
it('should return undefined for nonexistent cookie', function() {
- expect(browser.cookies('nonexistent')).not.toBeDefined();
+ expect(browser.cookies().nonexistent).not.toBeDefined();
});
@@ -221,7 +221,7 @@ describe('browser', function(){
});
- describe('getAll', function() {
+ describe('getAll via cookies()', function() {
it('should return cookies as hash', function() {
document.cookie = "foo1=bar1";
@@ -252,7 +252,7 @@ describe('browser', function(){
});
- describe('poll', function(){
+ describe('poller', function(){
it('should call all fns on poll', function(){
var log = '';
browser.addPollFn(function(){log+='a';});
@@ -274,5 +274,11 @@ describe('browser', function(){
setTimeoutSpy.mostRecentCall.args[0]();
expect(log).toEqual('..');
});
+
+ it('should return fn that was passed into addPollFn', function() {
+ var fn = function() { return 1; };
+ var returnedFn = browser.addPollFn(fn);
+ expect(returnedFn).toBe(fn);
+ });
});
});