2015-09-11 16:35:46 -04:00
|
|
|
import {
|
|
|
|
AsyncTestCompleter,
|
|
|
|
beforeEach,
|
|
|
|
ddescribe,
|
|
|
|
describe,
|
|
|
|
el,
|
|
|
|
expect,
|
|
|
|
iit,
|
|
|
|
inject,
|
|
|
|
it,
|
|
|
|
xit,
|
|
|
|
TestComponentBuilder
|
|
|
|
} from 'angular2/test_lib';
|
|
|
|
|
|
|
|
import {
|
2015-09-14 18:59:09 -04:00
|
|
|
NormalizedDirectiveMetadata,
|
2015-09-11 16:35:46 -04:00
|
|
|
TypeMetadata,
|
2015-09-14 18:59:09 -04:00
|
|
|
NormalizedTemplateMetadata,
|
2015-09-11 16:35:46 -04:00
|
|
|
ChangeDetectionMetadata
|
2015-09-14 18:59:09 -04:00
|
|
|
} from 'angular2/src/compiler/directive_metadata';
|
2015-09-11 16:35:46 -04:00
|
|
|
import {ViewEncapsulation} from 'angular2/src/core/render/api';
|
|
|
|
import {ChangeDetectionStrategy} from 'angular2/src/core/change_detection';
|
|
|
|
|
|
|
|
export function main() {
|
2015-09-14 18:59:09 -04:00
|
|
|
describe('DirectiveMetadata', () => {
|
2015-09-11 16:35:46 -04:00
|
|
|
var fullTypeMeta: TypeMetadata;
|
2015-09-14 18:59:09 -04:00
|
|
|
var fullTemplateMeta: NormalizedTemplateMetadata;
|
2015-09-11 16:35:46 -04:00
|
|
|
var fullChangeDetectionMeta: ChangeDetectionMetadata;
|
2015-09-14 18:59:09 -04:00
|
|
|
var fullDirectiveMeta: NormalizedDirectiveMetadata;
|
2015-09-11 16:35:46 -04:00
|
|
|
|
|
|
|
beforeEach(() => {
|
2015-09-14 18:59:09 -04:00
|
|
|
fullTypeMeta = new TypeMetadata({id: 23, name: 'SomeType', moduleId: 'someUrl'});
|
|
|
|
fullTemplateMeta = new NormalizedTemplateMetadata({
|
2015-09-11 16:35:46 -04:00
|
|
|
encapsulation: ViewEncapsulation.Emulated,
|
|
|
|
template: '<a></a>',
|
|
|
|
styles: ['someStyle'],
|
|
|
|
styleAbsUrls: ['someStyleUrl'],
|
2015-09-14 18:59:09 -04:00
|
|
|
hostAttributes: {'attr1': 'attrValue2'},
|
2015-09-11 16:35:46 -04:00
|
|
|
ngContentSelectors: ['*']
|
|
|
|
});
|
|
|
|
fullChangeDetectionMeta = new ChangeDetectionMetadata({
|
|
|
|
changeDetection: ChangeDetectionStrategy.Default,
|
|
|
|
properties: ['someProp'],
|
|
|
|
events: ['someEvent'],
|
|
|
|
hostListeners: {'event1': 'handler1'},
|
|
|
|
hostProperties: {'prop1': 'expr1'},
|
|
|
|
callAfterContentInit: true,
|
|
|
|
callAfterContentChecked: true,
|
|
|
|
callAfterViewInit: true,
|
|
|
|
callAfterViewChecked: true,
|
|
|
|
callOnChanges: true,
|
|
|
|
callDoCheck: true,
|
|
|
|
callOnInit: true
|
|
|
|
});
|
2015-09-14 18:59:09 -04:00
|
|
|
fullDirectiveMeta = new NormalizedDirectiveMetadata({
|
2015-09-11 16:35:46 -04:00
|
|
|
selector: 'someSelector',
|
|
|
|
isComponent: true,
|
2015-09-14 18:59:09 -04:00
|
|
|
dynamicLoadable: true,
|
2015-09-11 16:35:46 -04:00
|
|
|
type: fullTypeMeta, template: fullTemplateMeta,
|
|
|
|
changeDetection: fullChangeDetectionMeta,
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('DirectiveMetadata', () => {
|
|
|
|
it('should serialize with full data', () => {
|
2015-09-14 18:59:09 -04:00
|
|
|
expect(NormalizedDirectiveMetadata.fromJson(fullDirectiveMeta.toJson()))
|
|
|
|
.toEqual(fullDirectiveMeta);
|
2015-09-11 16:35:46 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should serialize with no data', () => {
|
2015-09-14 18:59:09 -04:00
|
|
|
var empty = new NormalizedDirectiveMetadata();
|
|
|
|
expect(NormalizedDirectiveMetadata.fromJson(empty.toJson())).toEqual(empty);
|
2015-09-11 16:35:46 -04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('TypeMetadata', () => {
|
|
|
|
it('should serialize with full data',
|
|
|
|
() => { expect(TypeMetadata.fromJson(fullTypeMeta.toJson())).toEqual(fullTypeMeta); });
|
|
|
|
|
|
|
|
it('should serialize with no data', () => {
|
|
|
|
var empty = new TypeMetadata();
|
|
|
|
expect(TypeMetadata.fromJson(empty.toJson())).toEqual(empty);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('TemplateMetadata', () => {
|
|
|
|
it('should serialize with full data', () => {
|
2015-09-14 18:59:09 -04:00
|
|
|
expect(NormalizedTemplateMetadata.fromJson(fullTemplateMeta.toJson()))
|
|
|
|
.toEqual(fullTemplateMeta);
|
2015-09-11 16:35:46 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should serialize with no data', () => {
|
2015-09-14 18:59:09 -04:00
|
|
|
var empty = new NormalizedTemplateMetadata();
|
|
|
|
expect(NormalizedTemplateMetadata.fromJson(empty.toJson())).toEqual(empty);
|
2015-09-11 16:35:46 -04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('ChangeDetectionMetadata', () => {
|
|
|
|
it('should serialize with full data', () => {
|
|
|
|
expect(ChangeDetectionMetadata.fromJson(fullChangeDetectionMeta.toJson()))
|
|
|
|
.toEqual(fullChangeDetectionMeta);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should serialize with no data', () => {
|
|
|
|
var empty = new ChangeDetectionMetadata();
|
|
|
|
expect(ChangeDetectionMetadata.fromJson(empty.toJson())).toEqual(empty);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|