diff options
| author | Misko Hevery | 2011-10-07 11:27:49 -0700 | 
|---|---|---|
| committer | Igor Minar | 2011-10-11 11:01:46 -0700 | 
| commit | fd822bdaf9d04e522aaa5400b673f333190abe98 (patch) | |
| tree | 451cd26d3f7da862692d6c56e6e8f235824c180a /test/service | |
| parent | 4f78fd692c0ec51241476e6be9a4df06cd62fdd6 (diff) | |
| download | angular.js-fd822bdaf9d04e522aaa5400b673f333190abe98.tar.bz2 | |
chore(formating): clean code to be function() {
Diffstat (limited to 'test/service')
| -rw-r--r-- | test/service/cookieStoreSpec.js | 2 | ||||
| -rw-r--r-- | test/service/cookiesSpec.js | 6 | ||||
| -rw-r--r-- | test/service/deferSpec.js | 6 | ||||
| -rw-r--r-- | test/service/documentSpec.js | 6 | ||||
| -rw-r--r-- | test/service/exceptionHandlerSpec.js | 6 | ||||
| -rw-r--r-- | test/service/formFactorySpec.js | 43 | ||||
| -rw-r--r-- | test/service/locationSpec.js | 4 | ||||
| -rw-r--r-- | test/service/logSpec.js | 32 | ||||
| -rw-r--r-- | test/service/routeParamsSpec.js | 6 | ||||
| -rw-r--r-- | test/service/windowSpec.js | 6 | ||||
| -rw-r--r-- | test/service/xhr.bulkSpec.js | 12 | ||||
| -rw-r--r-- | test/service/xhr.cacheSpec.js | 12 | ||||
| -rw-r--r-- | test/service/xhr.errorSpec.js | 6 | ||||
| -rw-r--r-- | test/service/xhrSpec.js | 22 | 
14 files changed, 85 insertions, 84 deletions
| diff --git a/test/service/cookieStoreSpec.js b/test/service/cookieStoreSpec.js index fa4f3ceb..0bf7e99d 100644 --- a/test/service/cookieStoreSpec.js +++ b/test/service/cookieStoreSpec.js @@ -9,7 +9,7 @@ describe('$cookieStore', function() {      $browser = scope.$service('$browser');    }); -  afterEach(function(){ +  afterEach(function() {      dealoc(scope);    }); diff --git a/test/service/cookiesSpec.js b/test/service/cookiesSpec.js index 782cee72..f078c20c 100644 --- a/test/service/cookiesSpec.js +++ b/test/service/cookiesSpec.js @@ -10,13 +10,13 @@ describe('$cookies', function() {      scope.$cookies = scope.$service('$cookies');    }); -  afterEach(function(){ +  afterEach(function() {      dealoc(scope);    });    it('should provide access to existing cookies via object properties and keep them in sync', -      function(){ +      function() {      expect(scope.$cookies).toEqual({'preexisting': 'oldCookie'});      // access internal cookie storage of the browser mock directly to simulate behavior of @@ -55,7 +55,7 @@ describe('$cookies', function() {      scope.$cookies.nonString = [1, 2, 3];      scope.$cookies.nullVal = null;      scope.$cookies.undefVal = undefined; -    scope.$cookies.preexisting = function(){}; +    scope.$cookies.preexisting = function() {};      scope.$digest();      expect($browser.cookies()).toEqual({'preexisting': 'oldCookie'});      expect(scope.$cookies).toEqual({'preexisting': 'oldCookie'}); diff --git a/test/service/deferSpec.js b/test/service/deferSpec.js index 4f651522..ad1459ec 100644 --- a/test/service/deferSpec.js +++ b/test/service/deferSpec.js @@ -3,7 +3,7 @@  describe('$defer', function() {    var scope, $browser, $defer, $exceptionHandler; -  beforeEach(function(){ +  beforeEach(function() {      scope = angular.scope(angular.service,                            {'$exceptionHandler': jasmine.createSpy('$exceptionHandler')});      $browser = scope.$service('$browser'); @@ -11,7 +11,7 @@ describe('$defer', function() {      $exceptionHandler = scope.$service('$exceptionHandler');    }); -  afterEach(function(){ +  afterEach(function() {      dealoc(scope);    }); @@ -69,7 +69,7 @@ describe('$defer', function() {      expect(applySpy).toHaveBeenCalled();    }); -  it('should allow you to specify the delay time', function(){ +  it('should allow you to specify the delay time', function() {      var defer = this.spyOn($browser, 'defer');      $defer(noop, 123);      expect(defer.callCount).toEqual(1); diff --git a/test/service/documentSpec.js b/test/service/documentSpec.js index 79c752e4..885331e4 100644 --- a/test/service/documentSpec.js +++ b/test/service/documentSpec.js @@ -3,17 +3,17 @@  describe('$document', function() {    var scope; -  beforeEach(function(){ +  beforeEach(function() {      scope = angular.scope();    }); -  afterEach(function(){ +  afterEach(function() {      dealoc(scope);    }); -  it("should inject $document", function(){ +  it("should inject $document", function() {      expect(scope.$service('$document')).toEqual(jqLite(document));    });  }); diff --git a/test/service/exceptionHandlerSpec.js b/test/service/exceptionHandlerSpec.js index 74f37cb9..61e652b5 100644 --- a/test/service/exceptionHandlerSpec.js +++ b/test/service/exceptionHandlerSpec.js @@ -3,17 +3,17 @@  describe('$exceptionHandler', function() {    var scope; -  beforeEach(function(){ +  beforeEach(function() {      scope = angular.scope();    }); -  afterEach(function(){ +  afterEach(function() {      dealoc(scope);    }); -  it('should log errors', function(){ +  it('should log errors', function() {      var scope = createScope({$exceptionHandler: $exceptionHandlerFactory},                              {$log: $logMock}),          $log = scope.$service('$log'), diff --git a/test/service/formFactorySpec.js b/test/service/formFactorySpec.js index 5223cede..23b8ae0a 100644 --- a/test/service/formFactorySpec.js +++ b/test/service/formFactorySpec.js @@ -1,23 +1,23 @@  'use strict'; -describe('$formFactory', function(){ +describe('$formFactory', function() {    var rootScope;    var formFactory; -  beforeEach(function(){ +  beforeEach(function() {      rootScope = angular.scope();      formFactory = rootScope.$service('$formFactory');    }); -  it('should have global form', function(){ +  it('should have global form', function() {      expect(formFactory.rootForm).toBeTruthy();      expect(formFactory.rootForm.$createWidget).toBeTruthy();    }); -  describe('new form', function(){ +  describe('new form', function() {      var form;      var scope;      var log; @@ -25,7 +25,7 @@ describe('$formFactory', function(){      function WidgetCtrl($formFactory){        this.$formFactory = $formFactory;        log += '<init>'; -      this.$render = function(){ +      this.$render = function() {          log += '$render();';        };        this.$on('$validate', function(e){ @@ -41,13 +41,13 @@ describe('$formFactory', function(){          }      }; -    beforeEach(function(){ +    beforeEach(function() {        log = '';        scope = rootScope.$new();        form = formFactory(scope);      }); -    describe('$createWidget', function(){ +    describe('$createWidget', function() {        var widget;        beforeEach(function() { @@ -55,19 +55,20 @@ describe('$formFactory', function(){            scope:scope,            model:'text',            alias:'text', -          controller:WidgetCtrl}); +          controller:WidgetCtrl +        });        }); -      describe('data flow', function(){ -        it('should have status properties', function(){ +      describe('data flow', function() { +        it('should have status properties', function() {            expect(widget.$error).toEqual({});            expect(widget.$valid).toBe(true);            expect(widget.$invalid).toBe(false);          }); -        it('should update view when model changes', function(){ +        it('should update view when model changes', function() {            scope.text = 'abc';            scope.$digest();            expect(log).toEqual('<init>$validate();$render();'); @@ -80,14 +81,14 @@ describe('$formFactory', function(){          }); -        it('should have controller prototype methods', function(){ +        it('should have controller prototype methods', function() {            expect(widget.getFormFactory()).toEqual(formFactory);          });        }); -      describe('validation', function(){ -        it('should update state on error', function(){ +      describe('validation', function() { +        it('should update state on error', function() {            widget.$emit('$invalid', 'E');            expect(widget.$valid).toEqual(false);            expect(widget.$invalid).toEqual(true); @@ -98,9 +99,9 @@ describe('$formFactory', function(){          }); -        it('should have called the model setter before the validation', function(){ +        it('should have called the model setter before the validation', function() {            var modelValue; -          widget.$on('$validate', function(){ +          widget.$on('$validate', function() {              modelValue = scope.text;            });            widget.$emit('$viewChange', 'abc'); @@ -108,8 +109,8 @@ describe('$formFactory', function(){          }); -        describe('form', function(){ -          it('should invalidate form when widget is invalid', function(){ +        describe('form', function() { +          it('should invalidate form when widget is invalid', function() {              expect(form.$error).toEqual({});              expect(form.$valid).toEqual(true);              expect(form.$invalid).toEqual(false); @@ -147,8 +148,8 @@ describe('$formFactory', function(){        }); -      describe('id assignment', function(){ -        it('should default to name expression', function(){ +      describe('id assignment', function() { +        it('should default to name expression', function() {            expect(form.text).toEqual(widget);          }); @@ -201,7 +202,7 @@ describe('$formFactory', function(){          }); -        it('should remove invalid fields from errors, when child widget removed', function(){ +        it('should remove invalid fields from errors, when child widget removed', function() {            widget.$emit('$invalid', 'MyError');            expect(form.$error.MyError).toEqual([widget]); diff --git a/test/service/locationSpec.js b/test/service/locationSpec.js index a312c1b2..70319af7 100644 --- a/test/service/locationSpec.js +++ b/test/service/locationSpec.js @@ -481,7 +481,7 @@ describe('$location', function() {      }); -    it('should parse file://', function(){ +    it('should parse file://', function() {        var match = URL_MATCH.exec('file:///Users/Shared/misko/work/angular.js/scenario/widgets.html');        expect(match[1]).toBe('file'); @@ -492,7 +492,7 @@ describe('$location', function() {      }); -    it('should parse url with "-" in host', function(){ +    it('should parse url with "-" in host', function() {        var match = URL_MATCH.exec('http://a-b1.c-d.09/path');        expect(match[1]).toBe('http'); diff --git a/test/service/logSpec.js b/test/service/logSpec.js index 499447ad..c4efb8c5 100644 --- a/test/service/logSpec.js +++ b/test/service/logSpec.js @@ -3,22 +3,22 @@  describe('$log', function() {    var scope; -  beforeEach(function(){ +  beforeEach(function() {      scope = angular.scope();    }); -  afterEach(function(){ +  afterEach(function() {      dealoc(scope);    }); -  it('should use console if present', function(){ +  it('should use console if present', function() {      var logger = ""; -    function log(){ logger+= 'log;'; } -    function warn(){ logger+= 'warn;'; } -    function info(){ logger+= 'info;'; } -    function error(){ logger+= 'error;'; } +    function log() { logger+= 'log;'; } +    function warn() { logger+= 'warn;'; } +    function info() { logger+= 'info;'; } +    function error() { logger+= 'error;'; }      var scope = createScope({$log: $logFactory},                              {$exceptionHandler: rethrow,                               $window: {console: {log: log, @@ -35,9 +35,9 @@ describe('$log', function() {    }); -  it('should use console.log() if other not present', function(){ +  it('should use console.log() if other not present', function() {      var logger = ""; -    function log(){ logger+= 'log;'; } +    function log() { logger+= 'log;'; }      var scope = createScope({$log: $logFactory},                              {$window: {console:{log:log}},                               $exceptionHandler: rethrow}); @@ -50,7 +50,7 @@ describe('$log', function() {    }); -  it('should use noop if no console', function(){ +  it('should use noop if no console', function() {      var scope = createScope({$log: $logFactory},                              {$window: {},                               $exceptionHandler: rethrow}), @@ -62,36 +62,36 @@ describe('$log', function() {    }); -  describe('$log.error', function(){ +  describe('$log.error', function() {      var e, $log, errorArgs; -    beforeEach(function(){ +    beforeEach(function() {        e = new Error('');        e.message = undefined;        e.sourceURL = undefined;        e.line = undefined;        e.stack = undefined; -      $log = $logFactory({console:{error:function(){ +      $log = $logFactory({console:{error:function() {          errorArgs = arguments;        }}});      }); -    it('should pass error if does not have trace', function(){ +    it('should pass error if does not have trace', function() {        $log.error('abc', e);        expect(errorArgs).toEqual(['abc', e]);      }); -    it('should print stack', function(){ +    it('should print stack', function() {        e.stack = 'stack';        $log.error('abc', e);        expect(errorArgs).toEqual(['abc', 'stack']);      }); -    it('should print line', function(){ +    it('should print line', function() {        e.message = 'message';        e.sourceURL = 'sourceURL';        e.line = '123'; diff --git a/test/service/routeParamsSpec.js b/test/service/routeParamsSpec.js index 8cdf3af3..972e4314 100644 --- a/test/service/routeParamsSpec.js +++ b/test/service/routeParamsSpec.js @@ -1,7 +1,7 @@  'use strict'; -describe('$routeParams', function(){ -  it('should publish the params into a service', function(){ +describe('$routeParams', function() { +  it('should publish the params into a service', function() {      var scope = angular.scope(),          $location = scope.$service('$location'),          $route = scope.$service('$route'), @@ -20,7 +20,7 @@ describe('$routeParams', function(){    }); -  it('should preserve object identity during route reloads', function(){ +  it('should preserve object identity during route reloads', function() {      var scope = angular.scope(),          $location = scope.$service('$location'),          $route = scope.$service('$route'), diff --git a/test/service/windowSpec.js b/test/service/windowSpec.js index 3ead3df3..c539e285 100644 --- a/test/service/windowSpec.js +++ b/test/service/windowSpec.js @@ -3,17 +3,17 @@  describe('$window', function() {    var scope; -  beforeEach(function(){ +  beforeEach(function() {      scope = angular.scope();    }); -  afterEach(function(){ +  afterEach(function() {      dealoc(scope);    }); -  it("should inject $window", function(){ +  it("should inject $window", function() {      expect(scope.$service('$window')).toBe(window);    });  }); diff --git a/test/service/xhr.bulkSpec.js b/test/service/xhr.bulkSpec.js index e35673c7..6b99fbba 100644 --- a/test/service/xhr.bulkSpec.js +++ b/test/service/xhr.bulkSpec.js @@ -3,7 +3,7 @@  describe('$xhr.bulk', function() {    var scope, $browser, $browserXhr, $log, $xhrBulk, $xhrError, log; -  beforeEach(function(){ +  beforeEach(function() {      scope = angular.scope(angular.service, {        '$xhr.error': $xhrError = jasmine.createSpy('$xhr.error'),        '$log': $log = {} @@ -16,7 +16,7 @@ describe('$xhr.bulk', function() {    }); -  afterEach(function(){ +  afterEach(function() {      dealoc(scope);    }); @@ -27,7 +27,7 @@ describe('$xhr.bulk', function() {    } -  it('should collect requests', function(){ +  it('should collect requests', function() {      $xhrBulk.urls["/"] = {match:/.*/};      $xhrBulk('GET', '/req1', null, callback);      $xhrBulk('POST', '/req2', {post:'data'}, callback); @@ -39,13 +39,13 @@ describe('$xhr.bulk', function() {        {status:200, response:'first'},        {status:200, response:'second'}      ]); -    $xhrBulk.flush(function(){ log += 'DONE';}); +    $xhrBulk.flush(function() { log += 'DONE';});      $browserXhr.flush();      expect(log).toEqual('"first";"second";DONE');    }); -  it('should handle non 200 status code by forwarding to error handler', function(){ +  it('should handle non 200 status code by forwarding to error handler', function() {      $xhrBulk.urls['/'] = {match:/.*/};      $xhrBulk('GET', '/req1', null, callback);      $xhrBulk('POST', '/req2', {post:'data'}, callback); @@ -57,7 +57,7 @@ describe('$xhr.bulk', function() {        {status:404, response:'NotFound'},        {status:200, response:'second'}      ]); -    $xhrBulk.flush(function(){ log += 'DONE';}); +    $xhrBulk.flush(function() { log += 'DONE';});      $browserXhr.flush();      expect($xhrError).toHaveBeenCalled(); diff --git a/test/service/xhr.cacheSpec.js b/test/service/xhr.cacheSpec.js index c6b9cfec..0c77e629 100644 --- a/test/service/xhr.cacheSpec.js +++ b/test/service/xhr.cacheSpec.js @@ -12,7 +12,7 @@ describe('$xhr.cache', function() {    }); -  afterEach(function(){ +  afterEach(function() {      dealoc(scope);    }); @@ -23,7 +23,7 @@ describe('$xhr.cache', function() {    } -  it('should cache requests', function(){ +  it('should cache requests', function() {      $browserXhr.expectGET('/url').respond('first');      cache('GET', '/url', null, callback);      $browserXhr.flush(); @@ -39,7 +39,7 @@ describe('$xhr.cache', function() {    }); -  it('should first return cache request, then return server request', function(){ +  it('should first return cache request, then return server request', function() {      $browserXhr.expectGET('/url').respond('first');      cache('GET', '/url', null, callback, true);      $browserXhr.flush(); @@ -54,7 +54,7 @@ describe('$xhr.cache', function() {    }); -  it('should serve requests from cache', function(){ +  it('should serve requests from cache', function() {      cache.data.url = {value:'123'};      cache('GET', 'url', null, callback);      $browser.defer.flush(); @@ -66,7 +66,7 @@ describe('$xhr.cache', function() {    }); -  it('should keep track of in flight requests and request only once', function(){ +  it('should keep track of in flight requests and request only once', function() {      scope.$service('$xhr.bulk').urls['/bulk'] = {        match:function(url){          return url == '/url'; @@ -85,7 +85,7 @@ describe('$xhr.cache', function() {    }); -  it('should clear cache on non GET', function(){ +  it('should clear cache on non GET', function() {      $browserXhr.expectPOST('abc', {}).respond({});      cache.data.url = {value:123};      cache('POST', 'abc', {}); diff --git a/test/service/xhr.errorSpec.js b/test/service/xhr.errorSpec.js index 6cc7fce0..49b63fd0 100644 --- a/test/service/xhr.errorSpec.js +++ b/test/service/xhr.errorSpec.js @@ -3,7 +3,7 @@  describe('$xhr.error', function() {    var scope, $browser, $browserXhr, $xhr, $xhrError, log; -  beforeEach(function(){ +  beforeEach(function() {      scope = angular.scope(angular.service, {        '$xhr.error': $xhrError = jasmine.createSpy('$xhr.error')      }); @@ -14,7 +14,7 @@ describe('$xhr.error', function() {    }); -  afterEach(function(){ +  afterEach(function() {      dealoc(scope);    }); @@ -25,7 +25,7 @@ describe('$xhr.error', function() {    } -  it('should handle non 200 status codes by forwarding to error handler', function(){ +  it('should handle non 200 status codes by forwarding to error handler', function() {      $browserXhr.expectPOST('/req', 'MyData').respond(500, 'MyError');      $xhr('POST', '/req', 'MyData', callback);      $browserXhr.flush(); diff --git a/test/service/xhrSpec.js b/test/service/xhrSpec.js index b01eb385..2a552403 100644 --- a/test/service/xhrSpec.js +++ b/test/service/xhrSpec.js @@ -3,7 +3,7 @@  describe('$xhr', function() {    var scope, $browser, $browserXhr, $log, $xhr, $xhrErr, log; -  beforeEach(function(){ +  beforeEach(function() {      var scope = angular.scope(angular.service, {          '$xhr.error': $xhrErr = jasmine.createSpy('xhr.error')});      $log = scope.$service('$log'); @@ -14,7 +14,7 @@ describe('$xhr', function() {    }); -  afterEach(function(){ +  afterEach(function() {      dealoc(scope);    }); @@ -24,7 +24,7 @@ describe('$xhr', function() {    } -  it('should forward the request to $browser and decode JSON', function(){ +  it('should forward the request to $browser and decode JSON', function() {      $browserXhr.expectGET('/reqGET').respond('first');      $browserXhr.expectGET('/reqGETjson').respond('["second"]');      $browserXhr.expectPOST('/reqPOST', {post:'data'}).respond('third'); @@ -41,7 +41,7 @@ describe('$xhr', function() {          '{code=200; response="first"}');    }); -  it('should allow all 2xx requests', function(){ +  it('should allow all 2xx requests', function() {      $browserXhr.expectGET('/req1').respond(200, '1');      $xhr('GET', '/req1', null, callback);      $browserXhr.flush(); @@ -56,9 +56,9 @@ describe('$xhr', function() {    }); -  it('should handle exceptions in callback', function(){ +  it('should handle exceptions in callback', function() {      $browserXhr.expectGET('/reqGET').respond('first'); -    $xhr('GET', '/reqGET', null, function(){ throw "MyException"; }); +    $xhr('GET', '/reqGET', null, function() { throw "MyException"; });      $browserXhr.flush();      expect($log.error.logs.shift()).toContain('MyException'); @@ -140,7 +140,7 @@ describe('$xhr', function() {      describe('default headers', function() { -      it('should set default headers for GET request', function(){ +      it('should set default headers for GET request', function() {          var callback = jasmine.createSpy('callback');          $browserXhr.expectGET('URL', '', {'Accept': 'application/json, text/plain, */*', @@ -153,7 +153,7 @@ describe('$xhr', function() {        }); -      it('should set default headers for POST request', function(){ +      it('should set default headers for POST request', function() {          var callback = jasmine.createSpy('callback');          $browserXhr.expectPOST('URL', 'xx', {'Accept': 'application/json, text/plain, */*', @@ -167,7 +167,7 @@ describe('$xhr', function() {        }); -      it('should set default headers for custom HTTP method', function(){ +      it('should set default headers for custom HTTP method', function() {          var callback = jasmine.createSpy('callback');          $browserXhr.expect('FOO', 'URL', '', {'Accept': 'application/json, text/plain, */*', @@ -260,8 +260,8 @@ describe('$xhr', function() {      });    }); -  describe('xsrf', function(){ -    it('should copy the XSRF cookie into a XSRF Header', function(){ +  describe('xsrf', function() { +    it('should copy the XSRF cookie into a XSRF Header', function() {        var code, response;        $browserXhr          .expectPOST('URL', 'DATA', {'X-XSRF-TOKEN': 'secret'}) | 
