2016-04-12 12:40:37 -04:00
|
|
|
import {
|
|
|
|
beforeEach,
|
|
|
|
ddescribe,
|
|
|
|
describe,
|
|
|
|
expect,
|
|
|
|
iit,
|
|
|
|
inject,
|
|
|
|
it,
|
|
|
|
xit,
|
|
|
|
beforeEachProviders
|
2016-04-28 20:50:03 -04:00
|
|
|
} from '@angular/core/testing/testing_internal';
|
|
|
|
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
|
|
|
import {CompileTypeMetadata, CompileTemplateMetadata} from '@angular/compiler/src/compile_metadata';
|
|
|
|
import {ViewEncapsulation} from '@angular/core/src/metadata/view';
|
2016-04-12 12:40:37 -04:00
|
|
|
|
2016-04-28 20:50:03 -04:00
|
|
|
import {DirectiveNormalizer} from '@angular/compiler/src/directive_normalizer';
|
|
|
|
import {XHR} from '@angular/compiler/src/xhr';
|
|
|
|
import {MockXHR} from '@angular/compiler/testing';
|
2015-10-11 01:11:13 -04:00
|
|
|
import {TEST_PROVIDERS} from './test_bindings';
|
2015-09-14 18:59:09 -04:00
|
|
|
|
|
|
|
export function main() {
|
2016-01-06 17:13:44 -05:00
|
|
|
describe('DirectiveNormalizer', () => {
|
2015-09-18 13:33:23 -04:00
|
|
|
var dirType: CompileTypeMetadata;
|
2015-09-14 18:59:09 -04:00
|
|
|
|
2015-11-11 08:28:23 -05:00
|
|
|
beforeEachProviders(() => TEST_PROVIDERS);
|
2015-09-14 18:59:09 -04:00
|
|
|
|
2016-04-29 00:54:02 -04:00
|
|
|
beforeEach(() => { dirType = new CompileTypeMetadata({name: 'SomeComp'}); });
|
2015-09-14 18:59:09 -04:00
|
|
|
|
|
|
|
describe('loadTemplate', () => {
|
|
|
|
describe('inline template', () => {
|
|
|
|
it('should store the template',
|
2016-01-06 17:13:44 -05:00
|
|
|
inject([AsyncTestCompleter, DirectiveNormalizer],
|
|
|
|
(async, normalizer: DirectiveNormalizer) => {
|
2016-04-12 12:40:37 -04:00
|
|
|
normalizer.normalizeTemplate(dirType, new CompileTemplateMetadata({
|
|
|
|
encapsulation: null,
|
|
|
|
template: 'a',
|
|
|
|
templateUrl: null,
|
|
|
|
styles: [],
|
2016-04-29 00:54:02 -04:00
|
|
|
styleUrls: ['test.css'],
|
|
|
|
baseUrl: 'package:some/module/a.js'
|
2016-04-12 12:40:37 -04:00
|
|
|
}))
|
|
|
|
.then((template: CompileTemplateMetadata) => {
|
|
|
|
expect(template.template).toEqual('a');
|
|
|
|
expect(template.templateUrl).toEqual('package:some/module/a.js');
|
|
|
|
async.done();
|
|
|
|
});
|
|
|
|
}));
|
2015-09-14 18:59:09 -04:00
|
|
|
|
2016-04-29 00:54:02 -04:00
|
|
|
it('should resolve styles on the annotation against the baseUrl',
|
2016-01-06 17:13:44 -05:00
|
|
|
inject([AsyncTestCompleter, DirectiveNormalizer],
|
|
|
|
(async, normalizer: DirectiveNormalizer) => {
|
2016-04-12 12:40:37 -04:00
|
|
|
normalizer.normalizeTemplate(dirType, new CompileTemplateMetadata({
|
|
|
|
encapsulation: null,
|
|
|
|
template: '',
|
|
|
|
templateUrl: null,
|
|
|
|
styles: [],
|
2016-04-29 00:54:02 -04:00
|
|
|
styleUrls: ['test.css'],
|
|
|
|
baseUrl: 'package:some/module/a.js'
|
2016-04-12 12:40:37 -04:00
|
|
|
}))
|
|
|
|
.then((template: CompileTemplateMetadata) => {
|
|
|
|
expect(template.styleUrls).toEqual(['package:some/module/test.css']);
|
|
|
|
async.done();
|
|
|
|
});
|
|
|
|
}));
|
2015-09-14 18:59:09 -04:00
|
|
|
|
2016-04-29 00:54:02 -04:00
|
|
|
it('should resolve styles in the template against the baseUrl',
|
2016-01-06 17:13:44 -05:00
|
|
|
inject([AsyncTestCompleter, DirectiveNormalizer],
|
|
|
|
(async, normalizer: DirectiveNormalizer) => {
|
2016-04-12 12:40:37 -04:00
|
|
|
normalizer.normalizeTemplate(dirType, new CompileTemplateMetadata({
|
|
|
|
encapsulation: null,
|
|
|
|
template: '<style>@import test.css</style>',
|
|
|
|
templateUrl: null,
|
|
|
|
styles: [],
|
2016-04-29 00:54:02 -04:00
|
|
|
styleUrls: [],
|
|
|
|
baseUrl: 'package:some/module/a.js'
|
2016-04-12 12:40:37 -04:00
|
|
|
}))
|
|
|
|
.then((template: CompileTemplateMetadata) => {
|
|
|
|
expect(template.styleUrls).toEqual(['package:some/module/test.css']);
|
|
|
|
async.done();
|
|
|
|
});
|
|
|
|
}));
|
2015-09-14 18:59:09 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
describe('templateUrl', () => {
|
|
|
|
|
2016-04-29 00:54:02 -04:00
|
|
|
it('should load a template from a url that is resolved against baseUrl',
|
2016-01-06 17:13:44 -05:00
|
|
|
inject([AsyncTestCompleter, DirectiveNormalizer, XHR],
|
|
|
|
(async, normalizer: DirectiveNormalizer, xhr: MockXHR) => {
|
2016-04-12 12:40:37 -04:00
|
|
|
xhr.expect('package:some/module/sometplurl.html', 'a');
|
|
|
|
normalizer.normalizeTemplate(dirType, new CompileTemplateMetadata({
|
|
|
|
encapsulation: null,
|
|
|
|
template: null,
|
|
|
|
templateUrl: 'sometplurl.html',
|
|
|
|
styles: [],
|
2016-04-29 00:54:02 -04:00
|
|
|
styleUrls: ['test.css'],
|
|
|
|
baseUrl: 'package:some/module/a.js'
|
2016-04-12 12:40:37 -04:00
|
|
|
}))
|
|
|
|
.then((template: CompileTemplateMetadata) => {
|
|
|
|
expect(template.template).toEqual('a');
|
|
|
|
expect(template.templateUrl)
|
|
|
|
.toEqual('package:some/module/sometplurl.html');
|
|
|
|
async.done();
|
|
|
|
});
|
|
|
|
xhr.flush();
|
|
|
|
}));
|
2015-09-14 18:59:09 -04:00
|
|
|
|
2016-04-29 00:54:02 -04:00
|
|
|
it('should resolve styles on the annotation against the baseUrl',
|
2016-01-06 17:13:44 -05:00
|
|
|
inject([AsyncTestCompleter, DirectiveNormalizer, XHR],
|
|
|
|
(async, normalizer: DirectiveNormalizer, xhr: MockXHR) => {
|
2016-04-12 12:40:37 -04:00
|
|
|
xhr.expect('package:some/module/tpl/sometplurl.html', '');
|
|
|
|
normalizer.normalizeTemplate(dirType, new CompileTemplateMetadata({
|
|
|
|
encapsulation: null,
|
|
|
|
template: null,
|
|
|
|
templateUrl: 'tpl/sometplurl.html',
|
|
|
|
styles: [],
|
2016-04-29 00:54:02 -04:00
|
|
|
styleUrls: ['test.css'],
|
|
|
|
baseUrl: 'package:some/module/a.js'
|
2016-04-12 12:40:37 -04:00
|
|
|
}))
|
|
|
|
.then((template: CompileTemplateMetadata) => {
|
|
|
|
expect(template.styleUrls).toEqual(['package:some/module/test.css']);
|
|
|
|
async.done();
|
|
|
|
});
|
|
|
|
xhr.flush();
|
|
|
|
}));
|
2015-09-14 18:59:09 -04:00
|
|
|
|
|
|
|
it('should resolve styles in the template against the templateUrl',
|
2016-01-06 17:13:44 -05:00
|
|
|
inject([AsyncTestCompleter, DirectiveNormalizer, XHR],
|
|
|
|
(async, normalizer: DirectiveNormalizer, xhr: MockXHR) => {
|
2016-04-12 12:40:37 -04:00
|
|
|
xhr.expect('package:some/module/tpl/sometplurl.html',
|
|
|
|
'<style>@import test.css</style>');
|
|
|
|
normalizer.normalizeTemplate(dirType, new CompileTemplateMetadata({
|
|
|
|
encapsulation: null,
|
|
|
|
template: null,
|
|
|
|
templateUrl: 'tpl/sometplurl.html',
|
|
|
|
styles: [],
|
2016-04-29 00:54:02 -04:00
|
|
|
styleUrls: [],
|
|
|
|
baseUrl: 'package:some/module/a.js'
|
2016-04-12 12:40:37 -04:00
|
|
|
}))
|
|
|
|
.then((template: CompileTemplateMetadata) => {
|
|
|
|
expect(template.styleUrls).toEqual(['package:some/module/tpl/test.css']);
|
|
|
|
async.done();
|
|
|
|
});
|
|
|
|
xhr.flush();
|
|
|
|
}));
|
2015-09-14 18:59:09 -04:00
|
|
|
|
|
|
|
});
|
|
|
|
|
2015-09-18 13:33:23 -04:00
|
|
|
it('should throw if no template was specified',
|
2016-01-06 17:13:44 -05:00
|
|
|
inject([DirectiveNormalizer], (normalizer: DirectiveNormalizer) => {
|
2016-04-12 12:40:37 -04:00
|
|
|
expect(() => normalizer.normalizeTemplate(
|
|
|
|
dirType, new CompileTemplateMetadata(
|
|
|
|
{encapsulation: null, styles: [], styleUrls: []})))
|
2015-09-18 13:33:23 -04:00
|
|
|
.toThrowError('No template specified for component SomeComp');
|
|
|
|
}));
|
|
|
|
|
2015-09-14 18:59:09 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
describe('normalizeLoadedTemplate', () => {
|
|
|
|
it('should store the viewEncapsulationin the result',
|
2016-01-06 17:13:44 -05:00
|
|
|
inject([DirectiveNormalizer], (normalizer: DirectiveNormalizer) => {
|
2015-09-14 18:59:09 -04:00
|
|
|
|
|
|
|
var viewEncapsulation = ViewEncapsulation.Native;
|
2016-04-29 00:54:02 -04:00
|
|
|
var template = normalizer.normalizeLoadedTemplate(dirType, new CompileTemplateMetadata({
|
|
|
|
encapsulation: viewEncapsulation,
|
|
|
|
styles: [],
|
|
|
|
styleUrls: [],
|
|
|
|
baseUrl: 'package:some/module/a.js'
|
|
|
|
}),
|
|
|
|
'', 'package:some/module/');
|
2015-09-14 18:59:09 -04:00
|
|
|
expect(template.encapsulation).toBe(viewEncapsulation);
|
|
|
|
}));
|
|
|
|
|
|
|
|
it('should keep the template as html',
|
2016-01-06 17:13:44 -05:00
|
|
|
inject([DirectiveNormalizer], (normalizer: DirectiveNormalizer) => {
|
2016-04-29 00:54:02 -04:00
|
|
|
var template = normalizer.normalizeLoadedTemplate(dirType, new CompileTemplateMetadata({
|
|
|
|
encapsulation: null,
|
|
|
|
styles: [],
|
|
|
|
styleUrls: [],
|
|
|
|
baseUrl: 'package:some/module/a.js'
|
|
|
|
}),
|
|
|
|
'a', 'package:some/module/');
|
2015-09-14 18:59:09 -04:00
|
|
|
expect(template.template).toEqual('a')
|
|
|
|
}));
|
|
|
|
|
2015-09-18 13:33:23 -04:00
|
|
|
it('should collect ngContent',
|
2016-01-06 17:13:44 -05:00
|
|
|
inject([DirectiveNormalizer], (normalizer: DirectiveNormalizer) => {
|
2016-04-29 00:54:02 -04:00
|
|
|
var template = normalizer.normalizeLoadedTemplate(dirType, new CompileTemplateMetadata({
|
|
|
|
encapsulation: null,
|
|
|
|
styles: [],
|
|
|
|
styleUrls: [],
|
|
|
|
baseUrl: 'package:some/module/a.js'
|
|
|
|
}),
|
|
|
|
'<ng-content select="a"></ng-content>',
|
|
|
|
'package:some/module/');
|
2015-09-14 18:59:09 -04:00
|
|
|
expect(template.ngContentSelectors).toEqual(['a']);
|
|
|
|
}));
|
|
|
|
|
|
|
|
it('should normalize ngContent wildcard selector',
|
2016-01-06 17:13:44 -05:00
|
|
|
inject([DirectiveNormalizer], (normalizer: DirectiveNormalizer) => {
|
2015-09-14 18:59:09 -04:00
|
|
|
var template = normalizer.normalizeLoadedTemplate(
|
2016-04-29 00:54:02 -04:00
|
|
|
dirType, new CompileTemplateMetadata({
|
|
|
|
encapsulation: null,
|
|
|
|
styles: [],
|
|
|
|
styleUrls: [],
|
|
|
|
baseUrl: 'package:some/module/a.js'
|
|
|
|
}),
|
2015-09-14 18:59:09 -04:00
|
|
|
'<ng-content></ng-content><ng-content select></ng-content><ng-content select="*"></ng-content>',
|
2015-10-01 13:07:49 -04:00
|
|
|
'package:some/module/');
|
2015-09-14 18:59:09 -04:00
|
|
|
expect(template.ngContentSelectors).toEqual(['*', '*', '*']);
|
|
|
|
}));
|
|
|
|
|
2015-09-18 13:33:23 -04:00
|
|
|
it('should collect top level styles in the template',
|
2016-01-06 17:13:44 -05:00
|
|
|
inject([DirectiveNormalizer], (normalizer: DirectiveNormalizer) => {
|
2016-04-29 00:54:02 -04:00
|
|
|
var template =
|
|
|
|
normalizer.normalizeLoadedTemplate(dirType, new CompileTemplateMetadata({
|
|
|
|
encapsulation: null,
|
|
|
|
styles: [],
|
|
|
|
styleUrls: [],
|
|
|
|
baseUrl: 'package:some/module/a.js'
|
|
|
|
}),
|
|
|
|
'<style>a</style>', 'package:some/module/');
|
2015-09-14 18:59:09 -04:00
|
|
|
expect(template.styles).toEqual(['a']);
|
|
|
|
}));
|
|
|
|
|
2015-09-18 13:33:23 -04:00
|
|
|
it('should collect styles inside in elements',
|
2016-01-06 17:13:44 -05:00
|
|
|
inject([DirectiveNormalizer], (normalizer: DirectiveNormalizer) => {
|
2016-04-29 00:54:02 -04:00
|
|
|
var template = normalizer.normalizeLoadedTemplate(dirType, new CompileTemplateMetadata({
|
|
|
|
encapsulation: null,
|
|
|
|
styles: [],
|
|
|
|
styleUrls: [],
|
|
|
|
baseUrl: 'package:some/module/a.js'
|
|
|
|
}),
|
|
|
|
'<div><style>a</style></div>',
|
|
|
|
'package:some/module/');
|
2015-09-14 18:59:09 -04:00
|
|
|
expect(template.styles).toEqual(['a']);
|
|
|
|
}));
|
|
|
|
|
2015-09-18 13:33:23 -04:00
|
|
|
it('should collect styleUrls in the template',
|
2016-01-06 17:13:44 -05:00
|
|
|
inject([DirectiveNormalizer], (normalizer: DirectiveNormalizer) => {
|
2016-04-29 00:54:02 -04:00
|
|
|
var template = normalizer.normalizeLoadedTemplate(dirType, new CompileTemplateMetadata({
|
|
|
|
encapsulation: null,
|
|
|
|
styles: [],
|
|
|
|
styleUrls: [],
|
|
|
|
baseUrl: 'package:some/module/a.js'
|
|
|
|
}),
|
|
|
|
'<link rel="stylesheet" href="aUrl">',
|
|
|
|
'package:some/module/');
|
2015-10-01 13:07:49 -04:00
|
|
|
expect(template.styleUrls).toEqual(['package:some/module/aUrl']);
|
2015-09-14 18:59:09 -04:00
|
|
|
}));
|
|
|
|
|
2015-09-18 13:33:23 -04:00
|
|
|
it('should collect styleUrls in elements',
|
2016-01-06 17:13:44 -05:00
|
|
|
inject([DirectiveNormalizer], (normalizer: DirectiveNormalizer) => {
|
2015-09-14 18:59:09 -04:00
|
|
|
var template = normalizer.normalizeLoadedTemplate(
|
2016-04-29 00:54:02 -04:00
|
|
|
dirType, new CompileTemplateMetadata({
|
|
|
|
encapsulation: null,
|
|
|
|
styles: [],
|
|
|
|
styleUrls: [],
|
|
|
|
baseUrl: 'package:some/module/a.js'
|
|
|
|
}),
|
2015-10-01 13:07:49 -04:00
|
|
|
'<div><link rel="stylesheet" href="aUrl"></div>', 'package:some/module/');
|
|
|
|
expect(template.styleUrls).toEqual(['package:some/module/aUrl']);
|
2015-09-14 18:59:09 -04:00
|
|
|
}));
|
|
|
|
|
2015-09-18 13:33:23 -04:00
|
|
|
it('should ignore link elements with non stylesheet rel attribute',
|
2016-01-06 17:13:44 -05:00
|
|
|
inject([DirectiveNormalizer], (normalizer: DirectiveNormalizer) => {
|
2016-04-29 00:54:02 -04:00
|
|
|
var template = normalizer.normalizeLoadedTemplate(dirType, new CompileTemplateMetadata({
|
|
|
|
encapsulation: null,
|
|
|
|
styles: [],
|
|
|
|
styleUrls: [],
|
|
|
|
baseUrl: 'package:some/module/a.js'
|
|
|
|
}),
|
|
|
|
'<link href="b" rel="a">',
|
|
|
|
'package:some/module/');
|
2015-09-18 13:33:23 -04:00
|
|
|
expect(template.styleUrls).toEqual([]);
|
2015-09-14 18:59:09 -04:00
|
|
|
}));
|
|
|
|
|
2015-10-14 12:39:40 -04:00
|
|
|
it('should ignore link elements with absolute urls but non package: scheme',
|
2016-01-06 17:13:44 -05:00
|
|
|
inject([DirectiveNormalizer], (normalizer: DirectiveNormalizer) => {
|
2015-10-14 12:39:40 -04:00
|
|
|
var template = normalizer.normalizeLoadedTemplate(
|
2016-04-29 00:54:02 -04:00
|
|
|
dirType, new CompileTemplateMetadata({
|
|
|
|
encapsulation: null,
|
|
|
|
styles: [],
|
|
|
|
styleUrls: [],
|
|
|
|
baseUrl: 'package:some/module/a.js'
|
|
|
|
}),
|
2015-12-03 18:53:44 -05:00
|
|
|
'<link href="http://some/external.css" rel="stylesheet">', 'package:some/module/');
|
2015-10-14 12:39:40 -04:00
|
|
|
expect(template.styleUrls).toEqual([]);
|
|
|
|
}));
|
|
|
|
|
2015-09-14 18:59:09 -04:00
|
|
|
it('should extract @import style urls into styleAbsUrl',
|
2016-01-06 17:13:44 -05:00
|
|
|
inject([DirectiveNormalizer], (normalizer: DirectiveNormalizer) => {
|
2016-04-29 00:54:02 -04:00
|
|
|
var template = normalizer.normalizeLoadedTemplate(dirType, new CompileTemplateMetadata({
|
|
|
|
encapsulation: null,
|
|
|
|
styles: ['@import "test.css";'],
|
|
|
|
styleUrls: [],
|
|
|
|
baseUrl: 'package:some/module/a.js'
|
|
|
|
}),
|
|
|
|
'', 'package:some/module/id');
|
2015-09-14 18:59:09 -04:00
|
|
|
expect(template.styles).toEqual(['']);
|
2015-10-01 13:07:49 -04:00
|
|
|
expect(template.styleUrls).toEqual(['package:some/module/test.css']);
|
2015-09-14 18:59:09 -04:00
|
|
|
}));
|
|
|
|
|
2015-10-14 12:39:40 -04:00
|
|
|
it('should not resolve relative urls in inline styles',
|
2016-01-06 17:13:44 -05:00
|
|
|
inject([DirectiveNormalizer], (normalizer: DirectiveNormalizer) => {
|
2015-09-14 18:59:09 -04:00
|
|
|
var template = normalizer.normalizeLoadedTemplate(
|
2015-09-18 13:33:23 -04:00
|
|
|
dirType, new CompileTemplateMetadata({
|
2015-09-14 18:59:09 -04:00
|
|
|
encapsulation: null,
|
|
|
|
styles: ['.foo{background-image: url(\'double.jpg\');'],
|
2016-04-29 00:54:02 -04:00
|
|
|
styleUrls: [],
|
|
|
|
baseUrl: 'package:some/module/a.js'
|
2015-09-14 18:59:09 -04:00
|
|
|
}),
|
2015-10-01 13:07:49 -04:00
|
|
|
'', 'package:some/module/id');
|
2015-10-14 12:39:40 -04:00
|
|
|
expect(template.styles).toEqual(['.foo{background-image: url(\'double.jpg\');']);
|
2015-09-14 18:59:09 -04:00
|
|
|
}));
|
|
|
|
|
|
|
|
it('should resolve relative style urls in styleUrls',
|
2016-01-06 17:13:44 -05:00
|
|
|
inject([DirectiveNormalizer], (normalizer: DirectiveNormalizer) => {
|
2016-04-29 00:54:02 -04:00
|
|
|
var template = normalizer.normalizeLoadedTemplate(dirType, new CompileTemplateMetadata({
|
|
|
|
encapsulation: null,
|
|
|
|
styles: [],
|
|
|
|
styleUrls: ['test.css'],
|
|
|
|
baseUrl: 'package:some/module/a.js'
|
|
|
|
}),
|
|
|
|
'', 'package:some/module/id');
|
2015-09-14 18:59:09 -04:00
|
|
|
expect(template.styles).toEqual([]);
|
2015-10-01 13:07:49 -04:00
|
|
|
expect(template.styleUrls).toEqual(['package:some/module/test.css']);
|
2015-09-14 18:59:09 -04:00
|
|
|
}));
|
|
|
|
|
2015-10-27 17:00:15 -04:00
|
|
|
it('should resolve relative style urls in styleUrls with http directive url',
|
2016-01-06 17:13:44 -05:00
|
|
|
inject([DirectiveNormalizer], (normalizer: DirectiveNormalizer) => {
|
2016-04-29 00:54:02 -04:00
|
|
|
var template = normalizer.normalizeLoadedTemplate(dirType, new CompileTemplateMetadata({
|
|
|
|
encapsulation: null,
|
|
|
|
styles: [],
|
|
|
|
styleUrls: ['test.css'],
|
|
|
|
baseUrl: 'http://some/module/a.js'
|
|
|
|
}),
|
|
|
|
'', 'http://some/module/id');
|
2015-10-27 17:00:15 -04:00
|
|
|
expect(template.styles).toEqual([]);
|
|
|
|
expect(template.styleUrls).toEqual(['http://some/module/test.css']);
|
|
|
|
}));
|
|
|
|
|
2015-12-16 02:47:48 -05:00
|
|
|
it('should normalize ViewEncapsulation.Emulated to ViewEncapsulation.None if there are no styles nor stylesheets',
|
2016-01-06 17:13:44 -05:00
|
|
|
inject([DirectiveNormalizer], (normalizer: DirectiveNormalizer) => {
|
2016-04-29 00:54:02 -04:00
|
|
|
var template =
|
|
|
|
normalizer.normalizeLoadedTemplate(dirType, new CompileTemplateMetadata({
|
|
|
|
encapsulation: ViewEncapsulation.Emulated,
|
|
|
|
styles: [],
|
|
|
|
styleUrls: [],
|
|
|
|
baseUrl: 'package:some/module/a.js'
|
|
|
|
}),
|
|
|
|
'', 'package:some/module/id');
|
2015-09-18 13:33:23 -04:00
|
|
|
expect(template.encapsulation).toEqual(ViewEncapsulation.None);
|
|
|
|
}));
|
2015-09-14 18:59:09 -04:00
|
|
|
|
2015-11-23 19:02:19 -05:00
|
|
|
it('should ignore ng-content in elements with ngNonBindable',
|
2016-01-06 17:13:44 -05:00
|
|
|
inject([DirectiveNormalizer], (normalizer: DirectiveNormalizer) => {
|
2015-09-18 13:33:23 -04:00
|
|
|
var template = normalizer.normalizeLoadedTemplate(
|
2016-04-29 00:54:02 -04:00
|
|
|
dirType, new CompileTemplateMetadata({
|
|
|
|
encapsulation: null,
|
|
|
|
styles: [],
|
|
|
|
styleUrls: [],
|
|
|
|
baseUrl: 'package:some/module/a.js'
|
|
|
|
}),
|
2015-11-23 19:02:19 -05:00
|
|
|
'<div ngNonBindable><ng-content select="a"></ng-content></div>',
|
2015-10-01 13:07:49 -04:00
|
|
|
'package:some/module/');
|
2015-09-18 13:33:23 -04:00
|
|
|
expect(template.ngContentSelectors).toEqual([]);
|
|
|
|
}));
|
2015-09-14 18:59:09 -04:00
|
|
|
|
2015-11-23 19:02:19 -05:00
|
|
|
it('should still collect <style> in elements with ngNonBindable',
|
2016-01-06 17:13:44 -05:00
|
|
|
inject([DirectiveNormalizer], (normalizer: DirectiveNormalizer) => {
|
2015-09-18 13:33:23 -04:00
|
|
|
var template = normalizer.normalizeLoadedTemplate(
|
2016-04-29 00:54:02 -04:00
|
|
|
dirType, new CompileTemplateMetadata({
|
|
|
|
encapsulation: null,
|
|
|
|
styles: [],
|
|
|
|
styleUrls: [],
|
|
|
|
baseUrl: 'package:some/module/a.js'
|
|
|
|
}),
|
2015-11-23 19:02:19 -05:00
|
|
|
'<div ngNonBindable><style>div {color:red}</style></div>', 'package:some/module/');
|
2015-09-18 13:33:23 -04:00
|
|
|
expect(template.styles).toEqual(['div {color:red}']);
|
|
|
|
}));
|
2015-09-18 13:33:23 -04:00
|
|
|
});
|
2015-09-14 18:59:09 -04:00
|
|
|
});
|
|
|
|
}
|