aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMisko Hevery2011-11-08 17:40:52 -0800
committerMisko Hevery2011-11-14 20:31:15 -0800
commit9c0639437607a4fcea379bbaf610600d05d8a9b7 (patch)
tree1ae90d93d0139f7791487fe814360904254d39cb /src
parent085e3c611fd0cd48757702c50c67b551a00a0d38 (diff)
downloadangular.js-9c0639437607a4fcea379bbaf610600d05d8a9b7.tar.bz2
chore(scenario tests): make scenario tests pass again
Diffstat (limited to 'src')
-rw-r--r--src/Angular.js132
-rw-r--r--src/angular-mocks.js4
-rw-r--r--src/scenario/Application.js2
-rw-r--r--src/service/filter/filter.js6
-rw-r--r--src/service/filter/filters.js4
-rw-r--r--src/service/filter/limitTo.js10
-rw-r--r--src/service/filter/orderBy.js2
-rw-r--r--src/service/formFactory.js12
8 files changed, 23 insertions, 149 deletions
diff --git a/src/Angular.js b/src/Angular.js
index a191c0c7..bb75bc4e 100644
--- a/src/Angular.js
+++ b/src/Angular.js
@@ -498,10 +498,6 @@ function map(obj, iterator, context) {
/**
- * @ngdoc function
- * @name angular.Object.size
- * @function
- *
* @description
* Determines the number of elements in an array, the number of properties an object has, or
* the length of a string.
@@ -512,29 +508,6 @@ function map(obj, iterator, context) {
* @param {Object|Array|string} obj Object, array, or string to inspect.
* @param {boolean} [ownPropsOnly=false] Count only "own" properties in an object
* @returns {number} The size of `obj` or `0` if `obj` is neither an object nor an array.
- *
- * @example
- * <doc:example>
- * <doc:source>
- * <script>
- * function SizeCtrl() {
- * this.fooStringLength = angular.Object.size('foo');
- * }
- * </script>
- * <div ng:controller="SizeCtrl">
- * Number of items in array: {{ [1,2].$size() }}<br/>
- * Number of items in object: {{ {a:1, b:2, c:3}.$size() }}<br/>
- * String length: {{fooStringLength}}
- * </div>
- * </doc:source>
- * <doc:scenario>
- * it('should print correct sizes for an array and an object', function() {
- * expect(binding('[1,2].$size()')).toBe('2');
- * expect(binding('{a:1, b:2, c:3}.$size()')).toBe('3');
- * expect(binding('fooStringLength')).toBe('3');
- * });
- * </doc:scenario>
- * </doc:example>
*/
function size(obj, ownPropsOnly) {
var size = 0, key;
@@ -566,11 +539,11 @@ function indexOf(array, obj) {
}
function arrayRemove(array, value) {
- var index = indexOf(array, value);
- if (index >=0)
- array.splice(index, 1);
- return value;
- }
+ var index = indexOf(array, value);
+ if (index >=0)
+ array.splice(index, 1);
+ return value;
+}
function isLeafNode (node) {
if (node) {
@@ -590,15 +563,6 @@ function isLeafNode (node) {
* @function
*
* @description
- * Alias for {@link angular.Object.copy}
- */
-
-/**
- * @ngdoc function
- * @name angular.Object.copy
- * @function
- *
- * @description
* Creates a deep copy of `source`, which should be an object or an array.
*
* * If no destination is supplied, a copy of the object or array is created.
@@ -614,46 +578,6 @@ function isLeafNode (node) {
* @param {(Object|Array)=} destination Destination into which the source is copied. If
* provided, must be of the same type as `source`.
* @returns {*} The copy or updated `destination`, if `destination` was specified.
- *
- * @example
- * <doc:example>
- * <doc:source>
- <script>
- function Ctrl() {
- this.master = {
- salutation: 'Hello',
- name: 'world'
- };
- this.copy = function() {
- this.form = angular.copy(this.master);
- }
- }
- </script>
- <div ng:controller="Ctrl">
- Salutation: <input type="text" ng:model="master.salutation" ><br/>
- Name: <input type="text" ng:model="master.name"><br/>
- <button ng:click="copy()">copy</button>
- <hr/>
-
- The master object is <span ng:hide="master.$equals(form)">NOT</span> equal to the form object.
-
- <pre>master={{master}}</pre>
- <pre>form={{form}}</pre>
- </div>
- * </doc:source>
- * <doc:scenario>
- it('should print that initialy the form object is NOT equal to master', function() {
- expect(element('.doc-example-live input[ng\\:model="master.salutation"]').val()).toBe('Hello');
- expect(element('.doc-example-live input[ng\\:model="master.name"]').val()).toBe('world');
- expect(element('.doc-example-live span').css('display')).toBe('inline');
- });
-
- it('should make form and master equal when the copy button is clicked', function() {
- element('.doc-example-live button').click();
- expect(element('.doc-example-live span').css('display')).toBe('none');
- });
- * </doc:scenario>
- * </doc:example>
*/
function copy(source, destination){
if (!destination) {
@@ -693,15 +617,6 @@ function copy(source, destination){
* @function
*
* @description
- * Alias for {@link angular.Object.equals}
- */
-
-/**
- * @ngdoc function
- * @name angular.Object.equals
- * @function
- *
- * @description
* Determines if two objects or two values are equivalent. Supports value types, arrays and
* objects.
*
@@ -720,43 +635,6 @@ function copy(source, destination){
* @param {*} o2 Object or value to compare.
* @returns {boolean} True if arguments are equal.
*
- * @example
- * <doc:example>
- * <doc:source>
- <script>
- function Ctrl() {
- this.master = {
- salutation: 'Hello',
- name: 'world'
- };
- this.greeting = angular.copy(this.master);
- }
- </script>
- <div ng:controller="Ctrl">
- Salutation: <input type="text" ng:model="greeting.salutation"><br/>
- Name: <input type="text" ng:model="greeting.name"><br/>
- <hr/>
-
- The <code>greeting</code> object is
- <span ng:hide="greeting.$equals(master)">NOT</span> equal to
- <code>{salutation:'Hello', name:'world'}</code>.
-
- <pre>greeting={{greeting}}</pre>
- </div>
- * </doc:source>
- * <doc:scenario>
- it('should print that initialy greeting is equal to the hardcoded value object', function() {
- expect(element('.doc-example-live input[ng\\:model="greeting.salutation"]').val()).toBe('Hello');
- expect(element('.doc-example-live input[ng\\:model="greeting.name"]').val()).toBe('world');
- expect(element('.doc-example-live span').css('display')).toBe('none');
- });
-
- it('should say that the objects are not equal when the form is modified', function() {
- input('greeting.name').enter('kitty');
- expect(element('.doc-example-live span').css('display')).toBe('inline');
- });
- * </doc:scenario>
- * </doc:example>
*/
function equals(o1, o2) {
if (o1 === o2) return true;
diff --git a/src/angular-mocks.js b/src/angular-mocks.js
index 907b0492..1757b941 100644
--- a/src/angular-mocks.js
+++ b/src/angular-mocks.js
@@ -344,7 +344,9 @@ angular.mock.$Browser.prototype = {
}
},
- addJs: function() {}
+ notifyWhenNoOutstandingRequests: function(fn) {
+ fn();
+ }
};
diff --git a/src/scenario/Application.js b/src/scenario/Application.js
index ef778975..e255041b 100644
--- a/src/scenario/Application.js
+++ b/src/scenario/Application.js
@@ -90,7 +90,7 @@ angular.scenario.Application.prototype.executeAction = function(action) {
if (!$window.angular) {
return action.call(this, $window, _jQuery($window.document));
}
- var element = $window.angular.element($window.document.body);
+ var element = $window.angular.element($window.document);
var $injector = element.inheritedData('$injector');
$injector(function($browser){
$browser.notifyWhenNoOutstandingRequests(function() {
diff --git a/src/service/filter/filter.js b/src/service/filter/filter.js
index 0a0f5706..05ae6bfa 100644
--- a/src/service/filter/filter.js
+++ b/src/service/filter/filter.js
@@ -2,7 +2,7 @@
/**
* @ngdoc function
- * @name angular.Array.filter
+ * @name angular.service.filter.filter
* @function
*
* @description
@@ -44,7 +44,7 @@
Search: <input ng:model="searchText"/>
<table id="searchTextResults">
<tr><th>Name</th><th>Phone</th><tr>
- <tr ng:repeat="friend in friends.$filter(searchText)">
+ <tr ng:repeat="friend in friends | filter:searchText">
<td>{{friend.name}}</td>
<td>{{friend.phone}}</td>
<tr>
@@ -55,7 +55,7 @@
Phone only <input ng:model="search.phone"/><br>
<table id="searchObjResults">
<tr><th>Name</th><th>Phone</th><tr>
- <tr ng:repeat="friend in friends.$filter(search)">
+ <tr ng:repeat="friend in friends | filter:search">
<td>{{friend.name}}</td>
<td>{{friend.phone}}</td>
<tr>
diff --git a/src/service/filter/filters.js b/src/service/filter/filters.js
index a411bf03..1034896b 100644
--- a/src/service/filter/filters.js
+++ b/src/service/filter/filters.js
@@ -40,8 +40,6 @@
* @param {string=} symbol Currency symbol or identifier to be displayed.
* @returns {string} Formatted number.
*
- * @css ng-format-negative
- * When the value is negative, this css class is applied to the binding making it (by default) red.
*
* @example
<doc:example>
@@ -66,8 +64,6 @@
input('amount').enter('-1234');
expect(binding('amount | currency')).toBe('($1,234.00)');
expect(binding('amount | currency:"USD$"')).toBe('(USD$1,234.00)');
- expect(element('.doc-example-live .ng-binding').prop('className')).
- toMatch(/ng-format-negative/);
});
</doc:scenario>
</doc:example>
diff --git a/src/service/filter/limitTo.js b/src/service/filter/limitTo.js
index 9bb5cf4d..219322f4 100644
--- a/src/service/filter/limitTo.js
+++ b/src/service/filter/limitTo.js
@@ -2,7 +2,7 @@
/**
* @ngdoc function
- * @name angular.Array.limitTo
+ * @name angular.service.filter.limitTo
* @function
*
* @description
@@ -32,23 +32,23 @@
</script>
<div ng:controller="Ctrl">
Limit {{numbers}} to: <input type="integer" ng:model="limit"/>
- <p>Output: {{ numbers.$limitTo(limit) | json }}</p>
+ <p>Output: {{ numbers | limitTo:limit | json }}</p>
</div>
</doc:source>
<doc:scenario>
it('should limit the numer array to first three items', function() {
expect(element('.doc-example-live input[ng\\:model=limit]').val()).toBe('3');
- expect(binding('numbers.$limitTo(limit) | json')).toEqual('[1,2,3]');
+ expect(binding('numbers | limitTo:limit | json')).toEqual('[1,2,3]');
});
it('should update the output when -3 is entered', function() {
input('limit').enter(-3);
- expect(binding('numbers.$limitTo(limit) | json')).toEqual('[7,8,9]');
+ expect(binding('numbers | limitTo:limit | json')).toEqual('[7,8,9]');
});
it('should not exceed the maximum size of input array', function() {
input('limit').enter(100);
- expect(binding('numbers.$limitTo(limit) | json')).toEqual('[1,2,3,4,5,6,7,8,9]');
+ expect(binding('numbers | limitTo:limit | json')).toEqual('[1,2,3,4,5,6,7,8,9]');
});
</doc:scenario>
</doc:example>
diff --git a/src/service/filter/orderBy.js b/src/service/filter/orderBy.js
index 07c69af3..08b86743 100644
--- a/src/service/filter/orderBy.js
+++ b/src/service/filter/orderBy.js
@@ -53,7 +53,7 @@
<th><a href="" ng:click="predicate = 'phone'; reverse=!reverse">Phone Number</a></th>
<th><a href="" ng:click="predicate = 'age'; reverse=!reverse">Age</a></th>
<tr>
- <tr ng:repeat="friend in friends.$orderBy(predicate, reverse)">
+ <tr ng:repeat="friend in friends | orderBy:predicate:reverse">
<td>{{friend.name}}</td>
<td>{{friend.phone}}</td>
<td>{{friend.age}}</td>
diff --git a/src/service/formFactory.js b/src/service/formFactory.js
index 972b46ee..8ba8ce79 100644
--- a/src/service/formFactory.js
+++ b/src/service/formFactory.js
@@ -29,9 +29,9 @@
this.html = '<b>Hello</b> <i>World</i>!';
}
- function HTMLEditorWidget(element) {
+ HTMLEditorWidget.$inject = ['$element', 'html$Filter'];
+ function HTMLEditorWidget(element, htmlFilter) {
var self = this;
- var htmlFilter = angular.filter('html');
this.$parseModel = function() {
// need to protect for script injection
@@ -59,7 +59,7 @@
}
angular.directive('ng:contenteditable', function() {
- function linkFn($formFactory, element) {
+ return ['$formFactory', '$element', function ($formFactory, element) {
var exp = element.attr('ng:contenteditable'),
form = $formFactory.forElement(element),
widget;
@@ -68,14 +68,12 @@
scope: this,
model: exp,
controller: HTMLEditorWidget,
- controllerArgs: [element]});
+ controllerArgs: {$element: element}});
// if the element is destroyed, then we need to notify the form.
element.bind('$destroy', function() {
widget.$destroy();
});
- }
- linkFn.$inject = ['$formFactory'];
- return linkFn;
+ }];
});
</script>
<form name='editorForm' ng:controller="EditorCntl">