Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
fix(tests): update mdCompiler to support unwrapped simple text nodes
Browse files Browse the repository at this point in the history
* 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 `<span>hola</span>` is of course, `"hola"` But the inner HTML of `"hola"` is `undefined`

[
  • Loading branch information
ThomasBurleson committed Mar 6, 2016
1 parent 737692f commit 36df9b9
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/core/services/compiler/compiler.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,25 @@ describe('$mdCompiler service', function() {
describe('setup', function() {

it('element should use templateUrl', inject(function($templateCache) {
var tpl = 'hola';
var tpl = '<span>hola</span>';
$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() {
var tpl = 'hello';
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() {
Expand All @@ -43,15 +48,15 @@ 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() {
var data = compile({
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() {
Expand All @@ -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() {
Expand Down

0 comments on commit 36df9b9

Please sign in to comment.