From fd822bdaf9d04e522aaa5400b673f333190abe98 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Fri, 7 Oct 2011 11:27:49 -0700 Subject: chore(formating): clean code to be function() { --- ...v_guide.compiler.widgets.creating_widgets.ngdoc | 2 +- docs/content/guide/dev_guide.expressions.ngdoc | 10 +++--- docs/content/guide/dev_guide.forms.ngdoc | 40 +++++++++++----------- .../dev_guide.mvc.understanding_controller.ngdoc | 6 ++-- docs/content/guide/dev_guide.overview.ngdoc | 4 +-- .../dev_guide.services.creating_services.ngdoc | 2 +- .../dev_guide.services.injecting_controllers.ngdoc | 2 +- ..._guide.templates.filters.creating_filters.ngdoc | 4 +-- docs/content/guide/dev_guide.unit-testing.ngdoc | 28 +++++++-------- 9 files changed, 49 insertions(+), 49 deletions(-) (limited to 'docs/content/guide') diff --git a/docs/content/guide/dev_guide.compiler.widgets.creating_widgets.ngdoc b/docs/content/guide/dev_guide.compiler.widgets.creating_widgets.ngdoc index 674f98aa..b73304c0 100644 --- a/docs/content/guide/dev_guide.compiler.widgets.creating_widgets.ngdoc +++ b/docs/content/guide/dev_guide.compiler.widgets.creating_widgets.ngdoc @@ -61,7 +61,7 @@ angular.widget('@my:watch', function(expression, compileElement) { angular.widget('my:time', function(compileElement){ compileElement.css('display', 'block'); return function(linkElement){ - function update(){ + function update() { linkElement.text('Current time is: ' + new Date()); setTimeout(update, 1000); } diff --git a/docs/content/guide/dev_guide.expressions.ngdoc b/docs/content/guide/dev_guide.expressions.ngdoc index ab5a897b..57fb9130 100644 --- a/docs/content/guide/dev_guide.expressions.ngdoc +++ b/docs/content/guide/dev_guide.expressions.ngdoc @@ -41,7 +41,7 @@ the `Scope:$eval()` method. 1+2={{1+2}} - it('should calculate expression in binding', function(){ + it('should calculate expression in binding', function() { expect(binding('1+2')).toEqual('3'); }); @@ -52,7 +52,7 @@ You can try evaluating different expressions here: @@ -50,7 +50,7 @@ text upper-case and assigns color. - it('should reverse greeting', function(){ + it('should reverse greeting', function() { expect(binding('greeting|reverse')).toEqual('olleh'); input('greeting').enter('ABC'); expect(binding('greeting|reverse')).toEqual('CBA'); diff --git a/docs/content/guide/dev_guide.unit-testing.ngdoc b/docs/content/guide/dev_guide.unit-testing.ngdoc index 459b6b93..978784f9 100644 --- a/docs/content/guide/dev_guide.unit-testing.ngdoc +++ b/docs/content/guide/dev_guide.unit-testing.ngdoc @@ -43,11 +43,11 @@ on a constructor permanently binds the call site to the type. For example lets s trying to instantiate an `XHR` so that we can get some data from the server.
-function MyClass(){
-  this.doWork = function(){
+function MyClass() {
+  this.doWork = function() {
     var xhr = new XHR();
     xhr.open(method, url, true);
-    xhr.onreadystatechange = function(){...}
+    xhr.onreadystatechange = function() {...}
     xhr.send();
   }
 }
@@ -61,7 +61,7 @@ patching, that is a bad idea for many reasons, which is outside the scope of thi
 The class above is hard to test since we have to resort to monkey patching:
 
 var oldXHR = XHR;
-XHR = function MockXHR(){};
+XHR = function MockXHR() {};
 var myClass = new MyClass();
 myClass.doWork();
 // assert that MockXHR got called with the right arguments
@@ -73,8 +73,8 @@ XHR = oldXHR; // if you forget this bad things will happen
 Another way to approach the problem is look for the service in a well known location.
 
 
-function MyClass(){
-  this.doWork = function(){
+function MyClass() {
+  this.doWork = function() {
     global.xhr({
       method:'...',
       url:'...',
@@ -94,7 +94,7 @@ State & Singletons}
 The class above is hard to test since we have to change global state:
 
 var oldXHR = glabal.xhr;
-glabal.xhr = function mockXHR(){};
+glabal.xhr = function mockXHR() {};
 var myClass = new MyClass();
 myClass.doWork();
 // assert that mockXHR got called with the right arguments
@@ -110,7 +110,7 @@ having the tests replace the services as needed.
 
 function MyClass() {
   var serviceRegistry = ????;
-  this.doWork = function(){
+  this.doWork = function() {
     var xhr = serviceRegistry.get('xhr');
     xhr({
       method:'...',
@@ -128,7 +128,7 @@ there is only one global variable to be reset).
 The class above is hard to test since we have to change global state:
 
 var oldServiceLocator = glabal.serviceLocator;
-glabal.serviceLocator.set('xhr', function mockXHR(){});
+glabal.serviceLocator.set('xhr', function mockXHR() {});
 var myClass = new MyClass();
 myClass.doWork();
 // assert that mockXHR got called with the right arguments
@@ -141,7 +141,7 @@ Lastly the dependency can be passed in.
 
 
 function MyClass(xhr) {
-  this.doWork = function(){
+  this.doWork = function() {
     xhr({
       method:'...',
       url:'...',
@@ -174,13 +174,13 @@ for your application is mixed in with DOM manipulation, it will be hard to test
 below:
 
 
-function PasswordController(){
+function PasswordController() {
   // get references to DOM elements
   var msg = $('.ex1 span');
   var input = $('.ex1 input');
   var strength;
 
-  this.grade = function(){
+  this.grade = function() {
     msg.removeClass(strength);
     var pwd = input.val();
     password.text(pwd);
@@ -219,9 +219,9 @@ In angular the controllers are strictly separated from the DOM manipulation logi
 a much easier testability story as can be seen in this example:
 
 
-function PasswordCntrl(){
+function PasswordCntrl() {
   this.password = '';
-  this.grade = function(){
+  this.grade = function() {
     var size = this.password.length;
     if (size > 8) {
       this.strength = 'strong';
-- 
cgit v1.2.3