From 36df9b9bb72426668a5bae61efe8e4456b715aa2 Mon Sep 17 00:00:00 2001 From: Thomas Burleson Date: Sun, 6 Mar 2016 17:04:20 -0600 Subject: [PATCH] fix(tests): update mdCompiler to support unwrapped simple text nodes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Angular compiler (1.5.1 and newer) no longer wraps simple top level text nodes in a span when compiling a template. `.html()` returns the “inner” HTML, which for `hola` is of course, `"hola"` But the inner HTML of `"hola"` is `undefined` [ --- src/core/services/compiler/compiler.spec.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/core/services/compiler/compiler.spec.js b/src/core/services/compiler/compiler.spec.js index bf8d956f1bb..b196dfc7856 100644 --- a/src/core/services/compiler/compiler.spec.js +++ b/src/core/services/compiler/compiler.spec.js @@ -15,12 +15,13 @@ describe('$mdCompiler service', function() { describe('setup', function() { it('element should use templateUrl', inject(function($templateCache) { - var tpl = 'hola'; + var tpl = 'hola'; $templateCache.put('template.html', tpl); var data = compile({ templateUrl: 'template.html' }); - expect(data.element.html()).toBe(tpl); + + expect(data.element.html()).toBe('hola'); })); it('element should use template', function() { @@ -28,7 +29,11 @@ describe('$mdCompiler service', function() { var data = compile({ template: tpl }); - expect(data.element.html()).toBe(tpl); + + // .html() returns the “inner” HTML + // but inner HTML of "hello" is `undefined` + // so use .text() + expect(data.element.text()).toBe(tpl); }); it('should support a custom element', function() { @@ -43,7 +48,7 @@ describe('$mdCompiler service', function() { var data = compile({ template: tpl }); - expect(data.element.html()).toBe('hello'); + expect(data.element.text()).toBe('hello'); }); it('transformTemplate should work with template', function() { @@ -51,7 +56,7 @@ describe('$mdCompiler service', function() { template: 'world', transformTemplate: function(tpl) { return 'hello ' + tpl; } }); - expect(data.element.html()).toBe('hello world'); + expect(data.element.text()).toBe('hello world'); }); it('transformTemplate receives the options', function() { @@ -60,7 +65,7 @@ describe('$mdCompiler service', function() { someArg: 'foo', transformTemplate: function(tpl, options) { return 'hello ' + tpl + ': ' + options.someArg; } }); - expect(data.element.html()).toBe('hello world: foo'); + expect(data.element.text()).toBe('hello world: foo'); }); describe('with resolve and locals options', function() {