From cb6f832f38b11499a6d1dd2caf14d15e68211635 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Thu, 3 Nov 2011 15:59:18 -0700 Subject: refactor(filter): filters are now injectable and services BREAK: - removed CSS support from filters --- test/directivesSpec.js | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) (limited to 'test/directivesSpec.js') 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('
hello
'); })); - 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('hello'); - }; + })); var element = $compile('
')($rootScope); $rootScope.$digest(); expect(lowercase(element.html())).toEqual('hello'); })); - 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('
before
after
')($rootScope); - $rootScope.$digest(); - expect(sortedHtml(element)).toEqual('
before
HELLO
after
'); - })); - it('should suppress rendering of falsy values', inject(function($rootScope, $compile) { var element = $compile('
{{ null }}{{ undefined }}{{ "" }}-{{ 0 }}{{ false }}
')($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('
beforeINNERafter
')($rootScope); $rootScope.$digest(); expect(element.text()).toEqual("beforeHELLOafter"); -- cgit v1.2.3