aboutsummaryrefslogtreecommitdiffstats
path: root/test/directivesSpec.js
diff options
context:
space:
mode:
authorMisko Hevery2011-11-03 15:59:18 -0700
committerMisko Hevery2011-11-14 20:31:09 -0800
commitcb6f832f38b11499a6d1dd2caf14d15e68211635 (patch)
treeadb837d60cb080712319122d3a7103e20e07c2e0 /test/directivesSpec.js
parent6022f3df399a5d98830dfe7904f0ad2baaa308c7 (diff)
downloadangular.js-cb6f832f38b11499a6d1dd2caf14d15e68211635.tar.bz2
refactor(filter): filters are now injectable and services
BREAK: - removed CSS support from filters
Diffstat (limited to 'test/directivesSpec.js')
-rw-r--r--test/directivesSpec.js22
1 files changed, 6 insertions, 16 deletions
diff --git a/test/directivesSpec.js b/test/directivesSpec.js
index 7acf87bc..93682fa0 100644
--- a/test/directivesSpec.js
+++ b/test/directivesSpec.js
@@ -41,25 +41,15 @@ describe("directive", function() {
expect(lowercase(element.html())).toEqual('<div onclick="">hello</div>');
}));
- it('should set element element', inject(function($rootScope, $compile) {
- angularFilter.myElement = function() {
+ it('should set element element', inject(function($rootScope, $compile, $provide) {
+ $provide.filter('myElement', valueFn(function() {
return jqLite('<a>hello</a>');
- };
+ }));
var element = $compile('<div ng:bind="0|myElement"></div>')($rootScope);
$rootScope.$digest();
expect(lowercase(element.html())).toEqual('<a>hello</a>');
}));
- it('should have $element set to current bind element', inject(function($rootScope, $compile) {
- angularFilter.myFilter = function() {
- this.$element.addClass("filter");
- return 'HELLO';
- };
- var element = $compile('<div>before<div ng:bind="0|myFilter"></div>after</div>')($rootScope);
- $rootScope.$digest();
- expect(sortedHtml(element)).toEqual('<div>before<div class="filter" ng:bind="0|myFilter">HELLO</div>after</div>');
- }));
-
it('should suppress rendering of falsy values', inject(function($rootScope, $compile) {
var element = $compile('<div>{{ null }}{{ undefined }}{{ "" }}-{{ 0 }}{{ false }}</div>')($rootScope);
@@ -83,12 +73,12 @@ describe("directive", function() {
expect(element.text()).toEqual('Hello Misko!');
}));
- it('should have $element set to current bind element', inject(function($rootScope, $compile) {
+ it('should have $element set to current bind element', inject(function($rootScope, $compile, $provide) {
var innerText;
- angularFilter.myFilter = function(text) {
+ $provide.filter('myFilter', valueFn(function(text) {
innerText = innerText || this.$element.text();
return text;
- };
+ }));
var element = $compile('<div>before<span ng:bind-template="{{\'HELLO\'|myFilter}}">INNER</span>after</div>')($rootScope);
$rootScope.$digest();
expect(element.text()).toEqual("beforeHELLOafter");