From 9ee2cdff44e7d496774b340de816344126c457b3 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Tue, 22 Nov 2011 21:28:39 -0800 Subject: refactor(directives): connect new compiler - turn everything into a directive --- test/AngularSpec.js | 49 ++++++++++++++++++++----------------------------- 1 file changed, 20 insertions(+), 29 deletions(-) (limited to 'test/AngularSpec.js') diff --git a/test/AngularSpec.js b/test/AngularSpec.js index 2d469698..10f5fd2a 100644 --- a/test/AngularSpec.js +++ b/test/AngularSpec.js @@ -1,6 +1,12 @@ 'use strict'; describe('angular', function() { + var element; + + afterEach(function(){ + dealoc(element); + }); + describe('case', function() { it('should change case', function() { expect(lowercase('ABC90')).toEqual('abc90'); @@ -382,28 +388,6 @@ describe('angular', function() { }); - describe('directive', function() { - it('should register directives with case-insensitive id', inject(function($compile) { - angularDirective('ALLCAPS', function(val, el) {el.text('+' + val + '+')}); - angularDirective('lowercase', function(val, el) {el.text('-' + val + '-')}); - - var el = jqLite('
' + - '' + - '' + - '' + - 'xx4' + - '
'); - $compile(el); - expect(lowercase(sortedHtml(el))).toBe('
' + - '+xx1+' + - '+xx2+' + - '+xx3+' + - '-xx4-' + - '
'); - })); - }); - - describe('isDate', function() { it('should return true for Date object', function() { expect(isDate(new Date())).toBe(true); @@ -420,7 +404,7 @@ describe('angular', function() { describe('compile', function() { it('should link to existing node and create scope', inject(function($rootScope, $compile) { var template = angular.element('
{{greeting = "hello world"}}
'); - $compile(template)($rootScope); + element = $compile(template)($rootScope); $rootScope.$digest(); expect(template.text()).toEqual('hello world'); expect($rootScope.greeting).toEqual('hello world'); @@ -428,7 +412,7 @@ describe('angular', function() { it('should link to existing node and given scope', inject(function($rootScope, $compile) { var template = angular.element('
{{greeting = "hello world"}}
'); - $compile(template)($rootScope); + element = $compile(template)($rootScope); $rootScope.$digest(); expect(template.text()).toEqual('hello world'); })); @@ -436,15 +420,15 @@ describe('angular', function() { it('should link to new node and given scope', inject(function($rootScope, $compile) { var template = jqLite('
{{greeting = "hello world"}}
'); - var templateFn = $compile(template); + var compile = $compile(template); var templateClone = template.clone(); - var element = templateFn($rootScope, function(clone){ + element = compile($rootScope, function(clone){ templateClone = clone; }); $rootScope.$digest(); - expect(template.text()).toEqual(''); + expect(template.text()).toEqual('{{greeting = "hello world"}}'); expect(element.text()).toEqual('hello world'); expect(element).toEqual(templateClone); expect($rootScope.greeting).toEqual('hello world'); @@ -452,9 +436,9 @@ describe('angular', function() { it('should link to cloned node and create scope', inject(function($rootScope, $compile) { var template = jqLite('
{{greeting = "hello world"}}
'); - var element = $compile(template)($rootScope, noop); + element = $compile(template)($rootScope, noop); $rootScope.$digest(); - expect(template.text()).toEqual(''); + expect(template.text()).toEqual('{{greeting = "hello world"}}'); expect(element.text()).toEqual('hello world'); expect($rootScope.greeting).toEqual('hello world'); })); @@ -524,4 +508,11 @@ describe('angular', function() { expect(startingTag('
text
')).toEqual(''); }); }); + + describe('snake_case', function(){ + it('should convert to snake_case', function() { + expect(snake_case('ABC')).toEqual('a_b_c'); + expect(snake_case('alanBobCharles')).toEqual('alan_bob_charles'); + }); + }); }); -- cgit v1.2.3