chore(formating): clean code to be function() {

This commit is contained in:
Misko Hevery 2011-10-07 11:27:49 -07:00 committed by Igor Minar
parent 4f78fd692c
commit fd822bdaf9
107 changed files with 942 additions and 941 deletions

View file

@ -40,8 +40,8 @@ All `inputType` widgets support:
<doc:example>
<doc:source>
<script>
angular.inputType('json', function(){
this.$parseView = function(){
angular.inputType('json', function() {
this.$parseView = function() {
try {
this.$modelValue = angular.fromJson(this.$viewValue);
if (this.$error.JSON) {
@ -52,12 +52,12 @@ All `inputType` widgets support:
}
}
this.$parseModel = function(){
this.$parseModel = function() {
this.$viewValue = angular.toJson(this.$modelValue);
}
});
function Ctrl(){
function Ctrl() {
this.data = {
framework:'angular',
codenames:'supper-powers'
@ -81,7 +81,7 @@ All `inputType` widgets support:
</div>
</doc:source>
<doc:scenario>
it('should invalidate on wrong input', function(){
it('should invalidate on wrong input', function() {
expect(element('form[name=myForm]').prop('className')).toMatch('ng-valid');
input('data').enter('{}');
expect(binding('data')).toEqual('data={\n }');

View file

@ -9,7 +9,7 @@ detection, and preventing invalid form submission.
<doc:example>
<doc:source>
<script>
function UserForm(){
function UserForm() {
this.state = /^\w\w$/;
this.zip = /^\d\d\d\d\d$/;
this.master = {
@ -28,11 +28,11 @@ detection, and preventing invalid form submission.
}
UserForm.prototype = {
cancel: function(){
cancel: function() {
this.form = angular.copy(this.master);
},
save: function(){
save: function() {
this.master = this.form;
this.cancel();
}
@ -76,7 +76,7 @@ detection, and preventing invalid form submission.
</div>
</doc:source>
<doc:scenario>
it('should enable save button', function(){
it('should enable save button', function() {
expect(element(':button:contains(Save)').attr('disabled')).toBeTruthy();
input('form.name').enter('');
expect(element(':button:contains(Save)').attr('disabled')).toBeTruthy();
@ -85,7 +85,7 @@ detection, and preventing invalid form submission.
element(':button:contains(Save)').click();
expect(element(':button:contains(Save)').attr('disabled')).toBeTruthy();
});
it('should enable cancel button', function(){
it('should enable cancel button', function() {
expect(element(':button:contains(Cancel)').attr('disabled')).toBeTruthy();
input('form.name').enter('change');
expect(element(':button:contains(Cancel)').attr('disabled')).toBeFalsy();

View file

@ -56,7 +56,7 @@ The two partials are defined in the following URLs:
function WelcomeCntl($route){}
WelcomeCntl.prototype = {
greet: function(){
greet: function() {
alert("Hello " + this.person.name);
}
};
@ -67,11 +67,11 @@ The two partials are defined in the following URLs:
this.cancel();
}
SettingsCntl.prototype = {
cancel: function(){
cancel: function() {
this.form = angular.copy(this.person);
},
save: function(){
save: function() {
angular.copy(this.form, this.person);
this.$location.path('/welcome');
}
@ -89,7 +89,7 @@ The two partials are defined in the following URLs:
</div>
</doc:source>
<doc:scenario>
it('should navigate to URL', function(){
it('should navigate to URL', function() {
element('a:contains(Welcome)').click();
expect(element('ng\\:view').text()).toMatch(/Hello anonymous/);
element('a:contains(Settings)').click();

View file

@ -11,7 +11,7 @@ allow a user to enter data.
<doc:example>
<doc:source>
<script>
function FormController(){
function FormController() {
this.user = {
name: 'John Smith',
address:{line1: '123 Main St.', city:'Anytown', state:'AA', zip:'12345'},
@ -53,22 +53,22 @@ allow a user to enter data.
</doc:source>
<doc:scenario>
it('should show debug', function(){
it('should show debug', function() {
expect(binding('user')).toMatch(/John Smith/);
});
it('should add contact', function(){
it('should add contact', function() {
using('.example').element('a:contains(add)').click();
using('.example div:last').input('contact.value').enter('you@example.org');
expect(binding('user')).toMatch(/\(234\) 555\-1212/);
expect(binding('user')).toMatch(/you@example.org/);
});
it('should remove contact', function(){
it('should remove contact', function() {
using('.example').element('a:contains(X)').click();
expect(binding('user')).not().toMatch(/\(234\) 555\-1212/);
});
it('should validate zip', function(){
it('should validate zip', function() {
expect(using('.example').
element(':input[ng\\:model="user.address.zip"]').
prop('className')).not().toMatch(/ng-invalid/);
@ -78,7 +78,7 @@ allow a user to enter data.
prop('className')).toMatch(/ng-invalid/);
});
it('should validate state', function(){
it('should validate state', function() {
expect(using('.example').element(':input[ng\\:model="user.address.state"]').prop('className'))
.not().toMatch(/ng-invalid/);
using('.example').input('user.address.state').enter('XXX');

View file

@ -6,7 +6,7 @@
<doc:example>
<doc:source>
<script>
function HelloCntl(){
function HelloCntl() {
this.name = 'World';
}
</script>
@ -17,7 +17,7 @@
</div>
</doc:source>
<doc:scenario>
it('should change the binding when user enters text', function(){
it('should change the binding when user enters text', function() {
expect(binding('name')).toEqual('World');
input('name').enter('angular');
expect(binding('name')).toEqual('angular');

View file

@ -36,7 +36,7 @@ no connection between the controller and the view.
this.setUrl();
}
},
reset: function(){
reset: function() {
this.board = [
['', '', ''],
['', '', ''],
@ -46,7 +46,7 @@ no connection between the controller and the view.
this.winner = '';
this.setUrl();
},
grade: function(){
grade: function() {
var b = this.board;
this.winner =
row(0) || row(1) || row(2) ||
@ -57,7 +57,7 @@ no connection between the controller and the view.
function diagonal(i) { return same(b[0][1-i], b[1][1], b[2][1+i]);}
function same(a, b, c) { return (a==b && b==c) ? a : '';};
},
setUrl: function(){
setUrl: function() {
var rows = [];
angular.forEach(this.board, function(row){
rows.push(row.join(','));
@ -91,7 +91,7 @@ no connection between the controller and the view.
</div>
</doc:source>
<doc:scenario>
it('should play a game', function(){
it('should play a game', function() {
piece(1, 1);
expect(binding('nextMove')).toEqual('O');
piece(3, 1);

View file

@ -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);
}

View file

@ -41,7 +41,7 @@ the `Scope:$eval()` method.
1+2={{1+2}}
</doc:source>
<doc:scenario>
it('should calculate expression in binding', function(){
it('should calculate expression in binding', function() {
expect(binding('1+2')).toEqual('3');
});
</doc:scenario>
@ -52,7 +52,7 @@ You can try evaluating different expressions here:
<doc:example>
<doc:source>
<script>
function Cntl2(){
function Cntl2() {
this.exprs = [];
this.expr = '3*10|currency';
}
@ -70,7 +70,7 @@ You can try evaluating different expressions here:
</div>
</doc:source>
<doc:scenario>
it('should allow user expression testing', function(){
it('should allow user expression testing', function() {
element('.expressions :button').click();
var li = using('.expressions ul').repeater('li');
expect(li.count()).toBe(1);
@ -105,7 +105,7 @@ the global state (a common source of subtle bugs).
</div>
</doc:source>
<doc:scenario>
it('should calculate expression in binding', function(){
it('should calculate expression in binding', function() {
var alertText;
this.addFutureAction('set mock', function($window, $document, done) {
$window.mockWindow = {
@ -183,7 +183,7 @@ Extensions: You can further extend the expression vocabulary by adding new metho
</table>
</doc:source>
<doc:scenario>
it('should filter the list', function(){
it('should filter the list', function() {
var tr = using('table.example3').repeater('tr.ng-attr-widget');
expect(tr.count()).toBe(5);
input('searchText').enter('a');

View file

@ -111,7 +111,7 @@ The following example demonstrates:
.ng-form {display: block;}
</style>
<script>
function UserFormCntl(){
function UserFormCntl() {
this.state = /^\w\w$/;
this.zip = /^\d\d\d\d\d$/;
this.master = {
@ -127,11 +127,11 @@ The following example demonstrates:
}
UserFormCntl.prototype = {
cancel: function(){
cancel: function() {
this.form = angular.copy(this.master);
},
save: function(){
save: function() {
this.master = this.form;
this.cancel();
}
@ -187,7 +187,7 @@ The following example demonstrates:
</div>
</doc:source>
<doc:scenario>
it('should enable save button', function(){
it('should enable save button', function() {
expect(element(':button:contains(Save)').attr('disabled')).toBeTruthy();
input('form.customer').enter('');
expect(element(':button:contains(Save)').attr('disabled')).toBeTruthy();
@ -196,7 +196,7 @@ The following example demonstrates:
element(':button:contains(Save)').click();
expect(element(':button:contains(Save)').attr('disabled')).toBeTruthy();
});
it('should enable cancel button', function(){
it('should enable cancel button', function() {
expect(element(':button:contains(Cancel)').attr('disabled')).toBeTruthy();
input('form.customer').enter('change');
expect(element(':button:contains(Cancel)').attr('disabled')).toBeFalsy();
@ -274,7 +274,7 @@ This example shows how to implement a custom HTML editor widget in Angular.
<doc:example>
<doc:source>
<script>
function EditorCntl(){
function EditorCntl() {
this.htmlContent = '<b>Hello</b> <i>World</i>!';
}
@ -282,7 +282,7 @@ This example shows how to implement a custom HTML editor widget in Angular.
var self = this;
var htmlFilter = angular.filter('html');
this.$parseModel = function(){
this.$parseModel = function() {
// need to protect for script injection
try {
this.$viewValue = htmlFilter(
@ -297,18 +297,18 @@ This example shows how to implement a custom HTML editor widget in Angular.
}
}
this.$render = function(){
this.$render = function() {
element.html(this.$viewValue);
}
element.bind('keyup', function(){
self.$apply(function(){
element.bind('keyup', function() {
self.$apply(function() {
self.$emit('$viewChange', element.html());
});
});
}
angular.directive('ng:html-editor-model', function(){
angular.directive('ng:html-editor-model', function() {
function linkFn($formFactory, element) {
var exp = element.attr('ng:html-editor-model'),
form = $formFactory.forElement(element),
@ -321,7 +321,7 @@ This example shows how to implement a custom HTML editor widget in Angular.
controllerArgs: [element]});
// if the element is destroyed, then we need to
// notify the form.
element.bind('$destroy', function(){
element.bind('$destroy', function() {
widget.$destroy();
});
}
@ -339,7 +339,7 @@ This example shows how to implement a custom HTML editor widget in Angular.
</form>
</doc:source>
<doc:scenario>
it('should enter invalid HTML', function(){
it('should enter invalid HTML', function() {
expect(element('form[name=editorForm]').prop('className')).toMatch(/ng-valid/);
input('htmlContent').enter('<');
expect(element('form[name=editorForm]').prop('className')).toMatch(/ng-invalid/);
@ -358,7 +358,7 @@ validation.
<doc:example>
<doc:source>
<script>
function Ctrl(){
function Ctrl() {
this.input1 = '';
this.input2 = '';
this.input3 = 'A';
@ -447,32 +447,32 @@ validation.
</doc:source>
<doc:scenario>
it('should exercise text', function(){
it('should exercise text', function() {
input('input1').enter('Carlos');
expect(binding('input1')).toEqual('"Carlos"');
});
it('should exercise textarea', function(){
it('should exercise textarea', function() {
input('input2').enter('Carlos');
expect(binding('input2')).toEqual('"Carlos"');
});
it('should exercise radio', function(){
it('should exercise radio', function() {
expect(binding('input3')).toEqual('"A"');
input('input3').select('B');
expect(binding('input3')).toEqual('"B"');
input('input3').select('A');
expect(binding('input3')).toEqual('"A"');
});
it('should exercise checkbox', function(){
it('should exercise checkbox', function() {
expect(binding('input4')).toEqual('false');
input('input4').check();
expect(binding('input4')).toEqual('true');
});
it('should exercise pulldown', function(){
it('should exercise pulldown', function() {
expect(binding('input5')).toEqual('"c"');
select('input5').option('d');
expect(binding('input5')).toEqual('"d"');
});
it('should exercise multiselect', function(){
it('should exercise multiselect', function() {
expect(binding('input6')).toEqual('[]');
select('input6').options('e');
expect(binding('input6')).toEqual('["e"]');

View file

@ -3,7 +3,7 @@
@name Developer Guide: About MVC in Angular: Understanding the Controller Component
@description
In angular, a controller is a JavaScript function (type/class) that is used to augment instances of
In angular, a controller is a JavaScript function(type/class) that is used to augment instances of
angular {@link dev_guide.scopes Scope}, excluding the root scope. When you or angular create a new
child scope object via the {@link api/angular.scope.$new scope.$new} API , there is an
option to pass in a controller as a method argument. This will tell angular to associate the
@ -128,7 +128,7 @@ starts with capital letter and ends with "Ctrl" or "Controller".
controller augments.
- Assigning a property to `this` creates or updates the model.
- Controller methods can be created through direct assignment to scope (the `chiliSpicy` method) or
as prototype methods of the controller constructor function (the `jalapenoSpicy` method)
as prototype methods of the controller constructor function(the `jalapenoSpicy` method)
- Both controller methods are available in the template (for the `body` element and and its
children).
@ -227,7 +227,7 @@ Controller Test:
<pre>
describe('myController function', function() {
describe('myController', function(){
describe('myController', function() {
var ctrl;
beforeEach(function() {

View file

@ -43,7 +43,7 @@ easier a web developer's life can if they're using angular:
<doc:example>
<doc:source>
<script>
function InvoiceCntl(){
function InvoiceCntl() {
this.qty = 1;
this.cost = 19.95;
}
@ -66,7 +66,7 @@ easier a web developer's life can if they're using angular:
</doc:source>
<!--
<doc:scenario>
it('should show of angular binding', function(){
it('should show of angular binding', function() {
expect(binding('qty * cost')).toEqual('$19.95');
input('qty').enter('2');
input('cost').enter('5.00');

View file

@ -10,7 +10,7 @@ that angular's DI will use to create the service object when it is needed.
The `angular.service` method accepts three parameters:
- `{string} name` - Name of the service.
- `{function()} factory` - Factory function (called just once by DI).
- `{function()} factory` - Factory function(called just once by DI).
- `{Object} config` - Configuration object with the following properties:
- `$inject` - {Array.<string>} - Array of service ids this service depends on. These services
will be passed as arguments into the factory function in the same order specified in the `$inject`

View file

@ -59,7 +59,7 @@ myController.$inject = ['notify'];
</div>
</doc:source>
<doc:scenario>
it('should test service', function(){
it('should test service', function() {
expect(element(':input[ng\\:model="message"]').val()).toEqual('test');
});
</doc:scenario>

View file

@ -36,7 +36,7 @@ text upper-case and assigns color.
return out;
});
function Ctrl(){
function Ctrl() {
this.greeting = 'hello';
}
</script>
@ -50,7 +50,7 @@ text upper-case and assigns color.
</div>
</doc:source>
<doc:scenario>
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');

View file

@ -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.
<pre>
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:
<pre>
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.
<pre>
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:
<pre>
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.
<pre>
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:
<pre>
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.
<pre>
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:
<pre>
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:
<pre>
function PasswordCntrl(){
function PasswordCntrl() {
this.password = '';
this.grade = function(){
this.grade = function() {
var size = this.password.length;
if (size > 8) {
this.strength = 'strong';

View file

@ -69,7 +69,7 @@ view.
## Model and Controller
The data __model__ (a simple array of phones in object literal notation) is instantiated within
the __controller__ function (`PhoneListCtrl`):
the __controller__ function(`PhoneListCtrl`):
__`app/js/controllers.js`:__
<pre>
@ -91,7 +91,7 @@ providing context for our data model, the controller allows us to establish data
the model and the view. We connected the dots between the presentation, data, and logic components
as follows:
* The name of our controller function (in the JavaScript file `controllers.js`) matches the {@link
* The name of our controller function(in the JavaScript file `controllers.js`) matches the {@link
api/angular.directive.ng:controller ng:controller} directive in the `<body>` tag (`PhoneListCtrl`).
* The data is instantiated within the *scope* of our controller function; our template binding
points are located within the block bounded by the `<body ng:controller="PhoneListCtrl">` tag.

View file

@ -114,7 +114,7 @@ __`test/unit/controllerSpec.js`:__
<pre>
describe('PhoneCat controllers', function() {
describe('PhoneListCtrl', function(){
describe('PhoneListCtrl', function() {
var scope, $browser, ctrl;
beforeEach(function() {

View file

@ -129,7 +129,7 @@ __`test/unit/controllersSpec.js`:__
<pre>
describe('PhoneCat controllers', function() {
beforeEach(function(){
beforeEach(function() {
this.addMatchers({
toEqualData: function(expected) {
return angular.equals(this.actual, expected);

View file

@ -1,15 +1,15 @@
var DOM = require('dom.js').DOM;
describe('dom', function(){
describe('dom', function() {
var dom;
beforeEach(function(){
beforeEach(function() {
dom = new DOM();
});
describe('h', function(){
describe('h', function() {
it('should render using function', function(){
it('should render using function', function() {
var cbThis;
var cdValue;
dom.h('heading', 'content', function(value){
@ -20,8 +20,8 @@ describe('dom', function(){
expect(cbValue).toEqual('content');
});
it('should update heading numbers', function(){
dom.h('heading', function(){
it('should update heading numbers', function() {
dom.h('heading', function() {
this.html('<h1>sub-heading</h1>');
});
expect(dom.toString()).toContain('<h1>heading</h1>');

View file

@ -1,11 +1,11 @@
var ngdoc = require('ngdoc.js');
var DOM = require('dom.js').DOM;
describe('ngdoc', function(){
describe('ngdoc', function() {
var Doc = ngdoc.Doc;
var dom;
beforeEach(function(){
beforeEach(function() {
dom = new DOM();
this.addMatchers({
toContain: function(text) {
@ -15,15 +15,15 @@ describe('ngdoc', function(){
});
});
describe('Doc', function(){
describe('metadata', function(){
describe('Doc', function() {
describe('metadata', function() {
it('should find keywords', function(){
it('should find keywords', function() {
expect(new Doc('\nHello: World! @ignore. $abc').keywords()).toEqual('$abc hello world');
expect(new Doc('The `ng:class-odd` and').keywords()).toEqual('and ng:class-odd the');
});
it('should have shortName', function(){
it('should have shortName', function() {
var d1 = new Doc('@name a.b.c').parse();
var d2 = new Doc('@name a.b.ng:c').parse();
var d3 = new Doc('@name some text: more text').parse();
@ -32,7 +32,7 @@ describe('ngdoc', function(){
expect(ngdoc.metadata([d3])[0].shortName).toEqual('more text');
});
it('should have depth information', function(){
it('should have depth information', function() {
var d1 = new Doc('@name a.b.c').parse();
var d2 = new Doc('@name a.b.ng:c').parse();
var d3 = new Doc('@name some text: more text').parse();
@ -43,8 +43,8 @@ describe('ngdoc', function(){
});
describe('parse', function(){
it('should convert @names into properties', function(){
describe('parse', function() {
it('should convert @names into properties', function() {
var doc = new Doc('\n@name name\n@desc\ndesc\ndesc2\n@dep\n');
doc.parse();
expect(doc.name).toEqual('name');
@ -52,7 +52,7 @@ describe('ngdoc', function(){
expect(doc.dep).toEqual('');
});
it('should parse parameters', function(){
it('should parse parameters', function() {
var doc = new Doc(
'@param {*} a short\n' +
'@param {Type} b med\n' +
@ -65,7 +65,7 @@ describe('ngdoc', function(){
]);
});
it('should parse return', function(){
it('should parse return', function() {
var doc = new Doc('@returns {Type} text *bold*.');
doc.parse();
expect(doc.returns).toEqual({
@ -74,14 +74,14 @@ describe('ngdoc', function(){
});
});
it('should parse filename', function(){
it('should parse filename', function() {
var doc = new Doc('@name friendly name', 'docs/a.b.ngdoc', 1);
doc.parse(0);
expect(doc.id).toEqual('a.b');
expect(doc.name).toEqual('friendly name');
});
it('should escape <doc:source> element', function(){
it('should escape <doc:source> element', function() {
var doc = new Doc('@description before <doc:example>' +
'<doc:source>\n<>\n</doc:source></doc:example> after');
doc.parse();
@ -89,7 +89,7 @@ describe('ngdoc', function(){
'<pre class="doc-source">\n&lt;&gt;\n</pre></doc:example><p>after</p>');
});
it('should preserve the jsfiddle attribute', function(){
it('should preserve the jsfiddle attribute', function() {
var doc = new Doc('@description before <doc:example>' +
'<doc:source jsfiddle="foo">lala</doc:source></doc:example> after');
doc.parse();
@ -97,7 +97,7 @@ describe('ngdoc', function(){
'<pre class="doc-source" jsfiddle="foo">lala</pre></doc:example><p>after</p>');
});
it('should escape <doc:scenario> element', function(){
it('should escape <doc:scenario> element', function() {
var doc = new Doc('@description before <doc:example>' +
'<doc:scenario>\n<>\n</doc:scenario></doc:example> after');
doc.parse();
@ -132,11 +132,11 @@ describe('ngdoc', function(){
});
});
describe('sorting', function(){
describe('sorting', function() {
function property(name) {
return function(obj) {return obj[name];};
}
function noop(){}
function noop() {}
function doc(type, name){
return {
id: name,
@ -149,7 +149,7 @@ describe('ngdoc', function(){
var angular_x = doc('function', 'angular.x');
var angular_y = doc('property', 'angular.y');
it('should put angular.fn() in front of angular.widget, etc', function(){
it('should put angular.fn() in front of angular.widget, etc', function() {
expect(ngdoc.metadata([angular_widget, angular_y, angular_x]).map(property('id')))
.toEqual(['angular.x', 'angular.y', 'angular.widget' ]);
});
@ -157,13 +157,13 @@ describe('ngdoc', function(){
});
});
describe('markdown', function(){
it('should replace angular in markdown', function(){
describe('markdown', function() {
it('should replace angular in markdown', function() {
expect(new Doc().markdown('<angular/>')).
toEqual('<p><tt>&lt;angular/&gt;</tt></p>');
});
it('should not replace anything in <pre>, but escape the html escape the content', function(){
it('should not replace anything in <pre>, but escape the html escape the content', function() {
expect(new Doc().markdown('bah x\n<pre>\n<b>angular</b>.k\n</pre>\n asdf x')).
toEqual(
'<p>bah x</p>' +
@ -234,19 +234,19 @@ describe('ngdoc', function(){
});
describe('trim', function(){
describe('trim', function() {
var trim = ngdoc.trim;
it('should remove leading/trailing space', function(){
it('should remove leading/trailing space', function() {
expect(trim(' \nabc\n ')).toEqual('abc');
});
it('should remove leading space on every line', function(){
it('should remove leading space on every line', function() {
expect(trim('\n 1\n 2\n 3\n')).toEqual('1\n 2\n 3');
});
});
describe('merge', function(){
it('should merge child with parent', function(){
describe('merge', function() {
it('should merge child with parent', function() {
var parent = new Doc({id: 'angular.service.abc', name: 'angular.service.abc', section: 'api'});
var methodA = new Doc({name: 'methodA', methodOf: 'angular.service.abc'});
var methodB = new Doc({name: 'methodB', methodOf: 'angular.service.abc'});
@ -294,9 +294,9 @@ describe('ngdoc', function(){
////////////////////////////////////////
describe('TAG', function(){
describe('@param', function(){
it('should parse with no default', function(){
describe('TAG', function() {
describe('@param', function() {
it('should parse with no default', function() {
var doc = new Doc('@param {(number|string)} number Number \n to format.');
doc.parse();
expect(doc.param).toEqual([{
@ -307,7 +307,7 @@ describe('ngdoc', function(){
description : '<p>Number \nto format.</p>' }]);
});
it('should parse with default and optional', function(){
it('should parse with default and optional', function() {
var doc = new Doc('@param {(number|string)=} [fractionSize=2] desc');
doc.parse();
expect(doc.param).toEqual([{
@ -397,8 +397,8 @@ describe('ngdoc', function(){
});
});
describe('@description', function(){
it('should support pre blocks', function(){
describe('@description', function() {
it('should support pre blocks', function() {
var doc = new Doc("@description <pre><b>abc</b></pre>");
doc.parse();
expect(doc.description).
@ -442,7 +442,7 @@ describe('ngdoc', function(){
toContain('<a href="./static.html">./static.html</a>');
});
it('should support line breaks in @link', function(){
it('should support line breaks in @link', function() {
var doc = new Doc("@description " +
'{@link\napi/angular.foo\na\nb}');
doc.parse();
@ -452,14 +452,14 @@ describe('ngdoc', function(){
});
describe('@example', function(){
it('should not remove {{}}', function(){
describe('@example', function() {
it('should not remove {{}}', function() {
var doc = new Doc('@example text {{ abc }}');
doc.parse();
expect(doc.example).toEqual('<p>text {{ abc }}</p>');
});
it('should support doc:example', function(){
it('should support doc:example', function() {
var doc = new Doc('@ngdoc overview\n@example \n' +
'<doc:example>\n' +
' <doc:source><escapeme></doc:source>\n' +
@ -480,7 +480,7 @@ describe('ngdoc', function(){
});
});
describe('@this', function(){
describe('@this', function() {
it('should render @this', function() {
var doc = new Doc('@this I am self.');
doc.ngdoc = 'filter';
@ -495,9 +495,9 @@ describe('ngdoc', function(){
});
});
describe('usage', function(){
describe('overview', function(){
it('should supress description heading', function(){
describe('usage', function() {
describe('overview', function() {
it('should supress description heading', function() {
var doc = new Doc('@ngdoc overview\n@name angular\n@description\n#heading\ntext');
doc.parse();
expect(doc.html()).toContain('text');
@ -507,8 +507,8 @@ describe('ngdoc', function(){
});
describe('function', function(){
it('should format', function(){
describe('function', function() {
it('should format', function() {
var doc = new Doc({
ngdoc:'function',
name:'some.name',
@ -527,8 +527,8 @@ describe('ngdoc', function(){
});
});
describe('filter', function(){
it('should format', function(){
describe('filter', function() {
it('should format', function() {
var doc = new Doc({
ngdoc:'formatter',
shortName:'myFilter',
@ -543,8 +543,8 @@ describe('ngdoc', function(){
});
});
describe('property', function(){
it('should format', function(){
describe('property', function() {
it('should format', function() {
var doc = new Doc({
ngdoc:'property',
name:'myProp',

View file

@ -2,8 +2,8 @@ var SiteMap = require('SiteMap.js').SiteMap;
var Doc = require('ngdoc.js').Doc;
describe('sitemap', function(){
it('should render empty sitemap', function(){
describe('sitemap', function() {
it('should render empty sitemap', function() {
var map = new SiteMap([]);
expect(map.render()).toEqual([
'<?xml version="1.0" encoding="UTF-8"?>',
@ -11,7 +11,7 @@ describe('sitemap', function(){
'</urlset>', ''].join('\n'));
});
it('should render ngdoc url', function(){
it('should render ngdoc url', function() {
var map = new SiteMap([new Doc({section: 'foo', id: 'a.b.c<>\'"&'})]);
expect(map.render()).toContain([
' <url>',

View file

@ -10,7 +10,7 @@ for(var key in jasmine) {
}
//Patch Jasmine for proper stack traces
jasmine.Spec.prototype.fail = function (e) {
jasmine.Spec.prototype.fail = function(e) {
var expectationResult = new jasmine.ExpectationResult({
passed: false,
message: e ? jasmine.util.formatException(e) : 'Exception'

View file

@ -1,17 +1,17 @@
var writer = require('writer.js');
describe('writer', function(){
describe('toString', function(){
describe('writer', function() {
describe('toString', function() {
var toString = writer.toString;
it('should merge string', function(){
it('should merge string', function() {
expect(toString('abc')).toEqual('abc');
});
it('should merge obj', function(){
it('should merge obj', function() {
expect(toString({a:1})).toEqual('{"a":1}');
});
it('should merge array', function(){
it('should merge array', function() {
expect(toString(['abc',{}])).toEqual('abc{}');
});
});

View file

@ -7,7 +7,7 @@ exports.SiteMap = SiteMap;
* @returns {SiteMap}
*/
function SiteMap(docs){
this.render = function(){
this.render = function() {
var map = [];
map.push('<?xml version="1.0" encoding="UTF-8"?>');
map.push('<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">');

View file

@ -12,7 +12,7 @@ function htmlEscape(text){
}
function DOM(){
function DOM() {
this.out = [];
this.headingDepth = 0;
}
@ -69,7 +69,7 @@ DOM.prototype = {
},
code: function(text) {
this.tag('div', {'ng:non-bindable':''}, function(){
this.tag('div', {'ng:non-bindable':''}, function() {
this.tag('pre', {'class':"brush: js; html-script: true;"}, text);
});
},
@ -84,7 +84,7 @@ DOM.prototype = {
if (content instanceof Array) {
this.ul(content, className, fn);
} else if (fn) {
this.tag('div', className, function(){
this.tag('div', className, function() {
fn.call(this, content);
});
} else {

View file

@ -7,7 +7,7 @@ var reader = require('reader.js'),
appCache = require('appCache.js').appCache,
Q = require('qq');
process.on('uncaughtException', function (err) {
process.on('uncaughtException', function(err) {
console.error(err.stack || err);
});
@ -93,6 +93,6 @@ function writeTheRest(writesFuture) {
}
function now(){ return new Date().getTime(); }
function now() { return new Date().getTime(); }
function noop(){};
function noop() {};

View file

@ -37,14 +37,14 @@ function Doc(text, file, line) {
this.events = this.events || [];
this.links = this.links || [];
}
Doc.METADATA_IGNORE = (function(){
Doc.METADATA_IGNORE = (function() {
var words = require('fs').readFileSync(__dirname + '/ignore.words', 'utf8');
return words.toString().split(/[,\s\n\r]+/gm);
})();
Doc.prototype = {
keywords: function keywords(){
keywords: function keywords() {
var keywords = {};
Doc.METADATA_IGNORE.forEach(function(ignore){ keywords[ignore] = true; });
var words = [];
@ -83,7 +83,7 @@ Doc.prototype = {
return this.section + '/' + url;
},
markdown: function (text) {
markdown: function(text) {
if (!text) return text;
var self = this,
@ -151,7 +151,7 @@ Doc.prototype = {
return parts.join('');
},
parse: function(){
parse: function() {
var atName;
var atText;
var match;
@ -180,7 +180,7 @@ Doc.prototype = {
this['this'] = this.markdown(this['this']);
return this;
function flush(){
function flush() {
if (atName) {
var text = trim(atText.join('\n'));
if (atName == 'param') {
@ -234,11 +234,11 @@ Doc.prototype = {
}
},
html: function(){
html: function() {
var dom = new DOM(),
self = this;
dom.h(this.name, function(){
dom.h(this.name, function() {
notice('workInProgress', 'Work in Progress',
'This page is currently being revised. It might be incomplete or contain inaccuracies.');
notice('deprecated', 'Deprecated API', self.deprecated);
@ -247,13 +247,13 @@ Doc.prototype = {
dom.h('Description', self.description, dom.html);
}
dom.h('Dependencies', self.requires, function(require){
dom.tag('code', function(){
dom.tag('code', function() {
dom.tag('a', {href: 'api/angular.service.' + require.name}, require.name);
});
dom.html(require.text);
});
(self['html_usage_' + self.ngdoc] || function(){
(self['html_usage_' + self.ngdoc] || function() {
throw new Error("Don't know how to format @ngdoc: " + self.ngdoc);
}).call(self, dom);
@ -276,10 +276,10 @@ Doc.prototype = {
html_usage_parameters: function(dom) {
dom.h('Parameters', this.param, function(param){
dom.tag('code', function(){
dom.tag('code', function() {
dom.text(param.name);
if (param.optional) {
dom.tag('i', function(){
dom.tag('i', function() {
dom.text('(optional');
if(param['default']) {
dom.text('=' + param['default']);
@ -298,7 +298,7 @@ Doc.prototype = {
html_usage_returns: function(dom) {
var self = this;
if (self.returns) {
dom.h('Returns', function(){
dom.h('Returns', function() {
dom.tag('code', '{' + self.returns.type + '}');
dom.text(' ');
dom.html(self.returns.description);
@ -319,8 +319,8 @@ Doc.prototype = {
html_usage_function: function(dom){
var self = this;
dom.h('Usage', function(){
dom.code(function(){
dom.h('Usage', function() {
dom.code(function() {
dom.text(self.name.split('service.').pop());
dom.text('(');
self.parameters(dom, ', ');
@ -335,8 +335,8 @@ Doc.prototype = {
html_usage_property: function(dom){
var self = this;
dom.h('Usage', function(){
dom.code(function(){
dom.h('Usage', function() {
dom.code(function() {
dom.text(self.name);
});
@ -346,8 +346,8 @@ Doc.prototype = {
html_usage_directive: function(dom){
var self = this;
dom.h('Usage', function(){
dom.tag('pre', {'class':"brush: js; html-script: true;"}, function(){
dom.h('Usage', function() {
dom.tag('pre', {'class':"brush: js; html-script: true;"}, function() {
dom.text('<' + self.element + ' ');
dom.text(self.shortName);
if (self.param.length) {
@ -362,9 +362,9 @@ Doc.prototype = {
html_usage_filter: function(dom){
var self = this;
dom.h('Usage', function(){
dom.h('In HTML Template Binding', function(){
dom.tag('code', function(){
dom.h('Usage', function() {
dom.h('In HTML Template Binding', function() {
dom.tag('code', function() {
dom.text('{{ ');
dom.text(self.shortName);
dom.text('_expression | ');
@ -374,8 +374,8 @@ Doc.prototype = {
});
});
dom.h('In JavaScript', function(){
dom.tag('code', function(){
dom.h('In JavaScript', function() {
dom.tag('code', function() {
dom.text('angular.filter.');
dom.text(self.shortName);
dom.text('(');
@ -392,8 +392,8 @@ Doc.prototype = {
html_usage_inputType: function(dom){
var self = this;
dom.h('Usage', function(){
dom.code(function(){
dom.h('Usage', function() {
dom.code(function() {
dom.text('<input type="' + self.shortName + '"');
(self.param||[]).forEach(function(param){
dom.text('\n ');
@ -410,9 +410,9 @@ Doc.prototype = {
html_usage_widget: function(dom){
var self = this;
dom.h('Usage', function(){
dom.h('In HTML Template Binding', function(){
dom.code(function(){
dom.h('Usage', function() {
dom.h('In HTML Template Binding', function() {
dom.code(function() {
if (self.shortName.match(/^@/)) {
dom.text('<');
dom.text(self.element);
@ -456,8 +456,8 @@ Doc.prototype = {
var self = this;
if (this.param.length) {
dom.h('Usage', function(){
dom.code(function(){
dom.h('Usage', function() {
dom.code(function() {
dom.text(self.name.split('.').pop());
dom.text('(');
self.parameters(dom, ', ');
@ -472,7 +472,7 @@ Doc.prototype = {
dom.h('Methods', this.methods, function(method){
var signature = (method.param || []).map(property('name'));
dom.h(method.shortName + '(' + signature.join(', ') + ')', method, function(){
dom.h(method.shortName + '(' + signature.join(', ') + ')', method, function() {
dom.html(method.description);
method.html_usage_parameters(dom);
self.html_usage_this(dom);
@ -482,23 +482,23 @@ Doc.prototype = {
});
});
dom.h('Properties', this.properties, function(property){
dom.h(property.name, function(){
dom.h(property.name, function() {
dom.html(property.description);
dom.h('Example', property.example, dom.html);
});
});
dom.h('Events', this.events, function(event){
dom.h(event.shortName, event, function(){
dom.h(event.shortName, event, function() {
dom.html(event.description);
if (event.type == 'listen') {
dom.tag('div', {class:'inline'}, function(){
dom.tag('div', {class:'inline'}, function() {
dom.h('Listen on:', event.target);
});
} else {
dom.tag('div', {class:'inline'}, function(){
dom.tag('div', {class:'inline'}, function() {
dom.h('Type:', event.type);
});
dom.tag('div', {class:'inline'}, function(){
dom.tag('div', {class:'inline'}, function() {
dom.h('Target:', event.target);
});
}
@ -547,8 +547,8 @@ function scenarios(docs){
function appendSpecs(urlPrefix) {
docs.forEach(function(doc){
specs.push(' describe("' + doc.section + '/' + doc.id + '", function(){');
specs.push(' beforeEach(function(){');
specs.push(' describe("' + doc.section + '/' + doc.id + '", function() {');
specs.push(' beforeEach(function() {');
specs.push(' browser().navigateTo("' + urlPrefix + doc.section + '/' + doc.id + '");');
specs.push(' });');
specs.push(' ');
@ -686,7 +686,7 @@ function indent(text, spaceCount) {
function merge(docs){
var byFullId = {};
docs.forEach(function (doc) {
docs.forEach(function(doc) {
byFullId[doc.section + '/' + doc.id] = doc;
});

View file

@ -1,4 +1,4 @@
(function(){
(function() {
var angularJsUrl;
var scripts = document.getElementsByTagName("script");

View file

@ -44,7 +44,7 @@ function DocsController($location, $browser, $window, $cookies) {
return page.section + '/' + page.id;
};
this.getCurrentPartial = function(){
this.getCurrentPartial = function() {
return this.partialId ? ('./partials/' + this.sectionId + '/' + this.partialId + '.html') : '';
};

File diff suppressed because one or more lines are too long

View file

@ -18,7 +18,7 @@ exports.output = function(file, content) {
};
//recursively create directory
exports.makeDir = function (path) {
exports.makeDir = function(path) {
var parts = path.split(/\//);
var path = ".";
//Sequentially create directories
@ -99,7 +99,7 @@ function merge(srcs, to) {
var contents = [];
//Sequentially read file
var done;
srcs.forEach(function (src) {
srcs.forEach(function(src) {
done = Q.when(done, function(content) {
if(content) contents.push(content);
return qfs.read(src, 'b');
@ -128,7 +128,7 @@ exports.toString = function toString(obj) {
return obj;
case 'object':
if (obj instanceof Array) {
obj.forEach(function (value, key) {
obj.forEach(function(value, key) {
obj[key] = toString(value);
});
return obj.join('');
@ -140,4 +140,4 @@ exports.toString = function toString(obj) {
};
function noop(){};
function noop() {};

View file

@ -8,11 +8,11 @@ angular.service('myApplication', function($resource){
});
}, {inject:['$resource']});
function BuzzController(){
function BuzzController() {
this.$watch('$location.hashPath', this.userChange);
}
BuzzController.prototype = {
userChange: function(){
userChange: function() {
this.userId = this.$location.hashPath;
this.activities = this.Activity.get({userId:this.userId});
},
@ -22,7 +22,7 @@ BuzzController.prototype = {
if (activity.replies) {
activity.replies.show = !activity.replies.show;
} else {
activity.replies = this.Activity.replies({userId:this.userId, activityId:activity.id}, function(){
activity.replies = this.Activity.replies({userId:this.userId, activityId:activity.id}, function() {
activity.replies.show = true;
});
}

View file

@ -10,7 +10,7 @@ describe('personal log', function() {
});
it('should create new logs and order them in reverse chronological order', function(){
it('should create new logs and order them in reverse chronological order', function() {
//create first msg
input('newMsg').enter('my first message');
element('form input[type="submit"]').click();

View file

@ -1,7 +1,7 @@
function noop(){}
$(document).ready(function(){
function noop() {}
$(document).ready(function() {
function xhr(method, url, data, callback){
jQuery.getJSON(url, function(){
jQuery.getJSON(url, function() {
callback.apply(this, arguments);
scope.updateView();
});

View file

@ -36,7 +36,7 @@ if (flag == '--login') {
help();
}
function help(){
function help() {
console.log('Synopsys');
console.log('gdocs.js --login <username>');
console.log('gdocs.js --fetch [<docs collection>]');
@ -141,7 +141,7 @@ function login(username, password){
);
}
function getAuthToken(){
function getAuthToken() {
var pwdFile = 'tmp/gdocs.auth';
try {
fs.statSync(pwdFile);
@ -164,10 +164,10 @@ function request(method, url, options, response) {
case 200:
var data = [];
res.setEncoding('utf8');
res.on('end', function (){ response(data.join('')); });
res.on('close', function (){ response(data.join('')); }); // https
res.on('end', function () { response(data.join('')); });
res.on('close', function () { response(data.join('')); }); // https
res.on('data', function (chunk) { data.push(chunk); });
res.on('error', function (e){ console.log(e); });
res.on('error', function (e) { console.log(e); });
break;
case 401:
console.log('Eror: Login credentials expired! Please login.');
@ -190,7 +190,7 @@ function request(method, url, options, response) {
}
if (options.data)
request.write(encodeData(options.data));
request.on('end', function(){
request.on('end', function() {
console.log('end');
});
request.end();
@ -212,7 +212,7 @@ function askPassword(callback) {
console.log('Enter your password:');
var password = "";
stdin.on("data", function (c) {
stdin.on("data", function(c) {
c = c + "";
switch (c) {
case "\n": case "\r": case "\u0004":
@ -236,7 +236,7 @@ function reflow(text, margin) {
text.split(/\n/).forEach(function(line) {
var col = 0;
var reflowLine = '';
function flush(){
function flush() {
reflowLine = reflowLine.replace(/\s*$/, '');
lines.push(reflowLine);
reflowLine = '';

View file

@ -1,4 +1,4 @@
angular.service("$locale", function() {
var PLURAL_CATEGORY = {ZERO: "zero", ONE: "one", TWO: "two", FEW: "few", MANY: "many", OTHER: "other"};
return {"NUMBER_FORMATS":{"DECIMAL_SEP":".","GROUP_SEP":",","PATTERNS":[{"minInt":1,"minFrac":0,"macFrac":0,"posPre":"","posSuf":"","negPre":"-","negSuf":"","gSize":3,"lgSize":3,"maxFrac":3},{"minInt":1,"minFrac":2,"macFrac":0,"posPre":"\u00A4","posSuf":"","negPre":"(\u00A4","negSuf":")","gSize":3,"lgSize":3,"maxFrac":2}],"CURRENCY_SYM":"Br"},"pluralCat":function (n) { if (n == 0 || n == 1) { return PLURAL_CATEGORY.ONE; } return PLURAL_CATEGORY.OTHER;},"DATETIME_FORMATS":{"MONTH":["ጃንዩወሪ","ፌብሩወሪ","ማርች","ኤፕረል","ሜይ","ጁን","ጁላይ","ኦገስት","ሴፕቴምበር","ኦክተውበር","ኖቬምበር","ዲሴምበር"],"SHORTMONTH":["ጃንዩ","ፌብሩ","ማርች","ኤፕረ","ሜይ","ጁን","ጁላይ","ኦገስ","ሴፕቴ","ኦክተ","ኖቬም","ዲሴም"],"DAY":["እሑድ","ሰኞ","ማክሰኞ","ረቡዕ","ሐሙስ","ዓርብ","ቅዳሜ"],"SHORTDAY":["እሑድ","ሰኞ","ማክሰ","ረቡዕ","ሐሙስ","ዓርብ","ቅዳሜ"],"AMPMS":["ጡዋት","ከሳዓት"],"medium":"d MMM y h:mm:ss a","short":"dd/MM/yyyy h:mm a","fullDate":"EEEE, d MMMM y","longDate":"d MMMM y","mediumDate":"d MMM y","shortDate":"dd/MM/yyyy","mediumTime":"h:mm:ss a","shortTime":"h:mm a"},"id":"am-et"};
return {"NUMBER_FORMATS":{"DECIMAL_SEP":".","GROUP_SEP":",","PATTERNS":[{"minInt":1,"minFrac":0,"macFrac":0,"posPre":"","posSuf":"","negPre":"-","negSuf":"","gSize":3,"lgSize":3,"maxFrac":3},{"minInt":1,"minFrac":2,"macFrac":0,"posPre":"\u00A4","posSuf":"","negPre":"(\u00A4","negSuf":")","gSize":3,"lgSize":3,"maxFrac":2}],"CURRENCY_SYM":"Br"},"pluralCat":function(n) { if (n == 0 || n == 1) { return PLURAL_CATEGORY.ONE; } return PLURAL_CATEGORY.OTHER;},"DATETIME_FORMATS":{"MONTH":["ጃንዩወሪ","ፌብሩወሪ","ማርች","ኤፕረል","ሜይ","ጁን","ጁላይ","ኦገስት","ሴፕቴምበር","ኦክተውበር","ኖቬምበር","ዲሴምበር"],"SHORTMONTH":["ጃንዩ","ፌብሩ","ማርች","ኤፕረ","ሜይ","ጁን","ጁላይ","ኦገስ","ሴፕቴ","ኦክተ","ኖቬም","ዲሴም"],"DAY":["እሑድ","ሰኞ","ማክሰኞ","ረቡዕ","ሐሙስ","ዓርብ","ቅዳሜ"],"SHORTDAY":["እሑድ","ሰኞ","ማክሰ","ረቡዕ","ሐሙስ","ዓርብ","ቅዳሜ"],"AMPMS":["ጡዋት","ከሳዓት"],"medium":"d MMM y h:mm:ss a","short":"dd/MM/yyyy h:mm a","fullDate":"EEEE, d MMMM y","longDate":"d MMMM y","mediumDate":"d MMM y","shortDate":"dd/MM/yyyy","mediumTime":"h:mm:ss a","shortTime":"h:mm a"},"id":"am-et"};
});

View file

@ -1,20 +1,20 @@
describe('perf misc', function(){
it('operation speeds', function(){
describe('perf misc', function() {
it('operation speeds', function() {
perf(
function typeByTypeof(){ return typeof noop == 'function'; }, // WINNER
function typeByTypeof() { return typeof noop == 'function'; }, // WINNER
function typeByProperty() { return noop.apply && noop.call; },
function typeByConstructor() { return noop.constructor == Function; }
);
});
it('property access', function(){
it('property access', function() {
var name = 'value';
var none = 'x';
var scope = {};
perf(
function direct(){ return scope.value; }, // WINNER
function direct() { return scope.value; }, // WINNER
function byName() { return scope[name]; },
function undefinedDirect(){ return scope.x; },
function undefinedDirect() { return scope.x; },
function undefiendByName() { return scope[none]; }
);
});

View file

@ -14,7 +14,7 @@ if (typeof document.getAttribute == $undefined)
* @param {string} string String to be converted to lowercase.
* @returns {string} Lowercased string.
*/
var lowercase = function (string){ return isString(string) ? string.toLowerCase() : string; };
var lowercase = function(string){ return isString(string) ? string.toLowerCase() : string; };
/**
@ -26,17 +26,17 @@ var lowercase = function (string){ return isString(string) ? string.toLowerCase(
* @param {string} string String to be converted to uppercase.
* @returns {string} Uppercased string.
*/
var uppercase = function (string){ return isString(string) ? string.toUpperCase() : string; };
var uppercase = function(string){ return isString(string) ? string.toUpperCase() : string; };
var manualLowercase = function (s) {
var manualLowercase = function(s) {
return isString(s)
? s.replace(/[A-Z]/g, function (ch) {return fromCharCode(ch.charCodeAt(0) | 32); })
? s.replace(/[A-Z]/g, function(ch) {return fromCharCode(ch.charCodeAt(0) | 32); })
: s;
};
var manualUppercase = function (s) {
var manualUppercase = function(s) {
return isString(s)
? s.replace(/[a-z]/g, function (ch) {return fromCharCode(ch.charCodeAt(0) & ~32); })
? s.replace(/[a-z]/g, function(ch) {return fromCharCode(ch.charCodeAt(0) & ~32); })
: s;
};
@ -239,7 +239,7 @@ function extend(dst) {
function inherit(parent, extra) {
return extend(new (extend(function(){}, {prototype:parent}))(), extra);
return extend(new (extend(function() {}, {prototype:parent}))(), extra);
}
@ -279,11 +279,11 @@ function noop() {}
function identity($) {return $;}
function valueFn(value) {return function(){ return value; };}
function valueFn(value) {return function() { return value; };}
function extensionMap(angular, name, transform) {
var extPoint;
return angular[name] || (extPoint = angular[name] = function (name, fn, prop){
return angular[name] || (extPoint = angular[name] = function(name, fn, prop){
name = (transform || identity)(name);
if (isDefined(fn)) {
extPoint[name] = extend(fn, prop || {});
@ -604,12 +604,12 @@ function isLeafNode (node) {
* <doc:example>
* <doc:source>
<script>
function Ctrl(){
function Ctrl() {
this.master = {
salutation: 'Hello',
name: 'world'
};
this.copy = function (){
this.copy = function() {
this.form = angular.copy(this.master);
}
}
@ -709,7 +709,7 @@ function copy(source, destination){
* <doc:example>
* <doc:source>
<script>
function Ctrl(){
function Ctrl() {
this.master = {
salutation: 'Hello',
name: 'world'
@ -969,7 +969,7 @@ function angularJsConfig(document) {
return config;
}
function bindJQuery(){
function bindJQuery() {
// bind to jQuery if present;
jQuery = window.jQuery;
// reset to jQuery or default to us.

View file

@ -3,7 +3,7 @@
//////////////////////////////
// Browser
//////////////////////////////
var XHR = window.XMLHttpRequest || function () {
var XHR = window.XMLHttpRequest || function() {
try { return new ActiveXObject("Msxml2.XMLHTTP.6.0"); } catch (e1) {}
try { return new ActiveXObject("Msxml2.XMLHTTP.3.0"); } catch (e2) {}
try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e3) {}
@ -56,7 +56,7 @@ function Browser(window, document, body, XHR, $log, $sniffer) {
/**
* Executes the `fn` function (supports currying) and decrements the `outstandingRequestCallbacks`
* Executes the `fn` function(supports currying) and decrements the `outstandingRequestCallbacks`
* counter. If the counter reaches 0, all the `outstandingRequestCallbacks` are executed.
*/
function completeOutstandingRequest(fn) {
@ -322,7 +322,7 @@ function Browser(window, document, body, XHR, $log, $sniffer) {
*
* @returns {Object} Hash of all cookies (if called without any parameter)
*/
self.cookies = function (name, value) {
self.cookies = function(name, value) {
var cookieLength, cookieArray, cookie, i, keyValue, index;
if (name) {

View file

@ -44,7 +44,7 @@ function createInjector(factoryScope, factories, instanceCache) {
factoryScope = factoryScope || {};
injector.invoke = invoke;
injector.eager = function(){
injector.eager = function() {
forEach(factories, function(factory, name){
if (factory.$eager)
injector(name);

View file

@ -67,7 +67,7 @@ ResourceFactory.prototype = {
forEach(actions, function(action, name){
var isPostOrPut = action.method == 'POST' || action.method == 'PUT';
Resource[name] = function (a1, a2, a3, a4) {
Resource[name] = function(a1, a2, a3, a4) {
var params = {};
var data;
var success = noop;

View file

@ -50,7 +50,7 @@ function createScope(providers, instanceCache) {
expect(scope.greeting).toEqual(undefined);
scope.$watch('name', function(){
scope.$watch('name', function() {
this.greeting = this.salutation + ' ' + this.name + '!';
}); // initialize the watch
@ -584,7 +584,7 @@ Scope.prototype = {
event = {
name: name,
targetScope: scope,
cancel: function(){canceled = true;}
cancel: function() {canceled = true;}
},
listenerArgs = concat([event], arguments, 1),
i, length;

16
src/angular-mocks.js vendored
View file

@ -146,7 +146,7 @@ function MockBrowser() {
if (!expectation) {
throw new Error("Unexpected request for method '" + method + "' and url '" + url + "'.");
}
requests.push(function(){
requests.push(function() {
angular.forEach(expectation.headers, function(value, key){
if (headers[key] !== value) {
throw new Error("Missing HTTP request header: " + key + ": " + value);
@ -317,7 +317,7 @@ MockBrowser.prototype = {
* @description
* run all fns in pollFns
*/
poll: function poll(){
poll: function poll() {
angular.forEach(this.pollFns, function(pollFn){
pollFn();
});
@ -356,10 +356,10 @@ MockBrowser.prototype = {
}
},
addJs: function(){}
addJs: function() {}
};
angular.service('$browser', function(){
angular.service('$browser', function() {
return new MockBrowser();
});
@ -397,10 +397,10 @@ angular.service('$log', MockLogFactory);
function MockLogFactory() {
var $log = {
log: function(){ $log.log.logs.push(arguments); },
warn: function(){ $log.warn.logs.push(arguments); },
info: function(){ $log.info.logs.push(arguments); },
error: function(){ $log.error.logs.push(arguments); }
log: function() { $log.log.logs.push(arguments); },
warn: function() { $log.warn.logs.push(arguments); },
info: function() { $log.info.logs.push(arguments); },
error: function() { $log.error.logs.push(arguments); }
};
$log.log.logs = [];

View file

@ -1,5 +1,5 @@
jqLiteWrap(document).ready(function(){
jqLiteWrap(document).ready(function() {
angularInit(angularJsConfig(document), document);
});

View file

@ -104,7 +104,7 @@ var angularArray = {
<doc:example>
<doc:source>
<script>
function Ctrl(){
function Ctrl() {
this.books = ['Moby Dick', 'Great Gatsby', 'Romeo and Juliet'];
this.bookName = 'Romeo and Juliet';
}
@ -154,7 +154,7 @@ var angularArray = {
<doc:example>
<doc:source>
<script>
function Ctrl(){
function Ctrl() {
this.invoice = {
items:[ {
qty:10,
@ -400,7 +400,7 @@ var angularArray = {
case "object":
for (var key in expression) {
if (key == '$') {
(function(){
(function() {
var text = (''+expression[key]).toLowerCase();
if (!text) return;
predicates.push(function(value) {
@ -408,7 +408,7 @@ var angularArray = {
});
})();
} else {
(function(){
(function() {
var path = key;
var text = (''+expression[key]).toLowerCase();
if (!text) return;
@ -462,7 +462,7 @@ var angularArray = {
<doc:example>
<doc:source>
<script>
function Ctrl(){
function Ctrl() {
this.people = [];
}
</script>
@ -612,7 +612,7 @@ var angularArray = {
<doc:example>
<doc:source>
<script>
function Ctrl(){
function Ctrl() {
this.friends =
[{name:'John', phone:'555-1212', age:10},
{name:'Mary', phone:'555-9876', age:19},
@ -738,7 +738,7 @@ var angularArray = {
<doc:example>
<doc:source>
<script>
function Ctrl(){
function Ctrl() {
this.numbers = [1,2,3,4,5,6,7,8,9];
this.limit = 3;
}
@ -939,7 +939,7 @@ HashMap.prototype = {
* A map where multiple values can be added to the same key such that the form a queue.
* @returns {HashQueueMap}
*/
function HashQueueMap(){}
function HashQueueMap() {}
HashQueueMap.prototype = {
/**
* Same as array push, but using an array as the value for the hash

View file

@ -61,7 +61,7 @@
</div>
</doc:source>
<doc:scenario>
it('should check greeting', function(){
it('should check greeting', function() {
expect(binding('greeting')).toBe('Hello');
expect(binding('person')).toBe('World');
});
@ -115,10 +115,10 @@ angularDirective("ng:init", function(expression){
{type:'email', value:'john.smith@example.org'} ];
}
SettingsController.prototype = {
greet: function(){
greet: function() {
alert(this.name);
},
addContact: function(){
addContact: function() {
this.contacts.push({type:'email', value:'yourname@example.org'});
},
removeContact: function(contactToRemove) {
@ -149,7 +149,7 @@ angularDirective("ng:init", function(expression){
</div>
</doc:source>
<doc:scenario>
it('should check controller', function(){
it('should check controller', function() {
expect(element('.doc-example-live div>:input').val()).toBe('John Smith');
expect(element('.doc-example-live li:nth-child(1) input').val())
.toBe('408 555 1212');
@ -199,7 +199,7 @@ angularDirective("ng:controller", function(expression){
<doc:example>
<doc:source>
<script>
function Ctrl(){
function Ctrl() {
this.name = 'Whirled';
}
</script>
@ -209,7 +209,7 @@ angularDirective("ng:controller", function(expression){
</div>
</doc:source>
<doc:scenario>
it('should check ng:bind', function(){
it('should check ng:bind', function() {
expect(using('.doc-example-live').binding('name')).toBe('Whirled');
using('.doc-example-live').input('name').enter('world');
expect(using('.doc-example-live').binding('name')).toBe('world');
@ -326,7 +326,7 @@ function compileBindTemplate(template){
<doc:example>
<doc:source>
<script>
function Ctrl(){
function Ctrl() {
this.salutation = 'Hello';
this.name = 'World';
}
@ -338,7 +338,7 @@ function compileBindTemplate(template){
</div>
</doc:source>
<doc:scenario>
it('should check ng:bind', function(){
it('should check ng:bind', function() {
expect(using('.doc-example-live').binding('{{salutation}} {{name}}')).
toBe('Hello World!');
using('.doc-example-live').input('salutation').enter('Greetings');
@ -402,7 +402,7 @@ angularDirective("ng:bind-template", function(expression, element){
<doc:example>
<doc:source>
<script>
function Ctrl(){
function Ctrl() {
this.query = 'AngularJS';
}
</script>
@ -413,7 +413,7 @@ angularDirective("ng:bind-template", function(expression, element){
</div>
</doc:source>
<doc:scenario>
it('should check ng:bind-attr', function(){
it('should check ng:bind-attr', function() {
expect(using('.doc-example-live').element('a').attr('href')).
toBe('http://www.google.com/search?q=AngularJS');
using('.doc-example-live').input('query').enter('google');
@ -471,7 +471,7 @@ angularDirective("ng:bind-attr", function(expression){
count: {{count}}
</doc:source>
<doc:scenario>
it('should check ng:click', function(){
it('should check ng:click', function() {
expect(binding('count')).toBe('0');
element('.doc-example-live :button').click();
expect(binding('count')).toBe('1');
@ -516,10 +516,10 @@ angularDirective("ng:click", function(expression, element){
<doc:example>
<doc:source>
<script>
function Ctrl(){
function Ctrl() {
this.list = [];
this.text = 'hello';
this.submit = function(){
this.submit = function() {
this.list.push(this.text);
this.text = '';
};
@ -533,7 +533,7 @@ angularDirective("ng:click", function(expression, element){
</form>
</doc:source>
<doc:scenario>
it('should check ng:submit', function(){
it('should check ng:submit', function() {
expect(binding('list')).toBe('list=[]');
element('.doc-example-live #submit').click();
expect(binding('list')).toBe('list=["hello"]');
@ -592,7 +592,7 @@ function ngClass(selector) {
<span ng:class="myVar">Sample Text &nbsp;&nbsp;&nbsp;&nbsp;</span>
</doc:source>
<doc:scenario>
it('should check ng:class', function(){
it('should check ng:class', function() {
expect(element('.doc-example-live span').prop('className')).not().
toMatch(/ng-input-indicator-wait/);
@ -609,7 +609,7 @@ function ngClass(selector) {
</doc:scenario>
</doc:example>
*/
angularDirective("ng:class", ngClass(function(){return true;}));
angularDirective("ng:class", ngClass(function() {return true;}));
/**
* @workInProgress
@ -641,7 +641,7 @@ angularDirective("ng:class", ngClass(function(){return true;}));
</ol>
</doc:source>
<doc:scenario>
it('should check ng:class-odd and ng:class-even', function(){
it('should check ng:class-odd and ng:class-even', function() {
expect(element('.doc-example-live li:first span').prop('className')).
toMatch(/ng-format-negative/);
expect(element('.doc-example-live li:last span').prop('className')).
@ -682,7 +682,7 @@ angularDirective("ng:class-odd", ngClass(function(i){return i % 2 === 0;}));
</ol>
</doc:source>
<doc:scenario>
it('should check ng:class-odd and ng:class-even', function(){
it('should check ng:class-odd and ng:class-even', function() {
expect(element('.doc-example-live li:first span').prop('className')).
toMatch(/ng-format-negative/);
expect(element('.doc-example-live li:last span').prop('className')).
@ -714,7 +714,7 @@ angularDirective("ng:class-even", ngClass(function(i){return i % 2 === 1;}));
Hide: <span ng:hide="checked">I hide when your checkbox is checked.</span>
</doc:source>
<doc:scenario>
it('should check ng:show / ng:hide', function(){
it('should check ng:show / ng:hide', function() {
expect(element('.doc-example-live span:first:hidden').count()).toEqual(1);
expect(element('.doc-example-live span:last:visible').count()).toEqual(1);
@ -755,7 +755,7 @@ angularDirective("ng:show", function(expression, element){
Hide: <span ng:hide="checked">I hide when you checkbox is checked?</span>
</doc:source>
<doc:scenario>
it('should check ng:show / ng:hide', function(){
it('should check ng:show / ng:hide', function() {
expect(element('.doc-example-live span:first:hidden').count()).toEqual(1);
expect(element('.doc-example-live span:last:visible').count()).toEqual(1);
@ -798,7 +798,7 @@ angularDirective("ng:hide", function(expression, element){
<pre>myStyle={{myStyle}}</pre>
</doc:source>
<doc:scenario>
it('should check ng:style', function(){
it('should check ng:style', function() {
expect(element('.doc-example-live span').css('color')).toBe('rgb(0, 0, 0)');
element('.doc-example-live :button[value=set]').click();
expect(element('.doc-example-live span').css('color')).toBe('rgb(255, 0, 0)');

View file

@ -49,7 +49,7 @@
<doc:example>
<doc:source>
<script>
function Ctrl(){
function Ctrl() {
this.amount = 1234.56;
}
</script>
@ -60,11 +60,11 @@
</div>
</doc:source>
<doc:scenario>
it('should init with 1234.56', function(){
it('should init with 1234.56', function() {
expect(binding('amount | currency')).toBe('$1,234.56');
expect(binding('amount | currency:"USD$"')).toBe('USD$1,234.56');
});
it('should update', function(){
it('should update', function() {
input('amount').enter('-1234');
expect(binding('amount | currency')).toBe('($1,234.00)');
expect(binding('amount | currency:"USD$"')).toBe('(USD$1,234.00)');
@ -101,7 +101,7 @@ angularFilter.currency = function(amount, currencySymbol){
<doc:example>
<doc:source>
<script>
function Ctrl(){
function Ctrl() {
this.val = 1234.56789;
}
</script>
@ -113,13 +113,13 @@ angularFilter.currency = function(amount, currencySymbol){
</div>
</doc:source>
<doc:scenario>
it('should format numbers', function(){
it('should format numbers', function() {
expect(binding('val | number')).toBe('1,234.568');
expect(binding('val | number:0')).toBe('1,235');
expect(binding('-val | number:4')).toBe('-1,234.5679');
});
it('should update', function(){
it('should update', function() {
input('val').enter('3374.333');
expect(binding('val | number')).toBe('3,374.333');
expect(binding('val | number:0')).toBe('3,374');
@ -336,7 +336,7 @@ var GET_TIME_ZONE = /[A-Z]{3}(?![+\-])/,
{{'1288323623006' | date:'MM/dd/yyyy @ h:mma'}}<br/>
</doc:source>
<doc:scenario>
it('should format date', function(){
it('should format date', function() {
expect(binding("1288323623006 | date:'medium'")).
toMatch(/Oct 2\d, 2010 \d{1,2}:\d{2}:\d{2} (AM|PM)/);
expect(binding("1288323623006 | date:'yyyy-MM-dd HH:mm:ss Z'")).
@ -477,7 +477,7 @@ angularFilter.uppercase = uppercase;
<doc:example>
<doc:source>
<script>
function Ctrl(){
function Ctrl() {
this.snippet =
'<p style="color:blue">an html\n' +
'<em onmouseover="this.textContent=\'PWN3D!\'">click here</em>\n' +
@ -515,7 +515,7 @@ angularFilter.uppercase = uppercase;
</div>
</doc:source>
<doc:scenario>
it('should sanitize the html snippet ', function(){
it('should sanitize the html snippet ', function() {
expect(using('#html-filter').binding('snippet | html')).
toBe('<p>an html\n<em>click here</em>\nsnippet</p>');
});
@ -534,7 +534,7 @@ angularFilter.uppercase = uppercase;
"snippet</p>");
});
it('should update', function(){
it('should update', function() {
input('snippet').enter('new <b>text</b>');
expect(using('#html-filter').binding('snippet | html')).toBe('new <b>text</b>');
expect(using('#escaped-html').binding('snippet')).toBe("new &lt;b&gt;text&lt;/b&gt;");
@ -565,7 +565,7 @@ angularFilter.html = function(html, option){
<doc:example>
<doc:source>
<script>
function Ctrl(){
function Ctrl() {
this.snippet =
'Pretty text with some links:\n'+
'http://angularjs.org/,\n'+
@ -599,7 +599,7 @@ angularFilter.html = function(html, option){
</table>
</doc:source>
<doc:scenario>
it('should linkify the snippet with urls', function(){
it('should linkify the snippet with urls', function() {
expect(using('#linky-filter').binding('snippet | linky')).
toBe('Pretty text with some links:\n' +
'<a href="http://angularjs.org/">http://angularjs.org/</a>,\n' +
@ -617,7 +617,7 @@ angularFilter.html = function(html, option){
"and one more: ftp://127.0.0.1/.");
});
it('should update', function(){
it('should update', function() {
input('snippet').enter('new http://link.');
expect(using('#linky-filter').binding('snippet | linky')).
toBe('new <a href="http://link">http://link</a>.');

View file

@ -459,7 +459,7 @@ forEach({
if (!eventHandler) {
bind[type] = eventHandler = function(event) {
if (!event.preventDefault) {
event.preventDefault = function(){
event.preventDefault = function() {
event.returnValue = false; //ie
};
}

View file

@ -142,7 +142,7 @@ function lex(text, parseStringsForObjects){
}
number = 1 * number;
tokens.push({index:start, text:number, json:true,
fn:function(){return number;}});
fn:function() {return number;}});
}
function readIdent() {
var ident = "";
@ -200,7 +200,7 @@ function lex(text, parseStringsForObjects){
} else if (ch == quote) {
index++;
tokens.push({index:start, text:rawString, string:string, json:true,
fn:function(){
fn:function() {
return (string.length == dateParseLength)
? angular['String']['toDate'](string)
: string;
@ -239,7 +239,7 @@ function parser(text, json){
filterChain =
functionIdent =
pipeFunction =
function (){ throwError("is not valid json", {text:text, index:0}); };
function() { throwError("is not valid json", {text:text, index:0}); };
}
//TODO: Shouldn't all of the public methods have assertAllConsumed?
//TODO: I think these should be public as part of the parser api instead of scope.$eval().
@ -251,7 +251,7 @@ function parser(text, json){
};
function assertConsumed(fn) {
return function(){
return function() {
var value = fn();
if (tokens.length !== 0) {
throwError("is an unexpected token", tokens[0]);
@ -320,7 +320,7 @@ function parser(text, json){
return tokens.length > 0;
}
function statements(){
function statements() {
var statements = [];
while(true) {
if (tokens.length > 0 && !peek('}', ')', ';', ']'))
@ -330,7 +330,7 @@ function parser(text, json){
// TODO(size): maybe we should not support multiple statements?
return statements.length == 1
? statements[0]
: function (self){
: function(self){
var value;
for ( var i = 0; i < statements.length; i++) {
var statement = statements[i];
@ -343,7 +343,7 @@ function parser(text, json){
}
}
function _filterChain(){
function _filterChain() {
var left = expression();
var token;
while(true) {
@ -355,7 +355,7 @@ function parser(text, json){
}
}
function filter(){
function filter() {
return pipeFunction(angularFilter);
}
@ -374,18 +374,18 @@ function parser(text, json){
}
return fn.apply(self, args);
};
return function(){
return function() {
return fnInvoke;
};
}
}
}
function expression(){
function expression() {
return assignment();
}
function _assignment(){
function _assignment() {
var left = logicalOR();
var right;
var token;
@ -403,7 +403,7 @@ function parser(text, json){
}
}
function logicalOR(){
function logicalOR() {
var left = logicalAND();
var token;
while(true) {
@ -415,7 +415,7 @@ function parser(text, json){
}
}
function logicalAND(){
function logicalAND() {
var left = equality();
var token;
if ((token = expect('&&'))) {
@ -424,7 +424,7 @@ function parser(text, json){
return left;
}
function equality(){
function equality() {
var left = relational();
var token;
if ((token = expect('==','!='))) {
@ -433,7 +433,7 @@ function parser(text, json){
return left;
}
function relational(){
function relational() {
var left = additive();
var token;
if ((token = expect('<', '>', '<=', '>='))) {
@ -442,7 +442,7 @@ function parser(text, json){
return left;
}
function additive(){
function additive() {
var left = multiplicative();
var token;
while ((token = expect('+','-'))) {
@ -451,7 +451,7 @@ function parser(text, json){
return left;
}
function multiplicative(){
function multiplicative() {
var left = unary();
var token;
while ((token = expect('*','/','%'))) {
@ -460,7 +460,7 @@ function parser(text, json){
return left;
}
function unary(){
function unary() {
var token;
if (expect('+')) {
return primary();
@ -524,7 +524,7 @@ function parser(text, json){
function _fieldAccess(object) {
var field = expect().text;
var getter = getterFn(field);
return extend(function (self){
return extend(function(self){
return getter(object(self));
}, {
assign:function(self, value){
@ -537,7 +537,7 @@ function parser(text, json){
var indexFn = expression();
consume(']');
return extend(
function (self){
function(self){
var o = obj(self);
var i = indexFn(self);
return (o) ? o[i] : undefined;
@ -556,7 +556,7 @@ function parser(text, json){
} while (expect(','));
}
consume(')');
return function (self){
return function(self){
var args = [];
for ( var i = 0; i < argsFn.length; i++) {
args.push(argsFn[i](self));
@ -578,7 +578,7 @@ function parser(text, json){
} while (expect(','));
}
consume(']');
return function (self){
return function(self){
var array = [];
for ( var i = 0; i < elementFns.length; i++) {
array.push(elementFns[i](self));
@ -599,7 +599,7 @@ function parser(text, json){
} while (expect(','));
}
consume('}');
return function (self){
return function(self){
var object = {};
for ( var i = 0; i < keyValues.length; i++) {
var keyValue = keyValues[i];
@ -721,7 +721,7 @@ function getterFn(path) {
});
code += 'return s;';
fn = Function('s', code);
fn["toString"] = function(){ return code; };
fn["toString"] = function() { return code; };
return getterFnCache[path] = fn;
}

View file

@ -67,7 +67,7 @@ var validAttrs = extend({}, uriAttrs, makeMap(
*/
function htmlParser( html, handler ) {
var index, chars, match, stack = [], last = html;
stack.last = function(){ return stack[ stack.length - 1 ]; };
stack.last = function() { return stack[ stack.length - 1 ]; };
while ( html ) {
chars = true;

View file

@ -96,7 +96,7 @@ angular.scenario.matcher = angular.scenario.matcher || function(name, fn) {
*
* @param {Object=} config Config options
*/
angular.scenario.setUpAndRun = function (config) {
angular.scenario.setUpAndRun = function(config) {
var href = window.location.href;
var body = _jQuery(document.body);
var output = [];

View file

@ -1,7 +1,7 @@
'use strict';
(function(previousOnLoad){
var prefix = (function(){
var prefix = (function() {
var filename = /(.*\/)angular-bootstrap.js(#(.*))?/;
var scripts = document.getElementsByTagName("script");
for(var j = 0; j < scripts.length; j++) {
@ -21,7 +21,7 @@
document.write('<link rel="stylesheet" type="text/css" href="' + prefix + path + '"/>');
}
window.onload = function(){
window.onload = function() {
try {
if (previousOnLoad) previousOnLoad();
} catch(e) {}

View file

@ -45,7 +45,7 @@ angularServiceInject('$cookies', function($browser) {
/**
* Pushes all the cookies from the service to the browser and verifies if all cookies were stored.
*/
function push(){
function push() {
var name,
value,
browserCookies,

View file

@ -25,7 +25,7 @@
<doc:example>
<doc:source>
<script>
function EditorCntl(){
function EditorCntl() {
this.html = '<b>Hello</b> <i>World</i>!';
}
@ -33,7 +33,7 @@
var self = this;
var htmlFilter = angular.filter('html');
this.$parseModel = function(){
this.$parseModel = function() {
// need to protect for script injection
try {
this.$viewValue = htmlFilter(this.$modelValue || '').get();
@ -47,18 +47,18 @@
}
}
this.$render = function(){
this.$render = function() {
element.html(this.$viewValue);
}
element.bind('keyup', function(){
self.$apply(function(){
element.bind('keyup', function() {
self.$apply(function() {
self.$emit('$viewChange', element.html());
});
});
}
angular.directive('ng:contenteditable', function(){
angular.directive('ng:contenteditable', function() {
function linkFn($formFactory, element) {
var exp = element.attr('ng:contenteditable'),
form = $formFactory.forElement(element),
@ -70,7 +70,7 @@
controller: HTMLEditorWidget,
controllerArgs: [element]});
// if the element is destroyed, then we need to notify the form.
element.bind('$destroy', function(){
element.bind('$destroy', function() {
widget.$destroy();
});
}
@ -88,7 +88,7 @@
</form>
</doc:source>
<doc:scenario>
it('should enter invalid HTML', function(){
it('should enter invalid HTML', function() {
expect(element('form[name=editorForm]').prop('className')).toMatch(/ng-valid/);
input('html').enter('<');
expect(element('form[name=editorForm]').prop('className')).toMatch(/ng-invalid/);
@ -96,7 +96,7 @@
</doc:scenario>
</doc:example>
*/
angularServiceInject('$formFactory', function(){
angularServiceInject('$formFactory', function() {
/**
@ -123,7 +123,7 @@ angularServiceInject('$formFactory', function(){
* {@link angular.widget.form form} element.
* @param {Element} element The element where the search for form should initiate.
*/
formFactory.forElement = function (element) {
formFactory.forElement = function(element) {
return element.inheritedData('$form') || formFactory.rootForm;
};
return formFactory;
@ -225,7 +225,7 @@ function propertiesUpdate(widget) {
* @param {*} viewValue The new value for the view which will be assigned to `widget.$viewValue`.
*/
function FormController(){
function FormController() {
var form = this,
$error = form.$error = {};
@ -361,7 +361,7 @@ FormController.prototype.$createWidget = function(params) {
// Set the state to something we know will change to get the process going.
widget.$modelValue = Number.NaN;
// watch for scope changes and update the view appropriately
modelScope.$watch(scopeGet, function (scope, value) {
modelScope.$watch(scopeGet, function(scope, value) {
if (!equals(widget.$modelValue, value)) {
widget.$modelValue = value;
widget.$parseModel ? widget.$parseModel() : (widget.$viewValue = value);

View file

@ -87,7 +87,7 @@ angularServiceInject("$log", $logFactory = function($window){
var console = $window.console || {};
var logFn = console[type] || console.log || noop;
if (logFn.apply) {
return function(){
return function() {
var args = [];
forEach(arguments, function(arg){
args.push(formatError(arg));

View file

@ -65,7 +65,7 @@
* update, delete) on server-side data like this:
* <pre>
var User = $resource('/user/:userId', {userId:'@id'});
var user = User.get({userId:123}, function(){
var user = User.get({userId:123}, function() {
user.abc = true;
user.$save();
});
@ -136,7 +136,7 @@
<pre>
var User = $resource('/user/:userId', {userId:'@id'});
var user = User.get({userId:123}, function(){
var user = User.get({userId:123}, function() {
user.abc = true;
user.$save();
});

View file

@ -188,7 +188,7 @@ angularServiceInject('$route', function($location, $routeParams) {
* @description
* Adds a new route definition to the `$route` service.
*/
when: function (path, route) {
when: function(path, route) {
var routeDef = routes[path];
if (!routeDef) routeDef = routes[path] = {reloadOnSearch: true};
if (route) extend(routeDef, route); // TODO(im): what the heck? merge two route definitions?

View file

@ -26,6 +26,6 @@
* $routeParams ==> {chapterId:1, sectionId:2, search:'moby'}
* </pre>
*/
angularService('$routeParams', function(){
angularService('$routeParams', function() {
return {};
});

View file

@ -83,6 +83,6 @@ angularServiceInject('$xhr.bulk', function($xhr, $error, $log){
}
});
};
this.$watch(function(){ bulkXHR.flush(); });
this.$watch(function() { bulkXHR.flush(); });
return bulkXHR;
}, ['$xhr', '$xhr.error', '$log']);

View file

@ -205,7 +205,7 @@ angularServiceInject('$xhr', function($browser, $error, $log){
response = fromJson(response, true);
}
}
rootScope.$apply(function(){
rootScope.$apply(function() {
if (200 <= code && code < 300) {
success(code, response);
} else if (isFunction(error)) {

View file

@ -24,7 +24,7 @@
<doc:example>
<doc:source>
<script>
function Ctrl(){
function Ctrl() {
this.text = 'guest';
}
</script>
@ -41,12 +41,12 @@
</div>
</doc:source>
<doc:scenario>
it('should initialize to model', function(){
it('should initialize to model', function() {
expect(binding('text')).toEqual('guest');
expect(binding('myForm.input.$valid')).toEqual('true');
});
it('should be invalid if empty', function(){
it('should be invalid if empty', function() {
input('text').enter('');
expect(binding('text')).toEqual('');
expect(binding('myForm.input.$valid')).toEqual('false');

View file

@ -25,7 +25,7 @@ var INTEGER_REGEXP = /^\s*(\-|\+)?\d+\s*$/;
<doc:example>
<doc:source>
<script>
function Ctrl(){
function Ctrl() {
this.text = 'guest';
this.word = /^\w*$/;
}
@ -87,7 +87,7 @@ var INTEGER_REGEXP = /^\s*(\-|\+)?\d+\s*$/;
<doc:example>
<doc:source>
<script>
function Ctrl(){
function Ctrl() {
this.text = 'me@example.com';
}
</script>
@ -155,7 +155,7 @@ angularInputType('email', function() {
<doc:example>
<doc:source>
<script>
function Ctrl(){
function Ctrl() {
this.text = 'http://google.com';
}
</script>
@ -222,7 +222,7 @@ angularInputType('url', function() {
<doc:example>
<doc:source>
<script>
function Ctrl(){
function Ctrl() {
this.names = ['igor', 'misko', 'vojta'];
}
</script>
@ -295,7 +295,7 @@ angularInputType('list', function() {
<doc:example>
<doc:source>
<script>
function Ctrl(){
function Ctrl() {
this.value = 12;
}
</script>
@ -359,7 +359,7 @@ angularInputType('number', numericRegexpInputType(NUMBER_REGEXP, 'NUMBER'));
<doc:example>
<doc:source>
<script>
function Ctrl(){
function Ctrl() {
this.value = 12;
}
</script>
@ -418,7 +418,7 @@ angularInputType('integer', numericRegexpInputType(INTEGER_REGEXP, 'INTEGER'));
<doc:example>
<doc:source>
<script>
function Ctrl(){
function Ctrl() {
this.value1 = true;
this.value2 = 'YES'
}
@ -446,7 +446,7 @@ angularInputType('integer', numericRegexpInputType(INTEGER_REGEXP, 'INTEGER'));
</doc:scenario>
</doc:example>
*/
angularInputType('checkbox', function (inputElement) {
angularInputType('checkbox', function(inputElement) {
var widget = this,
trueValue = inputElement.attr('true-value'),
falseValue = inputElement.attr('false-value');
@ -490,7 +490,7 @@ angularInputType('checkbox', function (inputElement) {
<doc:example>
<doc:source>
<script>
function Ctrl(){
function Ctrl() {
this.color = 'blue';
}
</script>
@ -604,7 +604,7 @@ var HTML5_INPUTS_TYPES = makeMap(
<doc:example>
<doc:source>
<script>
function Ctrl(){
function Ctrl() {
this.text = 'guest';
}
</script>
@ -635,7 +635,7 @@ var HTML5_INPUTS_TYPES = makeMap(
</doc:scenario>
</doc:example>
*/
angularWidget('input', function (inputElement){
angularWidget('input', function(inputElement){
this.directives(true);
this.descend(true);
var modelExp = inputElement.attr('ng:model');
@ -715,7 +715,7 @@ angularWidget('input', function (inputElement){
}
});
forEach(['valid', 'invalid', 'pristine', 'dirty'], function (name) {
forEach(['valid', 'invalid', 'pristine', 'dirty'], function(name) {
widget.$watch('$' + name, function(scope, value) {
inputElement[value ? 'addClass' : 'removeClass']('ng-' + name);
}

View file

@ -66,7 +66,7 @@
<doc:example>
<doc:source>
<script>
function MyCntrl(){
function MyCntrl() {
this.colors = [
{name:'black', shade:'dark'},
{name:'white', shade:'light'},
@ -112,7 +112,7 @@
</div>
</doc:source>
<doc:scenario>
it('should check ng:options', function(){
it('should check ng:options', function() {
expect(binding('color')).toMatch('red');
select('color').option('0');
expect(binding('color')).toMatch('black');
@ -128,7 +128,7 @@
var NG_OPTIONS_REGEXP = /^\s*(.*?)(?:\s+as\s+(.*?))?(?:\s+group\s+by\s+(.*))?\s+for\s+(?:([\$\w][\$\w\d]*)|(?:\(\s*([\$\w][\$\w\d]*)\s*,\s*([\$\w][\$\w\d]*)\s*\)))\s+in\s+(.*)$/;
angularWidget('select', function (element){
angularWidget('select', function(element){
this.directives(true);
this.descend(true);
return element.attr('ng:model') && annotate('$formFactory', function($formFactory, selectElement){
@ -145,7 +145,7 @@ angularWidget('select', function (element){
alias: selectElement.attr('name'),
controller: optionsExp ? Options : (multiple ? Multiple : Single)});
selectElement.bind('$destroy', function(){ widget.$destroy(); });
selectElement.bind('$destroy', function() { widget.$destroy(); });
widget.$pristine = !(widget.$dirty = false);
@ -153,7 +153,7 @@ angularWidget('select', function (element){
watchElementProperty(modelScope, widget, 'readonly', selectElement);
watchElementProperty(modelScope, widget, 'disabled', selectElement);
widget.$on('$validate', function(){
widget.$on('$validate', function() {
var valid = !widget.$required || !!widget.$modelValue;
if (valid && multiple && widget.$required) valid = !!widget.$modelValue.length;
if (valid !== !widget.$error.REQUIRED) {
@ -161,11 +161,11 @@ angularWidget('select', function (element){
}
});
widget.$on('$viewChange', function(){
widget.$on('$viewChange', function() {
widget.$pristine = !(widget.$dirty = true);
});
forEach(['valid', 'invalid', 'pristine', 'dirty'], function (name) {
forEach(['valid', 'invalid', 'pristine', 'dirty'], function(name) {
widget.$watch('$' + name, function(scope, value) {
selectElement[value ? 'addClass' : 'removeClass']('ng-' + name);
});
@ -173,18 +173,18 @@ angularWidget('select', function (element){
////////////////////////////
function Multiple(){
function Multiple() {
var widget = this;
this.$render = function(){
this.$render = function() {
var items = new HashMap(this.$viewValue);
forEach(selectElement.children(), function(option){
option.selected = isDefined(items.get(option.value));
});
};
selectElement.bind('change', function (){
widget.$apply(function(){
selectElement.bind('change', function() {
widget.$apply(function() {
var array = [];
forEach(selectElement.children(), function(option){
if (option.selected) {
@ -197,15 +197,15 @@ angularWidget('select', function (element){
}
function Single(){
function Single() {
var widget = this;
widget.$render = function(){
widget.$render = function() {
selectElement.val(widget.$viewValue);
};
selectElement.bind('change', function(){
widget.$apply(function(){
selectElement.bind('change', function() {
widget.$apply(function() {
widget.$emit('$viewChange', selectElement.val());
});
});
@ -213,7 +213,7 @@ angularWidget('select', function (element){
widget.$viewValue = selectElement.val();
}
function Options(){
function Options() {
var widget = this,
match;
@ -249,8 +249,8 @@ angularWidget('select', function (element){
});
selectElement.html(''); // clear contents
selectElement.bind('change', function(){
widgetScope.$apply(function(){
selectElement.bind('change', function() {
widgetScope.$apply(function() {
var optionGroup,
collection = valuesFn(modelScope) || [],
key = selectElement.val(),

View file

@ -49,7 +49,7 @@
<doc:example>
<doc:source jsfiddle="false">
<script>
function Ctrl(){
function Ctrl() {
this.templates =
[ { name: 'template1.html', url: 'examples/ng-include/template1.html'}
, { name: 'template2.html', url: 'examples/ng-include/template2.html'} ];
@ -66,16 +66,16 @@
</div>
</doc:source>
<doc:scenario>
it('should load template1.html', function(){
it('should load template1.html', function() {
expect(element('.doc-example-live .ng-include').text()).
toBe('Content of template1.html\n');
});
it('should load template2.html', function(){
it('should load template2.html', function() {
select('template').option('1');
expect(element('.doc-example-live .ng-include').text()).
toBe('Content of template2.html\n');
});
it('should change to blank', function(){
it('should change to blank', function() {
select('template').option('');
expect(element('.doc-example-live .ng-include').text()).toEqual('');
});
@ -99,7 +99,7 @@ angularWidget('ng:include', function(element){
childScope,
oldScope;
function incrementChange(){ changeCounter++;}
function incrementChange() { changeCounter++;}
this.$watch(srcExp, incrementChange);
this.$watch(function(scope){
var newScope = scope.$eval(scopeExp);
@ -108,7 +108,7 @@ angularWidget('ng:include', function(element){
incrementChange();
}
});
this.$watch(function(){return changeCounter;}, function(scope) {
this.$watch(function() {return changeCounter;}, function(scope) {
var src = scope.$eval(srcExp),
useScope = scope.$eval(scopeExp);
@ -161,7 +161,7 @@ angularWidget('ng:include', function(element){
<doc:example>
<doc:source>
<script>
function Ctrl(){
function Ctrl() {
this.items = ['settings', 'home', 'other'];
this.selection = this.items[0];
}
@ -179,21 +179,21 @@ angularWidget('ng:include', function(element){
</div>
</doc:source>
<doc:scenario>
it('should start in settings', function(){
it('should start in settings', function() {
expect(element('.doc-example-live ng\\:switch').text()).toEqual('Settings Div');
});
it('should change to home', function(){
it('should change to home', function() {
select('selection').option('home');
expect(element('.doc-example-live ng\\:switch').text()).toEqual('Home Span');
});
it('should select deafault', function(){
it('should select deafault', function() {
select('selection').option('other');
expect(element('.doc-example-live ng\\:switch').text()).toEqual('default');
});
</doc:scenario>
</doc:example>
*/
angularWidget('ng:switch', function (element) {
angularWidget('ng:switch', function(element) {
var compiler = this,
watchExpr = element.attr("on"),
changeExpr = element.attr('change'),
@ -234,7 +234,7 @@ angularWidget('ng:switch', function (element) {
}
});
this.$watch(function(){return changeCounter;}, function() {
this.$watch(function() {return changeCounter;}, function() {
element.html('');
if (selectedTemplate) {
selectedTemplate(childScope, function(caseElement) {
@ -325,7 +325,7 @@ angularWidget('a', function() {
</div>
</doc:source>
<doc:scenario>
it('should check ng:repeat', function(){
it('should check ng:repeat', function() {
var r = using('.doc-example-live').repeater('ul li');
expect(r.count()).toBe(2);
expect(r.row(0)).toEqual(["1","John","25"]);
@ -467,7 +467,7 @@ angularWidget('@ng:repeat', function(expression, element){
<div ng:non-bindable>Ignored: {{1 + 2}}</div>
</doc:source>
<doc:scenario>
it('should check ng:non-bindable', function(){
it('should check ng:non-bindable', function() {
expect(using('.doc-example-live').binding('1 + 2')).toBe('3');
expect(using('.doc-example-live').element('div:last').text()).
toMatch(/1 \+ 2/);
@ -517,8 +517,8 @@ angularWidget("@ng:non-bindable", noop);
};
MyCtrl.$inject = ['$route'];
function BootstrapCtrl(){}
function OverviewCtrl(){}
function BootstrapCtrl() {}
function OverviewCtrl() {}
</script>
<div ng:controller="MyCtrl">
<a href="overview">overview</a> |
@ -533,7 +533,7 @@ angularWidget("@ng:non-bindable", noop);
</div>
</doc:source>
<doc:scenario>
it('should load templates', function(){
it('should load templates', function() {
element('.doc-example-live a:contains(overview)').click();
expect(element('.doc-example-live ng\\:view').text()).toMatch(/Developer Guide: Overview/);
@ -552,11 +552,11 @@ angularWidget('ng:view', function(element) {
var template;
var changeCounter = 0;
this.$on('$afterRouteChange', function(){
this.$on('$afterRouteChange', function() {
changeCounter++;
});
this.$watch(function(){return changeCounter;}, function() {
this.$watch(function() {return changeCounter;}, function() {
var template = $route.current && $route.current.template;
if (template) {
//xhr's callback must be async, see commit history for more info
@ -669,7 +669,7 @@ angularWidget('ng:view', function(element) {
<doc:example>
<doc:source>
<script>
function Ctrl(){
function Ctrl() {
this.person1 = 'Igor';
this.person2 = 'Misko';
this.personCount = 1;
@ -700,7 +700,7 @@ angularWidget('ng:view', function(element) {
</div>
</doc:source>
<doc:scenario>
it('should show correct pluralized string', function(){
it('should show correct pluralized string', function() {
expect(element('.doc-example-live .ng-pluralize:first').text()).
toBe('1 person is viewing.');
expect(element('.doc-example-live .ng-pluralize:last').text()).
@ -731,7 +731,7 @@ angularWidget('ng:view', function(element) {
toBe('Igor, Misko and 2 other people are viewing.');
});
it('should show data-binded names', function(){
it('should show data-binded names', function() {
using('.doc-example-live').input('personCount').enter('4');
expect(element('.doc-example-live .ng-pluralize:last').text()).
toBe('Igor, Misko and 2 other people are viewing.');

View file

@ -1,8 +1,8 @@
'use strict';
describe('angular', function(){
describe('case', function(){
it('should change case', function(){
describe('angular', function() {
describe('case', function() {
it('should change case', function() {
expect(lowercase('ABC90')).toEqual('abc90');
expect(manualLowercase('ABC90')).toEqual('abc90');
expect(uppercase('abc90')).toEqual('ABC90');
@ -10,22 +10,22 @@ describe('angular', function(){
});
});
describe("copy", function(){
it("should return same object", function (){
describe("copy", function() {
it("should return same object", function () {
var obj = {};
var arr = [];
expect(copy({}, obj)).toBe(obj);
expect(copy([], arr)).toBe(arr);
});
it("should copy Date", function(){
it("should copy Date", function() {
var date = new Date(123);
expect(copy(date) instanceof Date).toBeTruthy();
expect(copy(date).getTime()).toEqual(123);
expect(copy(date) === date).toBeFalsy();
});
it("should copy array", function(){
it("should copy array", function() {
var src = [1, {name:"value"}];
var dst = [{key:"v"}];
expect(copy(src, dst)).toBe(dst);
@ -41,7 +41,7 @@ describe('angular', function(){
expect(dst).toEqual([]);
});
it("should copy object", function(){
it("should copy object", function() {
var src = {a:{name:"value"}};
var dst = {b:{key:"v"}};
expect(copy(src, dst)).toBe(dst);
@ -50,7 +50,7 @@ describe('angular', function(){
expect(dst.a).not.toBe(src.a);
});
it("should copy primitives", function(){
it("should copy primitives", function() {
expect(copy(null)).toEqual(null);
expect(copy('')).toBe('');
expect(copy('lala')).toBe('lala');
@ -59,8 +59,8 @@ describe('angular', function(){
});
});
describe('equals', function(){
it('should return true if same object', function(){
describe('equals', function() {
it('should return true if same object', function() {
var o = {};
expect(equals(o, o)).toEqual(true);
expect(equals(o, {})).toEqual(true);
@ -68,7 +68,7 @@ describe('angular', function(){
expect(equals(1, '2')).toEqual(false);
});
it('should recurse into object', function(){
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);
@ -79,13 +79,13 @@ describe('angular', function(){
expect(equals(['misko'], ['misko', 'adam'])).toEqual(false);
});
it('should ignore $ member variables', function(){
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);
});
it('should ignore functions', function(){
it('should ignore functions', function() {
expect(equals({func: function() {}}, {bar: function() {}})).toEqual(true);
});
@ -169,8 +169,8 @@ describe('angular', function(){
});
});
describe('sortedKeys', function(){
it('should collect keys from object', function(){
describe('sortedKeys', function() {
it('should collect keys from object', function() {
expect(sortedKeys({c:0, b:0, a:0})).toEqual(['a', 'b', 'c']);
});
});
@ -524,14 +524,14 @@ describe('angular', function(){
});
});
describe('compile', function(){
describe('compile', function() {
var scope, template;
afterEach(function(){
afterEach(function() {
dealoc(scope);
});
it('should link to existing node and create scope', function(){
it('should link to existing node and create scope', function() {
template = angular.element('<div>{{greeting = "hello world"}}</div>');
scope = angular.compile(template)();
scope.$digest();
@ -539,7 +539,7 @@ describe('angular', function(){
expect(scope.greeting).toEqual('hello world');
});
it('should link to existing node and given scope', function(){
it('should link to existing node and given scope', function() {
scope = angular.scope();
template = angular.element('<div>{{greeting = "hello world"}}</div>');
angular.compile(template)(scope);
@ -548,7 +548,7 @@ describe('angular', function(){
expect(scope).toEqual(scope);
});
it('should link to new node and given scope', function(){
it('should link to new node and given scope', function() {
scope = angular.scope();
template = jqLite('<div>{{greeting = "hello world"}}</div>');
@ -566,7 +566,7 @@ describe('angular', function(){
expect(scope.greeting).toEqual('hello world');
});
it('should link to cloned node and create scope', function(){
it('should link to cloned node and create scope', function() {
scope = angular.scope();
template = jqLite('<div>{{greeting = "hello world"}}</div>');
angular.compile(template)(scope, noop).$digest();
@ -598,8 +598,8 @@ describe('angular', function(){
});
describe('nextUid()', function(){
it('should return new id per call', function(){
describe('nextUid()', function() {
it('should return new id per call', function() {
var seen = {};
var count = 100;

View file

@ -16,7 +16,7 @@ describe('api', function() {
expect(map.get(key)).toBe(undefined);
});
it('should init from an array', function(){
it('should init from an array', function() {
var map = new HashMap(['a','b']);
expect(map.get('a')).toBe(0);
expect(map.get('b')).toBe(1);

View file

@ -1,7 +1,7 @@
'use strict';
describe('Binder', function(){
beforeEach(function(){
describe('Binder', function() {
beforeEach(function() {
var self = this;
this.compile = function(html, parent, logErrors) {
@ -22,42 +22,42 @@ describe('Binder', function(){
};
});
afterEach(function(){
afterEach(function() {
if (this.element && this.element.dealoc) {
this.element.dealoc();
}
});
it('BindUpdate', function(){
it('BindUpdate', function() {
var scope = this.compile('<div ng:init="a=123"/>');
scope.$digest();
assertEquals(123, scope.a);
});
it('ExecuteInitialization', function(){
it('ExecuteInitialization', function() {
var scope = this.compile('<div ng:init="a=123">');
assertEquals(scope.a, 123);
});
it('ExecuteInitializationStatements', function(){
it('ExecuteInitializationStatements', function() {
var scope = this.compile('<div ng:init="a=123;b=345">');
assertEquals(scope.a, 123);
assertEquals(scope.b, 345);
});
it('ApplyTextBindings', function(){
it('ApplyTextBindings', function() {
var scope = this.compile('<div ng:bind="model.a">x</div>');
scope.model = {a:123};
scope.$apply();
assertEquals('123', scope.$element.text());
});
it('ReplaceBindingInTextWithSpan', function(){
it('ReplaceBindingInTextWithSpan', function() {
assertEquals(this.compileToHtml("<b>a{{b}}c</b>"), '<b>a<span ng:bind="b"></span>c</b>');
assertEquals(this.compileToHtml("<b>{{b}}</b>"), '<b><span ng:bind="b"></span></b>');
});
it('BindingSpaceConfusesIE', function(){
it('BindingSpaceConfusesIE', function() {
if (!msie) return;
var span = document.createElement("span");
span.innerHTML = '&nbsp;';
@ -70,7 +70,7 @@ describe('Binder', function(){
this.compileToHtml("<b>{{A}} x {{B}} ({{C}})</b>"));
});
it('BindingOfAttributes', function(){
it('BindingOfAttributes', function() {
var scope = this.compile("<a href='http://s/a{{b}}c' foo='x'></a>");
var attrbinding = scope.$element.attr("ng:bind-attr");
var bindings = fromJson(attrbinding);
@ -78,7 +78,7 @@ describe('Binder', function(){
assertTrue(!bindings.foo);
});
it('MarkMultipleAttributes', function(){
it('MarkMultipleAttributes', function() {
var scope = this.compile('<a href="http://s/a{{b}}c" foo="{{d}}"></a>');
var attrbinding = scope.$element.attr("ng:bind-attr");
var bindings = fromJson(attrbinding);
@ -86,20 +86,20 @@ describe('Binder', function(){
assertEquals(decodeURI(bindings.href), "http://s/a{{b}}c");
});
it('AttributesNoneBound', function(){
it('AttributesNoneBound', function() {
var scope = this.compile("<a href='abc' foo='def'></a>");
var a = scope.$element;
assertEquals(a[0].nodeName, "A");
assertTrue(!a.attr("ng:bind-attr"));
});
it('ExistingAttrbindingIsAppended', function(){
it('ExistingAttrbindingIsAppended', function() {
var scope = this.compile("<a href='http://s/{{abc}}' ng:bind-attr='{\"b\":\"{{def}}\"}'></a>");
var a = scope.$element;
assertEquals('{"b":"{{def}}","href":"http://s/{{abc}}"}', a.attr('ng:bind-attr'));
});
it('AttributesAreEvaluated', function(){
it('AttributesAreEvaluated', function() {
var scope = this.compile('<a ng:bind-attr=\'{"a":"a", "b":"a+b={{a+b}}"}\'></a>');
scope.$eval('a=1;b=2');
scope.$apply();
@ -108,21 +108,21 @@ describe('Binder', function(){
assertEquals(a.attr('b'), 'a+b=3');
});
it('InputTypeButtonActionExecutesInScope', function(){
it('InputTypeButtonActionExecutesInScope', function() {
var savedCalled = false;
var scope = this.compile('<input type="button" ng:click="person.save()" value="Apply">');
scope.person = {};
scope.person.save = function(){
scope.person.save = function() {
savedCalled = true;
};
browserTrigger(scope.$element, 'click');
assertTrue(savedCalled);
});
it('InputTypeButtonActionExecutesInScope2', function(){
it('InputTypeButtonActionExecutesInScope2', function() {
var log = "";
var scope = this.compile('<input type="image" ng:click="action()">');
scope.action = function(){
scope.action = function() {
log += 'click;';
};
expect(log).toEqual('');
@ -130,18 +130,18 @@ describe('Binder', function(){
expect(log).toEqual('click;');
});
it('ButtonElementActionExecutesInScope', function(){
it('ButtonElementActionExecutesInScope', function() {
var savedCalled = false;
var scope = this.compile('<button ng:click="person.save()">Apply</button>');
scope.person = {};
scope.person.save = function(){
scope.person.save = function() {
savedCalled = true;
};
browserTrigger(scope.$element, 'click');
assertTrue(savedCalled);
});
it('RepeaterUpdateBindings', function(){
it('RepeaterUpdateBindings', function() {
var scope = this.compile('<ul><LI ng:repeat="item in model.items" ng:bind="item.a"/></ul>');
var form = scope.$element;
var items = [{a:"A"}, {a:"B"}];
@ -176,7 +176,7 @@ describe('Binder', function(){
scope.$apply();
});
it('RepeaterContentDoesNotBind', function(){
it('RepeaterContentDoesNotBind', function() {
var scope = this.compile('<ul><LI ng:repeat="item in model.items"><span ng:bind="item.a"></span></li></ul>');
scope.model = {items:[{a:"A"}]};
scope.$apply();
@ -186,12 +186,12 @@ describe('Binder', function(){
'</ul>', sortedHtml(scope.$element));
});
it('DoNotOverwriteCustomAction', function(){
it('DoNotOverwriteCustomAction', function() {
var html = this.compileToHtml('<input type="submit" value="Save" action="foo();">');
assertTrue(html.indexOf('action="foo();"') > 0 );
});
it('RepeaterAdd', function(){
it('RepeaterAdd', function() {
var scope = this.compile('<div><input type="text" ng:model="item.x" ng:repeat="item in items"></div>');
scope.items = [{x:'a'}, {x:'b'}];
scope.$apply();
@ -206,7 +206,7 @@ describe('Binder', function(){
expect(scope.items[0].x).toEqual('ABC');
});
it('ItShouldRemoveExtraChildrenWhenIteratingOverHash', function(){
it('ItShouldRemoveExtraChildrenWhenIteratingOverHash', function() {
var scope = this.compile('<div><div ng:repeat="i in items">{{i}}</div></div>');
var items = {};
scope.items = items;
@ -223,44 +223,44 @@ describe('Binder', function(){
expect(scope.$element[0].childNodes.length - 1).toEqual(0);
});
it('IfTextBindingThrowsErrorDecorateTheSpan', function(){
it('IfTextBindingThrowsErrorDecorateTheSpan', function() {
var scope = this.compile('<div>{{error.throw()}}</div>', null, true);
var errorLogs = scope.$service('$exceptionHandler').errors;
scope.error = {
'throw': function(){throw "ErrorMsg1";}
'throw': function() {throw "ErrorMsg1";}
};
scope.$apply();
scope.error['throw'] = function(){throw "MyError";};
scope.error['throw'] = function() {throw "MyError";};
errorLogs.length = 0;
scope.$apply();
assertEquals(['MyError'], errorLogs.shift());
scope.error['throw'] = function(){return "ok";};
scope.error['throw'] = function() {return "ok";};
scope.$apply();
assertEquals(0, errorLogs.length);
});
it('IfAttrBindingThrowsErrorDecorateTheAttribute', function(){
it('IfAttrBindingThrowsErrorDecorateTheAttribute', function() {
var scope = this.compile('<div attr="before {{error.throw()}} after"></div>', null, true);
var errorLogs = scope.$service('$exceptionHandler').errors;
var count = 0;
scope.error = {
'throw': function(){throw new Error("ErrorMsg" + (++count));}
'throw': function() {throw new Error("ErrorMsg" + (++count));}
};
scope.$apply();
expect(errorLogs.length).not.toEqual(0);
expect(errorLogs.shift()).toMatch(/ErrorMsg1/);
errorLogs.length = 0;
scope.error['throw'] = function(){ return 'X';};
scope.error['throw'] = function() { return 'X';};
scope.$apply();
expect(errorLogs.length).toMatch(0);
});
it('NestedRepeater', function(){
it('NestedRepeater', function() {
var scope = this.compile('<div><div ng:repeat="m in model" name="{{m.name}}">' +
'<ul name="{{i}}" ng:repeat="i in m.item"></ul>' +
'</div></div>');
@ -282,7 +282,7 @@ describe('Binder', function(){
'</div></div>', sortedHtml(scope.$element));
});
it('HideBindingExpression', function(){
it('HideBindingExpression', function() {
var scope = this.compile('<div ng:hide="hidden == 3"/>');
scope.hidden = 3;
@ -296,7 +296,7 @@ describe('Binder', function(){
assertVisible(scope.$element);
});
it('HideBinding', function(){
it('HideBinding', function() {
var scope = this.compile('<div ng:hide="hidden"/>');
scope.hidden = 'true';
@ -315,7 +315,7 @@ describe('Binder', function(){
assertVisible(scope.$element);
});
it('ShowBinding', function(){
it('ShowBinding', function() {
var scope = this.compile('<div ng:show="show"/>');
scope.show = 'true';
@ -335,7 +335,7 @@ describe('Binder', function(){
});
it('BindClass', function(){
it('BindClass', function() {
var scope = this.compile('<div ng:class="clazz"/>');
scope.clazz = 'testClass';
@ -349,7 +349,7 @@ describe('Binder', function(){
assertEquals('<div class="a b" ng:class="clazz"></div>', sortedHtml(scope.$element));
});
it('BindClassEvenOdd', function(){
it('BindClassEvenOdd', function() {
var scope = this.compile('<div><div ng:repeat="i in [0,1]" ng:class-even="\'e\'" ng:class-odd="\'o\'"></div></div>');
scope.$apply();
var d1 = jqLite(scope.$element[0].childNodes[1]);
@ -363,7 +363,7 @@ describe('Binder', function(){
sortedHtml(scope.$element));
});
it('BindStyle', function(){
it('BindStyle', function() {
var scope = this.compile('<div ng:style="style"/>');
scope.$eval('style={height: "10px"}');
@ -375,9 +375,9 @@ describe('Binder', function(){
scope.$apply();
});
it('ActionOnAHrefThrowsError', function(){
it('ActionOnAHrefThrowsError', function() {
var scope = this.compile('<a ng:click="action()">Add Phone</a>', null, true);
scope.action = function(){
scope.action = function() {
throw new Error('MyError');
};
var input = scope.$element;
@ -385,7 +385,7 @@ describe('Binder', function(){
expect(scope.$service('$exceptionHandler').errors[0]).toMatch(/MyError/);
});
it('ShoulIgnoreVbNonBindable', function(){
it('ShoulIgnoreVbNonBindable', function() {
var scope = this.compile("<div>{{a}}" +
"<div ng:non-bindable>{{a}}</div>" +
"<div ng:non-bindable=''>{{b}}</div>" +
@ -403,7 +403,7 @@ describe('Binder', function(){
assertEquals('<pre ng:bind-template="Hello {{name}}!">Hello World!</pre>', sortedHtml(scope.$element));
});
it('FillInOptionValueWhenMissing', function(){
it('FillInOptionValueWhenMissing', function() {
var scope = this.compile(
'<select ng:model="foo">' +
'<option selected="true">{{a}}</option>' +
@ -427,7 +427,7 @@ describe('Binder', function(){
expect(optionC.text()).toEqual('C');
});
it('DeleteAttributeIfEvaluatesFalse', function(){
it('DeleteAttributeIfEvaluatesFalse', function() {
var scope = this.compile('<div>' +
'<input ng:model="a0" ng:bind-attr="{disabled:\'{{true}}\'}">' +
'<input ng:model="a1" ng:bind-attr="{disabled:\'{{false}}\'}">' +
@ -449,7 +449,7 @@ describe('Binder', function(){
assertChild(5, false);
});
it('ItShouldDisplayErrorWhenActionIsSyntacticlyIncorrect', function(){
it('ItShouldDisplayErrorWhenActionIsSyntacticlyIncorrect', function() {
var scope = this.compile('<div>' +
'<input type="button" ng:click="greeting=\'ABC\'"/>' +
'<input type="button" ng:click=":garbage:"/></div>', null, true);
@ -466,7 +466,7 @@ describe('Binder', function(){
toMatchError(/Syntax Error: Token ':' not a primary expression/);
});
it('ItShouldSelectTheCorrectRadioBox', function(){
it('ItShouldSelectTheCorrectRadioBox', function() {
var scope = this.compile('<div>' +
'<input type="radio" ng:model="sex" value="female">' +
'<input type="radio" ng:model="sex" value="male"></div>');
@ -486,7 +486,7 @@ describe('Binder', function(){
assertEquals("male", male.val());
});
it('ItShouldRepeatOnHashes', function(){
it('ItShouldRepeatOnHashes', function() {
var scope = this.compile('<ul><li ng:repeat="(k,v) in {a:0,b:1}" ng:bind=\"k + v\"></li></ul>');
scope.$apply();
assertEquals('<ul>' +
@ -497,7 +497,7 @@ describe('Binder', function(){
sortedHtml(scope.$element));
});
it('ItShouldFireChangeListenersBeforeUpdate', function(){
it('ItShouldFireChangeListenersBeforeUpdate', function() {
var scope = this.compile('<div ng:bind="name"></div>');
scope.name = "";
scope.$watch("watched", "name=123");
@ -509,7 +509,7 @@ describe('Binder', function(){
sortedHtml(scope.$element));
});
it('ItShouldHandleMultilineBindings', function(){
it('ItShouldHandleMultilineBindings', function() {
var scope = this.compile('<div>{{\n 1 \n + \n 2 \n}}</div>');
scope.$apply();
assertEquals("3", scope.$element.text());

View file

@ -46,11 +46,11 @@ function MockWindow() {
};
}
describe('browser', function(){
describe('browser', function() {
var browser, fakeWindow, xhr, logs, scripts, removedScripts, sniffer;
beforeEach(function(){
beforeEach(function() {
scripts = [];
removedScripts = [];
xhr = null;
@ -60,7 +60,7 @@ describe('browser', function(){
var fakeBody = [{appendChild: function(node){scripts.push(node);},
removeChild: function(node){removedScripts.push(node);}}];
var FakeXhr = function(){
var FakeXhr = function() {
xhr = this;
this.open = function(method, url, async){
xhr.method = method;
@ -91,14 +91,14 @@ describe('browser', function(){
expect(browser.cookies).toBeDefined();
});
describe('outstading requests', function(){
it('should process callbacks immedietly with no outstanding requests', function(){
describe('outstading requests', function() {
it('should process callbacks immedietly with no outstanding requests', function() {
var callback = jasmine.createSpy('callback');
browser.notifyWhenNoOutstandingRequests(callback);
expect(callback).toHaveBeenCalled();
});
it('should queue callbacks with outstanding requests', function(){
it('should queue callbacks with outstanding requests', function() {
var callback = jasmine.createSpy('callback');
browser.xhr('GET', '/url', null, noop);
browser.notifyWhenNoOutstandingRequests(callback);
@ -110,8 +110,8 @@ describe('browser', function(){
});
});
describe('xhr', function(){
describe('JSON', function(){
describe('xhr', function() {
describe('JSON', function() {
var log;
function callback(code, data) {
@ -478,12 +478,12 @@ describe('browser', function(){
});
describe('poller', function(){
describe('poller', function() {
it('should call functions in pollFns in regular intervals', function(){
it('should call functions in pollFns in regular intervals', function() {
var log = '';
browser.addPollFn(function(){log+='a';});
browser.addPollFn(function(){log+='b';});
browser.addPollFn(function() {log+='a';});
browser.addPollFn(function() {log+='b';});
expect(log).toEqual('');
fakeWindow.setTimeout.flush();
expect(log).toEqual('ab');
@ -491,14 +491,14 @@ describe('browser', function(){
expect(log).toEqual('abab');
});
it('should startPoller', function(){
it('should startPoller', function() {
expect(fakeWindow.timeouts.length).toEqual(0);
browser.addPollFn(function(){});
browser.addPollFn(function() {});
expect(fakeWindow.timeouts.length).toEqual(1);
//should remain 1 as it is the check fn
browser.addPollFn(function(){});
browser.addPollFn(function() {});
expect(fakeWindow.timeouts.length).toEqual(1);
});

View file

@ -1,9 +1,9 @@
'use strict';
describe('compiler', function(){
describe('compiler', function() {
var compiler, markup, attrMarkup, directives, widgets, compile, log, scope;
beforeEach(function(){
beforeEach(function() {
log = "";
directives = {
hello: function(expression, element){
@ -34,13 +34,13 @@ describe('compiler', function(){
});
afterEach(function(){
afterEach(function() {
dealoc(scope);
});
it('should not allow compilation of multiple roots', function(){
expect(function(){
it('should not allow compilation of multiple roots', function() {
expect(function() {
compiler.compile('<div>A</div><span></span>');
}).toThrow("Cannot compile multiple element roots: " + ie("<div>A</div><span></span>"));
function ie(text) {
@ -49,7 +49,7 @@ describe('compiler', function(){
});
it('should recognize a directive', function(){
it('should recognize a directive', function() {
var e = jqLite('<div directive="expr" ignore="me"></div>');
directives.directive = function(expression, element){
log += "found";
@ -67,13 +67,13 @@ describe('compiler', function(){
});
it('should recurse to children', function(){
it('should recurse to children', function() {
scope = compile('<div><span hello="misko"/></div>');
expect(log).toEqual("hello misko");
});
it('should observe scope', function(){
it('should observe scope', function() {
scope = compile('<span observe="name"></span>');
expect(log).toEqual("");
scope.$digest();
@ -87,14 +87,14 @@ describe('compiler', function(){
});
it('should prevent descend', function(){
directives.stop = function(){ this.descend(false); };
it('should prevent descend', function() {
directives.stop = function() { this.descend(false); };
scope = compile('<span hello="misko" stop="true"><span hello="adam"/></span>');
expect(log).toEqual("hello misko");
});
it('should allow creation of templates', function(){
it('should allow creation of templates', function() {
directives.duplicate = function(expr, element){
element.replaceWith(document.createComment("marker"));
element.removeAttr("duplicate");
@ -119,7 +119,7 @@ describe('compiler', function(){
});
it('should process markup before directives', function(){
it('should process markup before directives', function() {
markup.push(function(text, textNode, parentNode) {
if (text == 'middle') {
expect(textNode.text()).toEqual(text);
@ -133,7 +133,7 @@ describe('compiler', function(){
});
it('should replace widgets', function(){
it('should replace widgets', function() {
widgets['NG:BUTTON'] = function(element) {
expect(element.hasClass('ng-widget')).toEqual(true);
element.replaceWith('<div>button</div>');
@ -147,7 +147,7 @@ describe('compiler', function(){
});
it('should use the replaced element after calling widget', function(){
it('should use the replaced element after calling widget', function() {
widgets['H1'] = function(element) {
// HTML elements which are augmented by acting as widgets, should not be marked as so
expect(element.hasClass('ng-widget')).toEqual(false);
@ -166,7 +166,7 @@ describe('compiler', function(){
});
it('should allow multiple markups per text element', function(){
it('should allow multiple markups per text element', function() {
markup.push(function(text, textNode, parent){
var index = text.indexOf('---');
if (index > -1) {
@ -190,7 +190,7 @@ describe('compiler', function(){
});
it('should add class for namespace elements', function(){
it('should add class for namespace elements', function() {
scope = compile('<ng:space>abc</ng:space>');
var space = jqLite(scope.$element[0].firstChild);
expect(space.hasClass('ng-space')).toEqual(true);

View file

@ -6,7 +6,7 @@ describe('filter', function() {
it('should called the filter when evaluating expression', function() {
var scope = createScope();
filter.fakeFilter = function(){};
filter.fakeFilter = function() {};
spyOn(filter, 'fakeFilter');
scope.$eval('10|fakeFilter');
@ -205,7 +205,7 @@ describe('filter', function() {
});
});
describe('date', function(){
describe('date', function() {
var morning = new TzDate(+5, '2010-09-03T12:05:08.000Z'); //7am
var noon = new TzDate(+5, '2010-09-03T17:05:08.000Z'); //12pm

View file

@ -1,20 +1,20 @@
'use strict';
describe('injector', function(){
describe('injector', function() {
var providers;
var cache;
var injector;
var scope;
beforeEach(function(){
beforeEach(function() {
providers = extensionMap({}, 'providers');
cache = {};
scope = {};
injector = createInjector(scope, providers, cache);
});
it("should return same instance from calling provider", function(){
providers('text', function(){ return scope.name; });
it("should return same instance from calling provider", function() {
providers('text', function() { return scope.name; });
scope.name = 'abc';
expect(injector('text')).toEqual('abc');
expect(cache.text).toEqual('abc');
@ -22,9 +22,9 @@ describe('injector', function(){
expect(injector('text')).toEqual('abc');
});
it("should call function", function(){
providers('a', function(){return 1;});
providers('b', function(){return 2;});
it("should call function", function() {
providers('a', function() {return 1;});
providers('b', function() {return 2;});
var args;
function fn(a, b, c, d) {
args = [this, a, b, c, d];
@ -34,15 +34,15 @@ describe('injector', function(){
expect(args).toEqual([{name:'this'}, 1, 2, 3, 4]);
});
it('should inject providers', function(){
providers('a', function(){return this.mi = 'Mi';});
it('should inject providers', function() {
providers('a', function() {return this.mi = 'Mi';});
providers('b', function(mi){return this.name = mi+'sko';}, {$inject:['a']});
expect(injector('b')).toEqual('Misko');
expect(scope).toEqual({mi:'Mi', name:'Misko'});
});
it('should resolve dependency graph and instantiate all services just once', function(){
it('should resolve dependency graph and instantiate all services just once', function() {
var log = [];
// s1
@ -54,12 +54,12 @@ describe('injector', function(){
// s6
providers('s1', function(){ log.push('s1'); }, {$inject: ['s2', 's5', 's6']});
providers('s2', function(){ log.push('s2'); }, {$inject: ['s3', 's4', 's5']});
providers('s3', function(){ log.push('s3'); }, {$inject: ['s6']});
providers('s4', function(){ log.push('s4'); }, {$inject: ['s3', 's5']});
providers('s5', function(){ log.push('s5'); });
providers('s6', function(){ log.push('s6'); });
providers('s1', function() { log.push('s1'); }, {$inject: ['s2', 's5', 's6']});
providers('s2', function() { log.push('s2'); }, {$inject: ['s3', 's4', 's5']});
providers('s3', function() { log.push('s3'); }, {$inject: ['s6']});
providers('s4', function() { log.push('s4'); }, {$inject: ['s3', 's5']});
providers('s5', function() { log.push('s5'); });
providers('s6', function() { log.push('s6'); });
injector('s1');
@ -67,32 +67,32 @@ describe('injector', function(){
});
it('should provide usefull message if no provider', function(){
expect(function(){
it('should provide usefull message if no provider', function() {
expect(function() {
injector('idontexist');
}).toThrow("Unknown provider for 'idontexist'.");
});
it('should autostart eager services', function(){
it('should autostart eager services', function() {
var log = '';
providers('eager', function(){log += 'eager;'; return 'foo';}, {$eager: true});
providers('eager', function() {log += 'eager;'; return 'foo';}, {$eager: true});
injector.eager();
expect(log).toEqual('eager;');
expect(injector('eager')).toBe('foo');
});
describe('annotation', function(){
it('should return $inject', function(){
function fn(){}
describe('annotation', function() {
it('should return $inject', function() {
function fn() {}
fn.$inject = ['a'];
expect(inferInjectionArgs(fn)).toBe(fn.$inject);
expect(inferInjectionArgs(function(){})).toEqual([]);
expect(inferInjectionArgs(function (){})).toEqual([]);
expect(inferInjectionArgs(function (){})).toEqual([]);
expect(inferInjectionArgs(function /* */ (){})).toEqual([]);
expect(inferInjectionArgs(function() {})).toEqual([]);
expect(inferInjectionArgs(function () {})).toEqual([]);
expect(inferInjectionArgs(function () {})).toEqual([]);
expect(inferInjectionArgs(function /* */ () {})).toEqual([]);
});
it('should create $inject', function(){
it('should create $inject', function() {
// keep the multi-line to make sure we can handle it
function $f_n0 /*
*/(
@ -107,40 +107,40 @@ describe('injector', function(){
expect($f_n0.$inject).toEqual(['$a', 'b_', '_c', 'd']);
});
it('should handle no arg functions', function(){
function $f_n0(){}
it('should handle no arg functions', function() {
function $f_n0() {}
expect(inferInjectionArgs($f_n0)).toEqual([]);
expect($f_n0.$inject).toEqual([]);
});
it('should handle args with both $ and _', function(){
it('should handle args with both $ and _', function() {
function $f_n0($a_){}
expect(inferInjectionArgs($f_n0)).toEqual(['$a_']);
expect($f_n0.$inject).toEqual(['$a_']);
});
it('should throw on non function arg', function(){
expect(function(){
it('should throw on non function arg', function() {
expect(function() {
inferInjectionArgs({});
}).toThrow();
});
it('should infer injection on services', function(){
it('should infer injection on services', function() {
var scope = angular.scope({
a: function(){ return 'a';},
a: function() { return 'a';},
b: function(a){ return a + 'b';}
});
expect(scope.$service('b')).toEqual('ab');
});
});
describe('inject', function(){
it('should inject names', function(){
describe('inject', function() {
it('should inject names', function() {
expect(annotate('a', {}).$inject).toEqual(['a']);
expect(annotate('a', 'b', {}).$inject).toEqual(['a', 'b']);
});
it('should inject array', function(){
it('should inject array', function() {
expect(annotate(['a'], {}).$inject).toEqual(['a']);
expect(annotate(['a', 'b'], {}).$inject).toEqual(['a', 'b']);
});

View file

@ -1,6 +1,6 @@
'use strict';
describe('json', function(){
describe('json', function() {
it('should serialize primitives', function() {
expect(toJson(0/0)).toEqual('null');
expect(toJson(null)).toEqual('null');
@ -11,11 +11,11 @@ describe('json', function(){
expect(toJson("a \t \n \r b \\")).toEqual('"a \\t \\n \\r b \\\\"');
});
it('should not serialize $$properties', function(){
it('should not serialize $$properties', function() {
expect(toJson({$$some:'value', 'this':1, '$parent':1}, false)).toEqual('{}');
});
it('should not serialize this or $parent', function(){
it('should not serialize this or $parent', function() {
expect(toJson({'this':'value', $parent:'abc'}, false)).toEqual('{}');
});
@ -46,8 +46,8 @@ describe('json', function(){
});
it('should ignore functions', function() {
expect(toJson([function(){},1])).toEqual('[null,1]');
expect(toJson({a:function(){}})).toEqual('{}');
expect(toJson([function() {},1])).toEqual('[null,1]');
expect(toJson({a:function() {}})).toEqual('{}');
});
it('should parse null', function() {
@ -127,7 +127,7 @@ describe('json', function(){
expect(fromJson("{exp:1.2e-10}")).toEqual({exp:1.2E-10});
});
it('should ignore non-strings', function(){
it('should ignore non-strings', function() {
expect(fromJson([])).toEqual([]);
expect(fromJson({})).toEqual({});
expect(fromJson(null)).toEqual(null);
@ -170,51 +170,51 @@ describe('json', function(){
}
describe('security', function(){
it('should not allow naked expressions', function(){
expect(function(){fromJson('1+2');}).
describe('security', function() {
it('should not allow naked expressions', function() {
expect(function() {fromJson('1+2');}).
toThrow(new Error("Syntax Error: Token '+' is an unexpected token at column 2 of the expression [1+2] starting at [+2]."));
});
it('should not allow naked expressions group', function(){
expect(function(){fromJson('(1+2)');}).
it('should not allow naked expressions group', function() {
expect(function() {fromJson('(1+2)');}).
toThrow(new Error("Syntax Error: Token '(' is not valid json at column 1 of the expression [(1+2)] starting at [(1+2)]."));
});
it('should not allow expressions in objects', function(){
expect(function(){fromJson('{a:abc()}');}).
it('should not allow expressions in objects', function() {
expect(function() {fromJson('{a:abc()}');}).
toThrow(new Error("Syntax Error: Token 'abc' is not valid json at column 4 of the expression [{a:abc()}] starting at [abc()}]."));
});
it('should not allow expressions in arrays', function(){
expect(function(){fromJson('[1+2]');}).
it('should not allow expressions in arrays', function() {
expect(function() {fromJson('[1+2]');}).
toThrow(new Error("Syntax Error: Token '+' is not valid json at column 3 of the expression [[1+2]] starting at [+2]]."));
});
it('should not allow vars', function(){
expect(function(){fromJson('[1, x]');}).
it('should not allow vars', function() {
expect(function() {fromJson('[1, x]');}).
toThrow(new Error("Syntax Error: Token 'x' is not valid json at column 5 of the expression [[1, x]] starting at [x]]."));
});
it('should not allow dereference', function(){
expect(function(){fromJson('["".constructor]');}).
it('should not allow dereference', function() {
expect(function() {fromJson('["".constructor]');}).
toThrow(new Error("Syntax Error: Token '.' is not valid json at column 4 of the expression [[\"\".constructor]] starting at [.constructor]]."));
});
it('should not allow expressions ofter valid json', function(){
expect(function(){fromJson('[].constructor');}).
it('should not allow expressions ofter valid json', function() {
expect(function() {fromJson('[].constructor');}).
toThrow(new Error("Syntax Error: Token '.' is not valid json at column 3 of the expression [[].constructor] starting at [.constructor]."));
});
it('should not allow object dereference', function(){
expect(function(){fromJson('{a:1, b: $location, c:1}');}).toThrow();
expect(function(){fromJson("{a:1, b:[1]['__parent__']['location'], c:1}");}).toThrow();
it('should not allow object dereference', function() {
expect(function() {fromJson('{a:1, b: $location, c:1}');}).toThrow();
expect(function() {fromJson("{a:1, b:[1]['__parent__']['location'], c:1}");}).toThrow();
});
it('should not allow assignments', function(){
expect(function(){fromJson("{a:1, b:[1]=1, c:1}");}).toThrow();
expect(function(){fromJson("{a:1, b:=1, c:1}");}).toThrow();
expect(function(){fromJson("{a:1, b:x=1, c:1}");}).toThrow();
it('should not allow assignments', function() {
expect(function() {fromJson("{a:1, b:[1]=1, c:1}");}).toThrow();
expect(function() {fromJson("{a:1, b:=1, c:1}");}).toThrow();
expect(function() {fromJson("{a:1, b:x=1, c:1}");}).toThrow();
});
});

View file

@ -191,7 +191,7 @@ describe('parser', function() {
expect(scope.$eval("'a' + 'b c'")).toEqual("ab c");
});
it('should parse filters', function(){
it('should parse filters', function() {
angular.filter.substring = function(input, start, end) {
return input.substring(start, end);
};
@ -416,8 +416,8 @@ describe('parser', function() {
});
describe('assignable', function(){
it('should expose assignment function', function(){
describe('assignable', function() {
it('should expose assignment function', function() {
var fn = parser('a').assignable();
expect(fn.assign).toBeTruthy();
var scope = {};

View file

@ -16,7 +16,7 @@ describe("resource", function() {
callback = jasmine.createSpy();
});
it("should build resource", function(){
it("should build resource", function() {
expect(typeof CreditCard).toBe('function');
expect(typeof CreditCard.get).toBe('function');
expect(typeof CreditCard.save).toBe('function');
@ -25,12 +25,12 @@ describe("resource", function() {
expect(typeof CreditCard.query).toBe('function');
});
it('should default to empty parameters', function(){
it('should default to empty parameters', function() {
xhr.expectGET('URL').respond({});
resource.route('URL').query();
});
it('should ignore slashes of undefinend parameters', function(){
it('should ignore slashes of undefinend parameters', function() {
var R = resource.route('/Path/:a/:b/:c');
xhr.expectGET('/Path').respond({});
xhr.expectGET('/Path/1').respond({});
@ -42,7 +42,7 @@ describe("resource", function() {
R.get({a:4, b:5, c:6});
});
it('should correctly encode url params', function(){
it('should correctly encode url params', function() {
var R = resource.route('/Path/:a');
xhr.expectGET('/Path/foo%231').respond({});
xhr.expectGET('/Path/doh!@foo?bar=baz%231').respond({});
@ -67,7 +67,7 @@ describe("resource", function() {
R.get({a: 'doh&foo', bar: 'baz&1'});
});
it("should build resource with default param", function(){
it("should build resource with default param", function() {
xhr.expectGET('/Order/123/Line/456.visa?minimum=0.05').respond({id:'abc'});
var LineItem = resource.route('/Order/:orderId/Line/:id:verb', {orderId: '123', id: '@id.key', verb:'.visa', minimum:0.05});
var item = LineItem.get({id:456});
@ -75,7 +75,7 @@ describe("resource", function() {
nakedExpect(item).toEqual({id:'abc'});
});
it("should build resource with action default param overriding default param", function(){
it("should build resource with action default param overriding default param", function() {
xhr.expectGET('/Customer/123').respond({id:'abc'});
var TypeItem = resource.route('/:type/:typeId', {type: 'Order'},
{get: {method: 'GET', params: {type: 'Customer'}}});
@ -84,7 +84,7 @@ describe("resource", function() {
nakedExpect(item).toEqual({id:'abc'});
});
it("should create resource", function(){
it("should create resource", function() {
xhr.expectPOST('/CreditCard', {name:'misko'}).respond({id:123, name:'misko'});
var cc = CreditCard.save({name:'misko'}, callback);
@ -95,7 +95,7 @@ describe("resource", function() {
expect(callback).toHaveBeenCalledWith(cc);
});
it("should read resource", function(){
it("should read resource", function() {
xhr.expectGET("/CreditCard/123").respond({id:123, number:'9876'});
var cc = CreditCard.get({id:123}, callback);
expect(cc instanceof CreditCard).toBeTruthy();
@ -106,7 +106,7 @@ describe("resource", function() {
expect(callback).toHaveBeenCalledWith(cc);
});
it("should read partial resource", function(){
it("should read partial resource", function() {
xhr.expectGET("/CreditCard").respond([{id:{key:123}}]);
xhr.expectGET("/CreditCard/123").respond({id:{key:123}, number:'9876'});
var ccs = CreditCard.query();
@ -121,7 +121,7 @@ describe("resource", function() {
expect(cc.number).toEqual('9876');
});
it("should update resource", function(){
it("should update resource", function() {
xhr.expectPOST('/CreditCard/123', {id:{key:123}, name:'misko'}).respond({id:{key:123}, name:'rama'});
var cc = CreditCard.save({id:{key:123}, name:'misko'}, callback);
@ -130,7 +130,7 @@ describe("resource", function() {
xhr.flush();
});
it("should query resource", function(){
it("should query resource", function() {
xhr.expectGET("/CreditCard?key=value").respond([{id:1}, {id:2}]);
var ccs = CreditCard.query({key:'value'}, callback);
@ -141,16 +141,16 @@ describe("resource", function() {
expect(callback).toHaveBeenCalledWith(ccs);
});
it("should have all arguments optional", function(){
it("should have all arguments optional", function() {
xhr.expectGET('/CreditCard').respond([{id:1}]);
var log = '';
var ccs = CreditCard.query(function(){ log += 'cb;'; });
var ccs = CreditCard.query(function() { log += 'cb;'; });
xhr.flush();
nakedExpect(ccs).toEqual([{id:1}]);
expect(log).toEqual('cb;');
});
it('should delete resource and call callback', function(){
it('should delete resource and call callback', function() {
xhr.expectDELETE("/CreditCard/123").respond(200, {});
CreditCard.remove({id:123}, callback);
@ -166,20 +166,20 @@ describe("resource", function() {
nakedExpect(callback.mostRecentCall.args).toEqual([{}]);
});
it('should post charge verb', function(){
it('should post charge verb', function() {
xhr.expectPOST('/CreditCard/123!charge?amount=10', {auth:'abc'}).respond({success:'ok'});
CreditCard.charge({id:123, amount:10},{auth:'abc'}, callback);
});
it('should post charge verb on instance', function(){
it('should post charge verb on instance', function() {
xhr.expectPOST('/CreditCard/123!charge?amount=10', {id:{key:123}, name:'misko'}).respond({success:'ok'});
var card = new CreditCard({id:{key:123}, name:'misko'});
card.$charge({amount:10}, callback);
});
it('should create on save', function(){
it('should create on save', function() {
xhr.expectPOST('/CreditCard', {name:'misko'}).respond({id:123});
var cc = new CreditCard();
expect(cc.$get).toBeDefined();
@ -195,7 +195,7 @@ describe("resource", function() {
expect(callback).toHaveBeenCalledWith(cc);
});
it('should not mutate the resource object if response contains no body', function(){
it('should not mutate the resource object if response contains no body', function() {
var data = {id:{key:123}, number:'9876'};
xhr.expectGET("/CreditCard/123").respond(data);
var cc = CreditCard.get({id:123});
@ -209,7 +209,7 @@ describe("resource", function() {
expect(idBefore).toEqual(cc.id);
});
it('should bind default parameters', function(){
it('should bind default parameters', function() {
xhr.expectGET('/CreditCard/123.visa?minimum=0.05').respond({id:123});
var Visa = CreditCard.bind({verb:'.visa', minimum:0.05});
var visa = Visa.get({id:123});
@ -217,7 +217,7 @@ describe("resource", function() {
nakedExpect(visa).toEqual({id:123});
});
it('should excersize full stack', function(){
it('should excersize full stack', function() {
var scope = angular.compile('<div></div>')();
var $browser = scope.$service('$browser');
var $resource = scope.$service('$resource');
@ -229,7 +229,7 @@ describe("resource", function() {
dealoc(scope);
});
it('should return the same object when verifying the cache', function(){
it('should return the same object when verifying the cache', function() {
var scope = angular.compile('<div></div>')();
var $browser = scope.$service('$browser');
var $resource = scope.$service('$resource');

View file

@ -1,18 +1,18 @@
'use strict';
describe("ScenarioSpec: Compilation", function(){
describe("ScenarioSpec: Compilation", function() {
var scope;
beforeEach(function(){
beforeEach(function() {
scope = null;
});
afterEach(function(){
afterEach(function() {
dealoc(scope);
});
describe('compilation', function(){
it("should compile dom node and return scope", function(){
describe('compilation', function() {
it("should compile dom node and return scope", function() {
var node = jqLite('<div ng:init="a=1">{{b=a+1}}</div>')[0];
scope = angular.compile(node)();
scope.$digest();
@ -20,13 +20,13 @@ describe("ScenarioSpec: Compilation", function(){
expect(scope.b).toEqual(2);
});
it("should compile jQuery node and return scope", function(){
it("should compile jQuery node and return scope", function() {
scope = compile(jqLite('<div>{{a=123}}</div>'))();
scope.$digest();
expect(jqLite(scope.$element).text()).toEqual('123');
});
it("should compile text node and return scope", function(){
it("should compile text node and return scope", function() {
scope = angular.compile('<div>{{a=123}}</div>')();
scope.$digest();
expect(jqLite(scope.$element).text()).toEqual('123');

View file

@ -1,6 +1,6 @@
'use strict';
describe('Scope', function(){
describe('Scope', function() {
var root = null, mockHandler = null;
beforeEach(function() {
@ -302,7 +302,7 @@ describe('Scope', function(){
});
describe('$destroy', function(){
describe('$destroy', function() {
var first = null, middle = null, last = null, log = null;
beforeEach(function() {
@ -471,7 +471,7 @@ describe('Scope', function(){
root = angular.scope(),
child = root.$new();
function eventFn(){
function eventFn() {
log += 'X';
}
@ -492,7 +492,7 @@ describe('Scope', function(){
child = root.$new(),
listenerRemove;
function eventFn(){
function eventFn() {
log += 'X';
}

View file

@ -1,6 +1,6 @@
'use strict';
describe('mocks', function(){
describe('mocks', function() {
describe('TzDate', function() {
function minutes(min) {
@ -172,26 +172,26 @@ describe('mocks', function(){
});
});
describe('defer', function(){
describe('defer', function() {
var browser, log;
beforeEach(function(){
beforeEach(function() {
browser = new MockBrowser();
log = '';
});
function logFn(text){ return function(){
function logFn(text){ return function() {
log += text +';';
};
}
it('should flush', function(){
it('should flush', function() {
browser.defer(logFn('A'));
expect(log).toEqual('');
browser.defer.flush();
expect(log).toEqual('A;');
});
it('should flush delayed', function(){
it('should flush delayed', function() {
browser.defer(logFn('A'));
browser.defer(logFn('B'), 10);
browser.defer(logFn('C'), 20);
@ -205,7 +205,7 @@ describe('mocks', function(){
expect(log).toEqual('A;B;C;');
});
it('should defer and flush over time', function(){
it('should defer and flush over time', function() {
browser.defer(logFn('A'), 1);
browser.defer(logFn('B'), 2);
browser.defer(logFn('C'), 3);

View file

@ -63,8 +63,8 @@ describe("directive", function() {
expect(lowercase(element.html())).toEqual('<a>hello</a>');
});
it('should have $element set to current bind element', function(){
angularFilter.myFilter = function(){
it('should have $element set to current bind element', function() {
angularFilter.myFilter = function() {
this.$element.addClass("filter");
return 'HELLO';
};
@ -80,7 +80,7 @@ describe("directive", function() {
expect(scope.$element.text()).toEqual('-0false');
});
it('should render object as JSON ignore $$', function(){
it('should render object as JSON ignore $$', function() {
var scope = compile('<div>{{ {key:"value", $$key:"hide"} }}</div>');
scope.$digest();
expect(fromJson(scope.$element.text())).toEqual({key:'value'});
@ -108,7 +108,7 @@ describe("directive", function() {
expect(innerText).toEqual('INNER');
});
it('should render object as JSON ignore $$', function(){
it('should render object as JSON ignore $$', function() {
var scope = compile('<pre>{{ {key:"value", $$key:"hide"} }}</pre>');
scope.$digest();
expect(fromJson(scope.$element.text())).toEqual({key:'value'});
@ -148,7 +148,7 @@ describe("directive", function() {
expect(input.checked).toEqual(true);
});
describe('ng:click', function(){
describe('ng:click', function() {
it('should get called on a click', function() {
var scope = compile('<div ng:click="clicked = true"></div>');
scope.$digest();
@ -208,7 +208,7 @@ describe("directive", function() {
});
it('should support adding multiple classes via an array', function(){
it('should support adding multiple classes via an array', function() {
var scope = compile('<div class="existing" ng:class="[\'A\', \'B\']"></div>');
scope.$digest();
expect(element.hasClass('existing')).toBeTruthy();
@ -217,7 +217,7 @@ describe("directive", function() {
});
it('should support adding multiple classes via a space delimited string', function(){
it('should support adding multiple classes via a space delimited string', function() {
var scope = compile('<div class="existing" ng:class="\'A B\'"></div>');
scope.$digest();
expect(element.hasClass('existing')).toBeTruthy();
@ -420,7 +420,7 @@ describe("directive", function() {
});
describe('ng:hide', function() {
it('should hide an element', function(){
it('should hide an element', function() {
var element = jqLite('<div ng:hide="exp"></div>'),
scope = compile(element);
@ -480,7 +480,7 @@ describe("directive", function() {
expect(scope.$element.text()).toEqual('hey dude!');
});
it('should infer injection arguments', function(){
it('should infer injection arguments', function() {
temp.MyController = function($xhr){
this.$root.someService = $xhr;
};

View file

@ -2,14 +2,14 @@
if (window.jQuery) {
describe('jQuery patch', function(){
describe('jQuery patch', function() {
var doc = null;
var divSpy = null;
var spy1 = null;
var spy2 = null;
beforeEach(function(){
beforeEach(function() {
divSpy = jasmine.createSpy('div.$destroy');
spy1 = jasmine.createSpy('span1.$destroy');
spy2 = jasmine.createSpy('span2.$destroy');
@ -18,7 +18,7 @@ if (window.jQuery) {
doc.find('span.second').bind('$destroy', spy2);
});
afterEach(function(){
afterEach(function() {
expect(divSpy).not.toHaveBeenCalled();
expect(spy1).toHaveBeenCalled();
@ -27,29 +27,29 @@ if (window.jQuery) {
expect(spy2.callCount).toEqual(1);
});
describe('$detach event', function(){
describe('$detach event', function() {
it('should fire on detach()', function(){
it('should fire on detach()', function() {
doc.find('span').detach();
});
it('should fire on remove()', function(){
it('should fire on remove()', function() {
doc.find('span').remove();
});
it('should fire on replaceWith()', function(){
it('should fire on replaceWith()', function() {
doc.find('span').replaceWith('<b>bla</b>');
});
it('should fire on replaceAll()', function(){
it('should fire on replaceAll()', function() {
$('<b>bla</b>').replaceAll(doc.find('span'));
});
it('should fire on empty()', function(){
it('should fire on empty()', function() {
doc.empty();
});
it('should fire on html()', function(){
it('should fire on html()', function() {
doc.html('abc');
});
});

View file

@ -1,16 +1,16 @@
'use strict';
describe('jqLite', function(){
describe('jqLite', function() {
var scope, a, b, c;
beforeEach(function(){
beforeEach(function() {
a = jqLite('<div>A</div>')[0];
b = jqLite('<div>B</div>')[0];
c = jqLite('<div>C</div>')[0];
});
beforeEach(function(){
beforeEach(function() {
scope = angular.scope();
this.addMatchers({
toJqEqual: function(expected) {
@ -32,7 +32,7 @@ describe('jqLite', function(){
});
afterEach(function(){
afterEach(function() {
dealoc(a);
dealoc(b);
dealoc(c);
@ -44,8 +44,8 @@ describe('jqLite', function(){
});
describe('construction', function(){
it('should allow construction with text node', function(){
describe('construction', function() {
it('should allow construction with text node', function() {
var text = a.firstChild;
var selected = jqLite(text);
expect(selected.length).toEqual(1);
@ -53,7 +53,7 @@ describe('jqLite', function(){
});
it('should allow construction with html', function(){
it('should allow construction with html', function() {
var nodes = jqLite('<div>1</div><span>2</span>');
expect(nodes.length).toEqual(2);
expect(nodes[0].innerHTML).toEqual('1');
@ -138,8 +138,8 @@ describe('jqLite', function(){
});
describe('data', function(){
it('should set and get and remove data', function(){
describe('data', function() {
it('should set and get and remove data', function() {
var selected = jqLite([a, b, c]);
expect(selected.data('prop', 'value')).toEqual(selected);
@ -160,18 +160,18 @@ describe('jqLite', function(){
expect(jqLite(c).data('prop')).toEqual(undefined);
});
it('should call $destroy function if element removed', function(){
it('should call $destroy function if element removed', function() {
var log = '';
var element = jqLite(a);
element.bind('$destroy', function(){log+= 'destroy;';});
element.bind('$destroy', function() {log+= 'destroy;';});
element.remove();
expect(log).toEqual('destroy;');
});
});
describe('attr', function(){
it('shoul read write and remove attr', function(){
describe('attr', function() {
it('shoul read write and remove attr', function() {
var selector = jqLite([a, b]);
expect(selector.attr('prop', 'value')).toEqual(selector);
@ -191,7 +191,7 @@ describe('jqLite', function(){
expect(jqLite(b).attr('prop')).toBeFalsy();
});
it('should read special attributes as strings', function(){
it('should read special attributes as strings', function() {
var select = jqLite('<select>');
expect(select.attr('multiple')).toBeUndefined();
expect(jqLite('<select multiple>').attr('multiple')).toBe('multiple');
@ -244,16 +244,16 @@ describe('jqLite', function(){
});
describe('class', function(){
describe('class', function() {
describe('hasClass', function(){
it('should check class', function(){
describe('hasClass', function() {
it('should check class', function() {
var selector = jqLite([a, b]);
expect(selector.hasClass('abc')).toEqual(false);
});
it('should make sure that partial class is not checked as a subset', function(){
it('should make sure that partial class is not checked as a subset', function() {
var selector = jqLite([a, b]);
selector.addClass('a');
selector.addClass('b');
@ -316,8 +316,8 @@ describe('jqLite', function(){
});
describe('toggleClass', function(){
it('should allow toggling of class', function(){
describe('toggleClass', function() {
it('should allow toggling of class', function() {
var selector = jqLite([a, b]);
expect(selector.toggleClass('abc')).toEqual(selector);
expect(jqLite(a).hasClass('abc')).toEqual(true);
@ -339,8 +339,8 @@ describe('jqLite', function(){
});
describe('removeClass', function(){
it('should allow removal of class', function(){
describe('removeClass', function() {
it('should allow removal of class', function() {
var selector = jqLite([a, b]);
expect(selector.addClass('abc')).toEqual(selector);
expect(selector.removeClass('abc')).toEqual(selector);
@ -372,8 +372,8 @@ describe('jqLite', function(){
});
describe('css', function(){
it('should set and read css', function(){
describe('css', function() {
it('should set and read css', function() {
var selector = jqLite([a, b]);
expect(selector.css('margin', '1px')).toEqual(selector);
@ -439,14 +439,14 @@ describe('jqLite', function(){
});
describe('text', function(){
it('should return null on empty', function(){
describe('text', function() {
it('should return null on empty', function() {
expect(jqLite().length).toEqual(0);
expect(jqLite().text()).toEqual('');
});
it('should read/write value', function(){
it('should read/write value', function() {
var element = jqLite('<div>abc</div>');
expect(element.length).toEqual(1);
expect(element[0].innerHTML).toEqual('abc');
@ -457,8 +457,8 @@ describe('jqLite', function(){
});
describe('val', function(){
it('should read, write value', function(){
describe('val', function() {
it('should read, write value', function() {
var input = jqLite('<input type="text"/>');
expect(input.val('abc')).toEqual(input);
expect(input[0].value).toEqual('abc');
@ -467,14 +467,14 @@ describe('jqLite', function(){
});
describe('html', function(){
it('should return null on empty', function(){
describe('html', function() {
it('should return null on empty', function() {
expect(jqLite().length).toEqual(0);
expect(jqLite().html()).toEqual(null);
});
it('should read/write value', function(){
it('should read/write value', function() {
var element = jqLite('<div>abc</div>');
expect(element.length).toEqual(1);
expect(element[0].innerHTML).toEqual('abc');
@ -485,8 +485,8 @@ describe('jqLite', function(){
});
describe('bind', function(){
it('should bind to window on hashchange', function(){
describe('bind', function() {
it('should bind to window on hashchange', function() {
if (jqLite.fn) return; // don't run in jQuery
var eventFn;
var window = {
@ -507,7 +507,7 @@ describe('jqLite', function(){
detachEvent: noop
};
var log;
var jWindow = jqLite(window).bind('hashchange', function(){
var jWindow = jqLite(window).bind('hashchange', function() {
log = 'works!';
});
eventFn({});
@ -516,10 +516,10 @@ describe('jqLite', function(){
});
it('should bind to all elements and return functions', function(){
it('should bind to all elements and return functions', function() {
var selected = jqLite([a, b]);
var log = '';
expect(selected.bind('click', function(){
expect(selected.bind('click', function() {
log += 'click on: ' + jqLite(this).text() + ';';
})).toEqual(selected);
browserTrigger(a, 'click');
@ -664,8 +664,8 @@ describe('jqLite', function(){
});
describe('replaceWith', function(){
it('should replaceWith', function(){
describe('replaceWith', function() {
it('should replaceWith', function() {
var root = jqLite('<div>').html('before-<div></div>after');
var div = root.find('div');
expect(div.replaceWith('<span>span-</span><b>bold-</b>')).toEqual(div);
@ -673,7 +673,7 @@ describe('jqLite', function(){
});
it('should replaceWith text', function(){
it('should replaceWith text', function() {
var root = jqLite('<div>').html('before-<div></div>after');
var div = root.find('div');
expect(div.replaceWith('text-')).toEqual(div);
@ -682,8 +682,8 @@ describe('jqLite', function(){
});
describe('children', function(){
it('should select non-text children', function(){
describe('children', function() {
it('should select non-text children', function() {
var root = jqLite('<div>').html('before-<div></div>after-<span></span>');
var div = root.find('div');
var span = root.find('span');
@ -692,13 +692,13 @@ describe('jqLite', function(){
});
describe('append', function(){
it('should append', function(){
describe('append', function() {
it('should append', function() {
var root = jqLite('<div>');
expect(root.append('<span>abc</span>')).toEqual(root);
expect(root.html().toLowerCase()).toEqual('<span>abc</span>');
});
it('should append text', function(){
it('should append text', function() {
var root = jqLite('<div>');
expect(root.append('text')).toEqual(root);
expect(root.html()).toEqual('text');
@ -710,18 +710,18 @@ describe('jqLite', function(){
});
});
describe('prepend', function(){
it('should prepend to empty', function(){
describe('prepend', function() {
it('should prepend to empty', function() {
var root = jqLite('<div>');
expect(root.prepend('<span>abc</span>')).toEqual(root);
expect(root.html().toLowerCase()).toEqual('<span>abc</span>');
});
it('should prepend to content', function(){
it('should prepend to content', function() {
var root = jqLite('<div>text</div>');
expect(root.prepend('<span>abc</span>')).toEqual(root);
expect(root.html().toLowerCase()).toEqual('<span>abc</span>text');
});
it('should prepend text to content', function(){
it('should prepend text to content', function() {
var root = jqLite('<div>text</div>');
expect(root.prepend('abc')).toEqual(root);
expect(root.html().toLowerCase()).toEqual('abctext');
@ -729,8 +729,8 @@ describe('jqLite', function(){
});
describe('remove', function(){
it('should remove', function(){
describe('remove', function() {
it('should remove', function() {
var root = jqLite('<div><span>abc</span></div>');
var span = root.find('span');
expect(span.remove()).toEqual(span);
@ -739,8 +739,8 @@ describe('jqLite', function(){
});
describe('after', function(){
it('should after', function(){
describe('after', function() {
it('should after', function() {
var root = jqLite('<div><span></span></div>');
var span = root.find('span');
expect(span.after('<i></i><b></b>')).toEqual(span);
@ -748,7 +748,7 @@ describe('jqLite', function(){
});
it('should allow taking text', function(){
it('should allow taking text', function() {
var root = jqLite('<div><span></span></div>');
var span = root.find('span');
span.after('abc');
@ -757,8 +757,8 @@ describe('jqLite', function(){
});
describe('parent', function(){
it('should return parent or an empty set when no parent', function(){
describe('parent', function() {
it('should return parent or an empty set when no parent', function() {
var parent = jqLite('<div><p>abc</p></div>'),
child = parent.find('p');
@ -790,7 +790,7 @@ describe('jqLite', function(){
describe('next', function() {
it('should return next sibling', function(){
it('should return next sibling', function() {
var element = jqLite('<div><b>b</b><i>i</i></div>');
var b = element.find('b');
var i = element.find('i');
@ -800,7 +800,7 @@ describe('jqLite', function(){
describe('find', function() {
it('should find child by name', function(){
it('should find child by name', function() {
var root = jqLite('<div><div>text</div></div>');
var innerDiv = root.find('div');
expect(innerDiv.length).toEqual(1);

View file

@ -42,7 +42,7 @@ describe('jstd-adapter', function() {
*/
function buildTestConf(type) {
return new jstestdriver.TestRunConfiguration(
new jstestdriver.TestCaseInfo('Fake test - ' + Math.random(), function(){}, type), null);
new jstestdriver.TestCaseInfo('Fake test - ' + Math.random(), function() {}, type), null);
}
/**

View file

@ -52,7 +52,7 @@
<!-- include spec files here... -->
<script type="text/javascript">
describe('manual', function(){
describe('manual', function() {
var compile, model, element;
beforeEach(function() {
@ -120,7 +120,7 @@ describe('angular.scenario.output.json', function() {
<script type="text/javascript">
jasmine.getEnv().addReporter(new jasmine.TrivialReporter());
function run(){
function run() {
jasmine.getEnv().execute();
}
run();

View file

@ -1,6 +1,6 @@
'use strict';
describe("markups", function(){
describe("markups", function() {
var compile, element, scope;
@ -13,11 +13,11 @@ describe("markups", function(){
};
});
afterEach(function(){
afterEach(function() {
dealoc(element);
});
it('should translate {{}} in text', function(){
it('should translate {{}} in text', function() {
compile('<div>hello {{name}}!</div>');
expect(sortedHtml(element)).toEqual('<div>hello <span ng:bind="name"></span>!</div>');
scope.name = 'Misko';
@ -25,7 +25,7 @@ describe("markups", function(){
expect(sortedHtml(element)).toEqual('<div>hello <span ng:bind="name">Misko</span>!</div>');
});
it('should translate {{}} in terminal nodes', function(){
it('should translate {{}} in terminal nodes', function() {
compile('<select ng:model="x"><option value="">Greet {{name}}!</option></select>');
scope.$digest();
expect(sortedHtml(element).replace(' selected="true"', '')).
@ -40,7 +40,7 @@ describe("markups", function(){
'</select>');
});
it('should translate {{}} in attributes', function(){
it('should translate {{}} in attributes', function() {
compile('<div src="http://server/{{path}}.png"/>');
expect(element.attr('ng:bind-attr')).toEqual('{"src":"http://server/{{path}}.png"}');
scope.path = 'a/b';
@ -48,11 +48,11 @@ describe("markups", function(){
expect(element.attr('src')).toEqual("http://server/a/b.png");
});
describe('OPTION value', function(){
beforeEach(function(){
describe('OPTION value', function() {
beforeEach(function() {
this.addMatchers({
toHaveValue: function(expected){
this.message = function(){
this.message = function() {
return 'Expected "' + this.actual.html() + '" to have value="' + expected + '".';
};
@ -74,22 +74,22 @@ describe("markups", function(){
});
it('should populate value attribute on OPTION', function(){
it('should populate value attribute on OPTION', function() {
compile('<select ng:model="x"><option>abc</option></select>');
expect(element).toHaveValue('abc');
});
it('should ignore value if already exists', function(){
it('should ignore value if already exists', function() {
compile('<select ng:model="x"><option value="abc">xyz</option></select>');
expect(element).toHaveValue('abc');
});
it('should set value even if newlines present', function(){
it('should set value even if newlines present', function() {
compile('<select ng:model="x"><option attr="\ntext\n" \n>\nabc\n</option></select>');
expect(element).toHaveValue('\nabc\n');
});
it('should set value even if self closing HTML', function(){
it('should set value even if self closing HTML', function() {
// IE removes the \n from option, which makes this test pointless
if (msie) return;
compile('<select ng:model="x"><option>\n</option></select>');
@ -174,21 +174,21 @@ describe("markups", function(){
});
});
it('should Parse Text With No Bindings', function(){
it('should Parse Text With No Bindings', function() {
var parts = parseBindings("a");
assertEquals(parts.length, 1);
assertEquals(parts[0], "a");
assertTrue(!binding(parts[0]));
});
it('should Parse Empty Text', function(){
it('should Parse Empty Text', function() {
var parts = parseBindings("");
assertEquals(parts.length, 1);
assertEquals(parts[0], "");
assertTrue(!binding(parts[0]));
});
it('should Parse Inner Binding', function(){
it('should Parse Inner Binding', function() {
var parts = parseBindings("a{{b}}C");
assertEquals(parts.length, 3);
assertEquals(parts[0], "a");
@ -199,7 +199,7 @@ describe("markups", function(){
assertTrue(!binding(parts[2]));
});
it('should Parse Ending Binding', function(){
it('should Parse Ending Binding', function() {
var parts = parseBindings("a{{b}}");
assertEquals(parts.length, 2);
assertEquals(parts[0], "a");
@ -208,7 +208,7 @@ describe("markups", function(){
assertEquals(binding(parts[1]), "b");
});
it('should Parse Begging Binding', function(){
it('should Parse Begging Binding', function() {
var parts = parseBindings("{{b}}c");
assertEquals(parts.length, 2);
assertEquals(parts[0], "{{b}}");
@ -217,14 +217,14 @@ describe("markups", function(){
assertTrue(!binding(parts[1]));
});
it('should Parse Loan Binding', function(){
it('should Parse Loan Binding', function() {
var parts = parseBindings("{{b}}");
assertEquals(parts.length, 1);
assertEquals(parts[0], "{{b}}");
assertEquals(binding(parts[0]), "b");
});
it('should Parse Two Bindings', function(){
it('should Parse Two Bindings', function() {
var parts = parseBindings("{{b}}{{c}}");
assertEquals(parts.length, 2);
assertEquals(parts[0], "{{b}}");
@ -233,7 +233,7 @@ describe("markups", function(){
assertEquals(binding(parts[1]), "c");
});
it('should Parse Two Bindings With Text In Middle', function(){
it('should Parse Two Bindings With Text In Middle', function() {
var parts = parseBindings("{{b}}x{{c}}");
assertEquals(parts.length, 3);
assertEquals(parts[0], "{{b}}");
@ -244,7 +244,7 @@ describe("markups", function(){
assertEquals(binding(parts[2]), "c");
});
it('should Parse Multiline', function(){
it('should Parse Multiline', function() {
var parts = parseBindings('"X\nY{{A\nB}}C\nD"');
assertTrue(!!binding('{{A\nB}}'));
assertEquals(parts.length, 3);
@ -253,7 +253,7 @@ describe("markups", function(){
assertEquals(parts[2], 'C\nD"');
});
it('should Has Binding', function(){
it('should Has Binding', function() {
assertTrue(hasBindings(parseBindings("{{a}}")));
assertTrue(!hasBindings(parseBindings("a")));
assertTrue(hasBindings(parseBindings("{{b}}x{{c}}")));

View file

@ -30,10 +30,10 @@
* See {@link angular.mock} for more info on angular mocks.
*/
var $logMock = {
log: function(){ $logMock.log.logs.push(concat([], arguments, 0)); },
warn: function(){ $logMock.warn.logs.push(concat([], arguments, 0)); },
info: function(){ $logMock.info.logs.push(concat([], arguments, 0)); },
error: function(){ $logMock.error.logs.push(concat([], arguments, 0)); }
log: function() { $logMock.log.logs.push(concat([], arguments, 0)); },
warn: function() { $logMock.warn.logs.push(concat([], arguments, 0)); },
info: function() { $logMock.info.logs.push(concat([], arguments, 0)); },
error: function() { $logMock.error.logs.push(concat([], arguments, 0)); }
};
$logMock.log.logs = [];
$logMock.warn.logs = [];

View file

@ -1,14 +1,14 @@
'use strict';
describe('HTML', function(){
describe('HTML', function() {
function expectHTML(html) {
return expect(new HTML(html).get());
}
describe('htmlParser', function(){
describe('htmlParser', function() {
var handler, start, text;
beforeEach(function(){
beforeEach(function() {
handler = {
start: function(tag, attrs, unary){
start = {
@ -31,31 +31,31 @@ describe('HTML', function(){
};
});
it('should parse basic format', function(){
it('should parse basic format', function() {
htmlParser('<tag attr="value">text</tag>', handler);
expect(start).toEqual({tag:'tag', attrs:{attr:'value'}, unary:false});
expect(text).toEqual('text');
});
it('should parse newlines in tags', function(){
it('should parse newlines in tags', function() {
htmlParser('<\ntag\n attr="value"\n>text<\n/\ntag\n>', handler);
expect(start).toEqual({tag:'tag', attrs:{attr:'value'}, unary:false});
expect(text).toEqual('text');
});
it('should parse newlines in attributes', function(){
it('should parse newlines in attributes', function() {
htmlParser('<tag attr="\nvalue\n">text</tag>', handler);
expect(start).toEqual({tag:'tag', attrs:{attr:'value'}, unary:false});
expect(text).toEqual('text');
});
it('should parse namespace', function(){
it('should parse namespace', function() {
htmlParser('<ns:t-a-g ns:a-t-t-r="\nvalue\n">text</ns:t-a-g>', handler);
expect(start).toEqual({tag:'ns:t-a-g', attrs:{'ns:a-t-t-r':'value'}, unary:false});
expect(text).toEqual('text');
});
it('should parse empty value attribute of node', function(){
it('should parse empty value attribute of node', function() {
htmlParser('<OPTION selected value="">abc</OPTION>', handler);
expect(start).toEqual({tag:'option', attrs:{selected:'', value:''}, unary:false});
expect(text).toEqual('abc');
@ -63,87 +63,87 @@ describe('HTML', function(){
});
it('should echo html', function(){
it('should echo html', function() {
expectHTML('hello<b class="1\'23" align=\'""\'>world</b>.').
toEqual('hello<b class="1\'23" align="&#34;&#34;">world</b>.');
});
it('should remove script', function(){
it('should remove script', function() {
expectHTML('a<SCRIPT>evil< / scrIpt >c.').toEqual('ac.');
});
it('should remove nested script', function(){
it('should remove nested script', function() {
expectHTML('a< SCRIPT >A< SCRIPT >evil< / scrIpt >B< / scrIpt >c.').toEqual('ac.');
});
it('should remove attrs', function(){
it('should remove attrs', function() {
expectHTML('a<div style="abc">b</div>c').toEqual('a<div>b</div>c');
});
it('should remove style', function(){
it('should remove style', function() {
expectHTML('a<STyle>evil</stYle>c.').toEqual('ac.');
});
it('should remove script and style', function(){
it('should remove script and style', function() {
expectHTML('a<STyle>evil<script></script></stYle>c.').toEqual('ac.');
});
it('should remove double nested script', function(){
it('should remove double nested script', function() {
expectHTML('a<SCRIPT>ev<script>evil</sCript>il</scrIpt>c.').toEqual('ac.');
});
it('should remove unknown names', function(){
it('should remove unknown names', function() {
expectHTML('a<xxx><B>b</B></xxx>c').toEqual('a<b>b</b>c');
});
it('should remove unsafe value', function(){
it('should remove unsafe value', function() {
expectHTML('<a href="javascript:alert()">').toEqual('<a></a>');
});
it('should handle self closed elements', function(){
it('should handle self closed elements', function() {
expectHTML('a<hr/>c').toEqual('a<hr/>c');
});
it('should handle namespace', function(){
it('should handle namespace', function() {
expectHTML('a<my:hr/><my:div>b</my:div>c').toEqual('abc');
});
it('should handle entities', function(){
it('should handle entities', function() {
var everything = '<div rel="!@#$%^&amp;*()_+-={}[]:&#34;;\'&lt;&gt;?,./`~ &#295;">' +
'!@#$%^&amp;*()_+-={}[]:&#34;;\'&lt;&gt;?,./`~ &#295;</div>';
expectHTML(everything).toEqual(everything);
});
it('should handle improper html', function(){
it('should handle improper html', function() {
expectHTML('< div rel="</div>" alt=abc dir=\'"\' >text< /div>').
toEqual('<div rel="&lt;/div&gt;" alt="abc" dir="&#34;">text</div>');
});
it('should handle improper html2', function(){
it('should handle improper html2', function() {
expectHTML('< div rel="</div>" / >').
toEqual('<div rel="&lt;/div&gt;"/>');
});
it('should ignore back slash as escape', function(){
it('should ignore back slash as escape', function() {
expectHTML('<img alt="xxx\\" title="><script>....">').
toEqual('<img alt="xxx\\" title="&gt;&lt;script&gt;...."/>');
});
it('should ignore object attributes', function(){
it('should ignore object attributes', function() {
expectHTML('<a constructor="hola">:)</a>').
toEqual('<a>:)</a>');
expectHTML('<constructor constructor="hola">:)</constructor>').
toEqual('');
});
describe('htmlSanitizerWriter', function(){
describe('htmlSanitizerWriter', function() {
var writer, html;
beforeEach(function(){
beforeEach(function() {
html = '';
writer = htmlSanitizeWriter({push:function(text){html+=text;}});
});
it('should write basic HTML', function(){
it('should write basic HTML', function() {
writer.chars('before');
writer.start('div', {rel:'123'}, false);
writer.chars('in');
@ -153,38 +153,38 @@ describe('HTML', function(){
expect(html).toEqual('before<div rel="123">in</div>after');
});
it('should escape text nodes', function(){
it('should escape text nodes', function() {
writer.chars('a<div>&</div>c');
expect(html).toEqual('a&lt;div&gt;&amp;&lt;/div&gt;c');
});
it('should escape IE script', function(){
it('should escape IE script', function() {
writer.chars('&<>{}');
expect(html).toEqual('&amp;&lt;&gt;{}');
});
it('should escape attributes', function(){
it('should escape attributes', function() {
writer.start('div', {rel:'!@#$%^&*()_+-={}[]:";\'<>?,./`~ \n\0\r\u0127'});
expect(html).toEqual('<div rel="!@#$%^&amp;*()_+-={}[]:&#34;;\'&lt;&gt;?,./`~ &#10;&#0;&#13;&#295;">');
});
it('should ignore missformed elements', function(){
it('should ignore missformed elements', function() {
writer.start('d>i&v', {});
expect(html).toEqual('');
});
it('should ignore unknown attributes', function(){
it('should ignore unknown attributes', function() {
writer.start('div', {unknown:""});
expect(html).toEqual('<div>');
});
describe('explicitly dissallow', function(){
it('should not allow attributes', function(){
describe('explicitly dissallow', function() {
it('should not allow attributes', function() {
writer.start('div', {id:'a', name:'a', style:'a'});
expect(html).toEqual('<div>');
});
it('should not allow tags', function(){
it('should not allow tags', function() {
function tag(name) {
writer.start(name, {});
writer.end(name);
@ -209,13 +209,13 @@ describe('HTML', function(){
});
});
describe('isUri', function(){
describe('isUri', function() {
function isUri(value) {
return value.match(URI_REGEXP);
}
it('should be URI', function(){
it('should be URI', function() {
expect(isUri('http://abc')).toBeTruthy();
expect(isUri('https://abc')).toBeTruthy();
expect(isUri('ftp://abc')).toBeTruthy();
@ -223,46 +223,46 @@ describe('HTML', function(){
expect(isUri('#anchor')).toBeTruthy();
});
it('should not be UIR', function(){
it('should not be UIR', function() {
expect(isUri('')).toBeFalsy();
expect(isUri('javascript:alert')).toBeFalsy();
});
});
describe('javascript URL attribute', function(){
beforeEach(function(){
describe('javascript URL attribute', function() {
beforeEach(function() {
this.addMatchers({
toBeValidUrl: function(){
toBeValidUrl: function() {
return URI_REGEXP.exec(this.actual);
}
});
});
it('should ignore javascript:', function(){
it('should ignore javascript:', function() {
expect('JavaScript:abc').not.toBeValidUrl();
expect(' \n Java\n Script:abc').not.toBeValidUrl();
expect('http://JavaScript/my.js').toBeValidUrl();
});
it('should ignore dec encoded javascript:', function(){
it('should ignore dec encoded javascript:', function() {
expect('&#106;&#97;&#118;&#97;&#115;&#99;&#114;&#105;&#112;&#116;&#58;').not.toBeValidUrl();
expect('&#106&#97;&#118;&#97;&#115;&#99;&#114;&#105;&#112;&#116;&#58;').not.toBeValidUrl();
expect('&#106 &#97;&#118;&#97;&#115;&#99;&#114;&#105;&#112;&#116;&#58;').not.toBeValidUrl();
});
it('should ignore decimal with leading 0 encodede javascript:', function(){
it('should ignore decimal with leading 0 encodede javascript:', function() {
expect('&#0000106&#0000097&#0000118&#0000097&#0000115&#0000099&#0000114&#0000105&#0000112&#0000116&#0000058').not.toBeValidUrl();
expect('&#0000106 &#0000097&#0000118&#0000097&#0000115&#0000099&#0000114&#0000105&#0000112&#0000116&#0000058').not.toBeValidUrl();
expect('&#0000106; &#0000097&#0000118&#0000097&#0000115&#0000099&#0000114&#0000105&#0000112&#0000116&#0000058').not.toBeValidUrl();
});
it('should ignore hex encoded javascript:', function(){
it('should ignore hex encoded javascript:', function() {
expect('&#x6A&#x61&#x76&#x61&#x73&#x63&#x72&#x69&#x70&#x74&#x3A;').not.toBeValidUrl();
expect('&#x6A;&#x61&#x76&#x61&#x73&#x63&#x72&#x69&#x70&#x74&#x3A;').not.toBeValidUrl();
expect('&#x6A &#x61&#x76&#x61&#x73&#x63&#x72&#x69&#x70&#x74&#x3A;').not.toBeValidUrl();
});
it('should ignore hex encoded whitespace javascript:', function(){
it('should ignore hex encoded whitespace javascript:', function() {
expect('jav&#x09;ascript:alert("A");').not.toBeValidUrl();
expect('jav&#x0A;ascript:alert("B");').not.toBeValidUrl();
expect('jav&#x0A ascript:alert("C");').not.toBeValidUrl();

View file

@ -26,11 +26,11 @@ describe('angular.scenario.Describe', function() {
});
it('should handle basic nested case', function() {
root.describe('A', function(){
root.describe('A', function() {
this.beforeEach(log.fn('{'));
this.afterEach(log.fn('}'));
this.it('1', log.fn('1'));
this.describe('B', function(){
this.describe('B', function() {
this.beforeEach(log.fn('('));
this.afterEach(log.fn(')'));
this.it('2', log.fn('2'));

View file

@ -212,7 +212,7 @@ describe("angular.scenario.dsl", function() {
expect(_jQuery('[ng\\:model="test"]').val()).toEqual('A');
});
it('should select option by name', function(){
it('should select option by name', function() {
doc.append(
'<select ng:model="test">' +
' <option value=A>one</option>' +

View file

@ -1,7 +1,7 @@
'use strict';
describe('widgets', function() {
it('should verify that basic widgets work', function(){
it('should verify that basic widgets work', function() {
browser().navigateTo('widgets.html');
using('#text-basic-box').input('text.basic').enter('Carlos');

View file

@ -9,7 +9,7 @@ describe('$cookieStore', function() {
$browser = scope.$service('$browser');
});
afterEach(function(){
afterEach(function() {
dealoc(scope);
});

View file

@ -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'});

View file

@ -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);

View file

@ -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));
});
});

View file

@ -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'),

View file

@ -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]);

View file

@ -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');

View file

@ -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';

View file

@ -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'),

View file

@ -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);
});
});

View file

@ -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();

View file

@ -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', {});

Some files were not shown because too many files have changed in this diff Show more