From 9abd10e7b8a34b9dcd1a6af5ff37f57bd27cf920 Mon Sep 17 00:00:00 2001
From: Misko Hevery
Date: Thu, 15 Jul 2010 13:13:21 -0700
Subject: proper handlig of $element in filters
---
test/directivesSpec.js | 72 ++++++++++++++++++++++++++++++++------------------
1 file changed, 47 insertions(+), 25 deletions(-)
(limited to 'test')
diff --git a/test/directivesSpec.js b/test/directivesSpec.js
index a42faa9a..b6ccf764 100644
--- a/test/directivesSpec.js
+++ b/test/directivesSpec.js
@@ -29,35 +29,57 @@ describe("directives", function(){
expect(scope.a).toEqual(2);
});
- it('should ng:bind', function() {
- var scope = compile('
');
- expect(element.text()).toEqual('');
- scope.a = 'misko';
- scope.$eval();
- expect(element.text()).toEqual('misko');
- });
+ describe('ng:bind', function(){
+ it('should set text', function() {
+ var scope = compile('');
+ expect(element.text()).toEqual('');
+ scope.a = 'misko';
+ scope.$eval();
+ expect(element.text()).toEqual('misko');
+ });
- it('should ng:bind html', function() {
- var scope = compile('');
- scope.html = 'hello
';
- scope.$eval();
- expect(lowercase(element.html())).toEqual('hello
');
- });
+ it('should set html', function() {
+ var scope = compile('');
+ scope.html = 'hello
';
+ scope.$eval();
+ expect(lowercase(element.html())).toEqual('hello
');
+ });
+
+ it('should set element element', function() {
+ angularFilter.myElement = function() {
+ return jqLite('hello');
+ };
+ var scope = compile('');
+ scope.$eval();
+ expect(lowercase(element.html())).toEqual('hello');
+ });
+
+ it('should have $element set to current bind element', function(){
+ angularFilter.myFilter = function(){
+ this.$element.text('HELLO');
+ };
+ var scope = compile('');
+ expect(scope.$element.text()).toEqual("beforeHELLOafter");
+ });
- it('should ng:bind element', function() {
- angularFilter.myElement = function() {
- return jqLite('hello');
- };
- var scope = compile('');
- scope.$eval();
- expect(lowercase(element.html())).toEqual('hello');
});
- it('should ng:bind-template', function() {
- var scope = compile('');
- scope.$set('name', 'Misko');
- scope.$eval();
- expect(element.text()).toEqual('Hello Misko!');
+ describe('ng:bind-template', function(){
+ it('should ng:bind-template', function() {
+ var scope = compile('');
+ scope.$set('name', 'Misko');
+ scope.$eval();
+ expect(element.text()).toEqual('Hello Misko!');
+ });
+
+ it('should have $element set to current bind element', function(){
+ angularFilter.myFilter = function(){
+ this.$element.text('HELLO');
+ };
+ var scope = compile('');
+ expect(scope.$element.text()).toEqual("beforeHELLOafter");
+ });
+
});
it('should ng:bind-attr', function(){
--
cgit v1.2.3