diff options
| author | Misko Hevery | 2010-10-26 22:02:24 -0700 |
|---|---|---|
| committer | Misko Hevery | 2010-10-27 15:42:46 -0700 |
| commit | 62c0e5c46091d8b98a20c31ab26e715bad574bae (patch) | |
| tree | 18e73b82cb9017b9e9b66d3ec094c53ce0b633a8 /test | |
| parent | c67af8a03819004c4aaa775805badd1e631af738 (diff) | |
| download | angular.js-62c0e5c46091d8b98a20c31ab26e715bad574bae.tar.bz2 | |
Fix failing tests for ie, and mark elements as ng-widget, ng-directive, and ng-binding
Diffstat (limited to 'test')
| -rw-r--r-- | test/CompilerSpec.js | 6 | ||||
| -rw-r--r-- | test/directivesSpec.js | 2 | ||||
| -rw-r--r-- | test/scenario/dslSpec.js | 6 | ||||
| -rw-r--r-- | test/testabilityPatch.js | 12 |
4 files changed, 18 insertions, 8 deletions
diff --git a/test/CompilerSpec.js b/test/CompilerSpec.js index 59c365e4..780fd7cb 100644 --- a/test/CompilerSpec.js +++ b/test/CompilerSpec.js @@ -46,6 +46,7 @@ describe('compiler', function(){ var init = template(e).$init; expect(log).toEqual("found"); init(); + expect(e.hasClass('ng-directive')).toEqual(true); expect(log).toEqual("found:init"); }); @@ -102,12 +103,13 @@ describe('compiler', function(){ } }); var scope = compile('before<span>middle</span>after'); - expect(lowercase(scope.$element[0].innerHTML)).toEqual('before<span hello="middle">replaced</span>after'); + expect(sortedHtml(scope.$element[0], true)).toEqual('<div>before<span class="ng-directive" hello="middle">replaced</span>after</div>'); expect(log).toEqual("hello middle"); }); it('should replace widgets', function(){ widgets['NG:BUTTON'] = function(element) { + expect(element.hasClass('ng-widget')).toEqual(true); element.replaceWith('<div>button</div>'); return function(element) { log += 'init'; @@ -120,6 +122,8 @@ describe('compiler', function(){ it('should use the replaced element after calling widget', function(){ widgets['H1'] = function(element) { + // HTML elements which are augmented by acting as widgets, should not be marked as so + expect(element.hasClass('ng-widget')).toEqual(false); var span = angular.element('<span>{{1+2}}</span>'); element.replaceWith(span); this.descend(true); diff --git a/test/directivesSpec.js b/test/directivesSpec.js index fa2abd46..2e5aa2a0 100644 --- a/test/directivesSpec.js +++ b/test/directivesSpec.js @@ -35,6 +35,7 @@ describe("directives", function(){ expect(element.text()).toEqual(''); scope.a = 'misko'; scope.$eval(); + expect(element.hasClass('ng-binding')).toEqual(true); expect(element.text()).toEqual('misko'); }); @@ -87,6 +88,7 @@ describe("directives", function(){ var scope = compile('<div ng:bind-template="Hello {{name}}!"></div>'); scope.$set('name', 'Misko'); scope.$eval(); + expect(element.hasClass('ng-binding')).toEqual(true); expect(element.text()).toEqual('Hello Misko!'); }); diff --git a/test/scenario/dslSpec.js b/test/scenario/dslSpec.js index efedeeb5..3d68925f 100644 --- a/test/scenario/dslSpec.js +++ b/test/scenario/dslSpec.js @@ -260,15 +260,13 @@ describe("angular.scenario.dsl", function() { describe('Binding', function() { it('should select binding by name', function() { - if (msie) return; // TODO reenable! - doc.append('<span ng:bind="foo.bar">some value</span>'); + doc.append('<span class="ng-binding" ng:bind="foo.bar">some value</span>'); $root.dsl.binding('foo.bar'); expect($root.futureResult).toEqual('some value'); }); it('should select binding in template by name', function() { - if (msie) return; // TODO reenable! - doc.append('<pre ng:bind-template="foo {{bar}} baz">foo some baz</pre>'); + doc.append('<pre class="ng-binding" ng:bind-template="foo {{bar}} baz">foo some baz</pre>'); $root.dsl.binding('bar'); expect($root.futureResult).toEqual('foo some baz'); }); diff --git a/test/testabilityPatch.js b/test/testabilityPatch.js index 5c6eaf4d..e8041ac7 100644 --- a/test/testabilityPatch.js +++ b/test/testabilityPatch.js @@ -81,7 +81,7 @@ extend(angular, { }); -function sortedHtml(element) { +function sortedHtml(element, showNgClass) { var html = ""; foreach(jqLite(element), function toString(node) { if (node.nodeName == "#text") { @@ -93,8 +93,14 @@ function sortedHtml(element) { html += '<' + node.nodeName.toLowerCase(); var attributes = node.attributes || []; var attrs = []; - if (node.className) - attrs.push(' class="' + node.className + '"'); + var className = node.className || ''; + if (!showNgClass) { + className = className.replace(/ng-[\w-]+\s*/g, ''); + } + className = trim(className); + if (className) { + attrs.push(' class="' + className + '"'); + } for(var i=0; i<attributes.length; i++) { var attr = attributes[i]; if(attr.name.match(/^ng:/) || |
