refactor(compiler): remove unused code
BREAKING CHANGE: - Removes `ChangeDetection`, use a binding for `ChangeDetectorGenConfig` instead to configure change detection. - `RenderElementRef.renderBoundElementIndex` was renamed to `RenderElementRef.boundElementIndex`. - Removes `ViewLoader`, use `XHRImpl` instead.
This commit is contained in:
@ -1,17 +0,0 @@
|
||||
library angular2.test.core.compiler.component_url_mapper_spec;
|
||||
|
||||
import 'package:angular2/test_lib.dart';
|
||||
import 'package:angular2/src/core/compiler/component_url_mapper.dart';
|
||||
|
||||
main() {
|
||||
describe("ComponentUrlMapper", () {
|
||||
it("should return the URL of the component's library", () {
|
||||
var mapper = new ComponentUrlMapper();
|
||||
expect(mapper
|
||||
.getUrl(SomeComponent)
|
||||
.endsWith("core/compiler/component_url_mapper_spec.dart")).toBeTrue();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
class SomeComponent {}
|
@ -1,25 +0,0 @@
|
||||
import {describe, it, expect, beforeEach, ddescribe, iit, xit, el} from 'angular2/test_lib';
|
||||
|
||||
import {
|
||||
ComponentUrlMapper,
|
||||
RuntimeComponentUrlMapper
|
||||
} from 'angular2/src/core/compiler/component_url_mapper';
|
||||
|
||||
export function main() {
|
||||
describe('RuntimeComponentUrlMapper', () => {
|
||||
it('should return the registered URL', () => {
|
||||
var url = 'http://path/to/component';
|
||||
var mapper = new RuntimeComponentUrlMapper();
|
||||
mapper.setComponentUrl(SomeComponent, url);
|
||||
expect(mapper.getUrl(SomeComponent)).toEqual(url);
|
||||
});
|
||||
|
||||
it('should fallback to ComponentUrlMapper', () => {
|
||||
var mapper = new ComponentUrlMapper();
|
||||
var runtimeMapper = new RuntimeComponentUrlMapper();
|
||||
expect(runtimeMapper.getUrl(SomeComponent)).toEqual(mapper.getUrl(SomeComponent));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
class SomeComponent {}
|
@ -1,112 +1,102 @@
|
||||
library angular2.test.core.compiler.directive_lifecycle_spec;
|
||||
|
||||
import 'package:angular2/test_lib.dart';
|
||||
import 'package:angular2/angular2.dart';
|
||||
import 'package:angular2/src/core/compiler/element_injector.dart';
|
||||
import 'package:angular2/src/core/compiler/directive_lifecycle_reflector.dart';
|
||||
import 'package:angular2/src/core/compiler/interfaces.dart';
|
||||
|
||||
main() {
|
||||
describe('Create DirectiveMetadata', () {
|
||||
describe('lifecycle', () {
|
||||
metadata(type, annotation) =>
|
||||
DirectiveBinding.createFromType(type, annotation).metadata;
|
||||
|
||||
describe("onChanges", () {
|
||||
it("should be true when the directive implements OnChanges", () {
|
||||
expect(metadata(DirectiveImplementingOnChanges, new Directive())
|
||||
.callOnChanges).toBe(true);
|
||||
it("should be true when the directive has the onChanges method", () {
|
||||
expect(hasLifecycleHook(LifecycleHooks.OnChanges, DirectiveImplementingOnChanges))
|
||||
.toBe(true);
|
||||
});
|
||||
|
||||
it("should be false otherwise", () {
|
||||
expect(metadata(DirectiveNoHooks, new Directive()).callOnChanges)
|
||||
.toBe(false);
|
||||
expect(hasLifecycleHook(LifecycleHooks.OnChanges, DirectiveNoHooks)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("onDestroy", () {
|
||||
it("should be true when the directive implements OnDestroy", () {
|
||||
expect(metadata(DirectiveImplementingOnDestroy, new Directive())
|
||||
.callOnDestroy).toBe(true);
|
||||
it("should be true when the directive has the onDestroy method", () {
|
||||
expect(hasLifecycleHook(LifecycleHooks.OnDestroy, DirectiveImplementingOnDestroy))
|
||||
.toBe(true);
|
||||
});
|
||||
|
||||
it("should be false otherwise", () {
|
||||
expect(metadata(DirectiveNoHooks, new Directive()).callOnDestroy)
|
||||
.toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("doCheck", () {
|
||||
it("should be true when the directive implements DoCheck", () {
|
||||
expect(metadata(DirectiveImplementingOnCheck, new Directive())
|
||||
.callDoCheck).toBe(true);
|
||||
});
|
||||
|
||||
it("should be false otherwise", () {
|
||||
expect(metadata(DirectiveNoHooks, new Directive()).callDoCheck)
|
||||
.toBe(false);
|
||||
expect(hasLifecycleHook(LifecycleHooks.OnDestroy, DirectiveNoHooks)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("onInit", () {
|
||||
it("should be true when the directive implements OnInit", () {
|
||||
expect(metadata(DirectiveImplementingOnInit, new Directive())
|
||||
.callOnInit).toBe(true);
|
||||
it("should be true when the directive has the onInit method", () {
|
||||
expect(hasLifecycleHook(LifecycleHooks.OnInit, DirectiveImplementingOnInit))
|
||||
.toBe(true);
|
||||
});
|
||||
|
||||
it("should be false otherwise", () {
|
||||
expect(metadata(DirectiveNoHooks, new Directive()).callOnInit)
|
||||
.toBe(false);
|
||||
expect(hasLifecycleHook(LifecycleHooks.OnInit, DirectiveNoHooks)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("doCheck", () {
|
||||
it("should be true when the directive has the doCheck method", () {
|
||||
expect(hasLifecycleHook(LifecycleHooks.DoCheck, DirectiveImplementingOnCheck))
|
||||
.toBe(true);
|
||||
});
|
||||
|
||||
it("should be false otherwise", () {
|
||||
expect(hasLifecycleHook(LifecycleHooks.DoCheck, DirectiveNoHooks)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("afterContentInit", () {
|
||||
it("should be true when the directive implements AfterContentInit", () {
|
||||
expect(
|
||||
metadata(DirectiveImplementingAfterContentInit, new Directive())
|
||||
.callAfterContentInit).toBe(true);
|
||||
it("should be true when the directive has the afterContentInit method", () {
|
||||
expect(hasLifecycleHook(LifecycleHooks.AfterContentInit, DirectiveImplementingAfterContentInit))
|
||||
.toBe(true);
|
||||
});
|
||||
|
||||
it("should be false otherwise", () {
|
||||
expect(metadata(DirectiveNoHooks, new Directive())
|
||||
.callAfterContentInit).toBe(false);
|
||||
expect(hasLifecycleHook(LifecycleHooks.AfterContentInit, DirectiveNoHooks))
|
||||
.toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("afterContentChecked", () {
|
||||
it("should be true when the directive implements AfterContentChecked", () {
|
||||
expect(
|
||||
metadata(DirectiveImplementingAfterContentChecked, new Directive())
|
||||
.callAfterContentChecked).toBe(true);
|
||||
it("should be true when the directive has the afterContentChecked method", () {
|
||||
expect(hasLifecycleHook(LifecycleHooks.AfterContentChecked, DirectiveImplementingAfterContentChecked))
|
||||
.toBe(true);
|
||||
});
|
||||
|
||||
it("should be false otherwise", () {
|
||||
expect(metadata(DirectiveNoHooks, new Directive())
|
||||
.callAfterContentChecked).toBe(false);
|
||||
expect(hasLifecycleHook(LifecycleHooks.AfterContentChecked, DirectiveNoHooks))
|
||||
.toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe("afterViewInit", () {
|
||||
it("should be true when the directive implements AfterViewInit", () {
|
||||
expect(
|
||||
metadata(DirectiveImplementingAfterViewInit, new Directive())
|
||||
.callAfterViewInit).toBe(true);
|
||||
it("should be true when the directive has the afterViewInit method", () {
|
||||
expect(hasLifecycleHook(LifecycleHooks.AfterViewInit, DirectiveImplementingAfterViewInit))
|
||||
.toBe(true);
|
||||
});
|
||||
|
||||
it("should be false otherwise", () {
|
||||
expect(metadata(DirectiveNoHooks, new Directive())
|
||||
.callAfterViewInit).toBe(false);
|
||||
expect(hasLifecycleHook(LifecycleHooks.AfterViewInit, DirectiveNoHooks)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("afterViewChecked", () {
|
||||
it("should be true when the directive implements AfterViewChecked", () {
|
||||
expect(
|
||||
metadata(DirectiveImplementingAfterViewChecked, new Directive())
|
||||
.callAfterViewChecked).toBe(true);
|
||||
it("should be true when the directive has the afterViewChecked method", () {
|
||||
expect(hasLifecycleHook(LifecycleHooks.AfterViewChecked, DirectiveImplementingAfterViewChecked))
|
||||
.toBe(true);
|
||||
});
|
||||
|
||||
it("should be false otherwise", () {
|
||||
expect(metadata(DirectiveNoHooks, new Directive())
|
||||
.callAfterViewChecked).toBe(false);
|
||||
expect(hasLifecycleHook(LifecycleHooks.AfterViewChecked, DirectiveNoHooks))
|
||||
.toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -13,83 +13,76 @@ import {
|
||||
proxy
|
||||
} from 'angular2/test_lib';
|
||||
|
||||
import {DirectiveMetadata} from 'angular2/src/core/metadata';
|
||||
import {DirectiveBinding} from 'angular2/src/core/compiler/element_injector';
|
||||
import {RenderDirectiveMetadata} from 'angular2/src/core/render/api';
|
||||
import {hasLifecycleHook} from 'angular2/src/core/compiler/directive_lifecycle_reflector';
|
||||
import {LifecycleHooks} from 'angular2/src/core/compiler/interfaces';
|
||||
|
||||
export function main() {
|
||||
describe('Create DirectiveMetadata', () => {
|
||||
describe('lifecycle', () => {
|
||||
function metadata(type, annotation): RenderDirectiveMetadata {
|
||||
return DirectiveBinding.createFromType(type, annotation).metadata;
|
||||
}
|
||||
|
||||
describe("onChanges", () => {
|
||||
it("should be true when the directive has the onChanges method", () => {
|
||||
expect(metadata(DirectiveWithOnChangesMethod, new DirectiveMetadata({})).callOnChanges)
|
||||
expect(hasLifecycleHook(LifecycleHooks.OnChanges, DirectiveWithOnChangesMethod))
|
||||
.toBe(true);
|
||||
});
|
||||
|
||||
it("should be false otherwise", () => {
|
||||
expect(metadata(DirectiveNoHooks, new DirectiveMetadata()).callOnChanges).toBe(false);
|
||||
expect(hasLifecycleHook(LifecycleHooks.OnChanges, DirectiveNoHooks)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("onDestroy", () => {
|
||||
it("should be true when the directive has the onDestroy method", () => {
|
||||
expect(metadata(DirectiveWithOnDestroyMethod, new DirectiveMetadata({})).callOnDestroy)
|
||||
expect(hasLifecycleHook(LifecycleHooks.OnDestroy, DirectiveWithOnDestroyMethod))
|
||||
.toBe(true);
|
||||
});
|
||||
|
||||
it("should be false otherwise", () => {
|
||||
expect(metadata(DirectiveNoHooks, new DirectiveMetadata()).callOnDestroy).toBe(false);
|
||||
expect(hasLifecycleHook(LifecycleHooks.OnDestroy, DirectiveNoHooks)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("onInit", () => {
|
||||
it("should be true when the directive has the onInit method", () => {
|
||||
expect(metadata(DirectiveWithOnInitMethod, new DirectiveMetadata({})).callOnInit)
|
||||
.toBe(true);
|
||||
expect(hasLifecycleHook(LifecycleHooks.OnInit, DirectiveWithOnInitMethod)).toBe(true);
|
||||
});
|
||||
|
||||
it("should be false otherwise", () => {
|
||||
expect(metadata(DirectiveNoHooks, new DirectiveMetadata()).callOnInit).toBe(false);
|
||||
expect(hasLifecycleHook(LifecycleHooks.OnInit, DirectiveNoHooks)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("doCheck", () => {
|
||||
it("should be true when the directive has the doCheck method", () => {
|
||||
expect(metadata(DirectiveWithOnCheckMethod, new DirectiveMetadata({})).callDoCheck)
|
||||
.toBe(true);
|
||||
expect(hasLifecycleHook(LifecycleHooks.DoCheck, DirectiveWithOnCheckMethod)).toBe(true);
|
||||
});
|
||||
|
||||
it("should be false otherwise", () => {
|
||||
expect(metadata(DirectiveNoHooks, new DirectiveMetadata()).callDoCheck).toBe(false);
|
||||
expect(hasLifecycleHook(LifecycleHooks.DoCheck, DirectiveNoHooks)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("afterContentInit", () => {
|
||||
it("should be true when the directive has the afterContentInit method", () => {
|
||||
expect(metadata(DirectiveWithAfterContentInitMethod, new DirectiveMetadata({}))
|
||||
.callAfterContentInit)
|
||||
expect(hasLifecycleHook(LifecycleHooks.AfterContentInit,
|
||||
DirectiveWithAfterContentInitMethod))
|
||||
.toBe(true);
|
||||
});
|
||||
|
||||
it("should be false otherwise", () => {
|
||||
expect(metadata(DirectiveNoHooks, new DirectiveMetadata()).callAfterContentInit)
|
||||
.toBe(false);
|
||||
expect(hasLifecycleHook(LifecycleHooks.AfterContentInit, DirectiveNoHooks)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("afterContentChecked", () => {
|
||||
it("should be true when the directive has the afterContentChecked method", () => {
|
||||
expect(metadata(DirectiveWithAfterContentCheckedMethod, new DirectiveMetadata({}))
|
||||
.callAfterContentChecked)
|
||||
expect(hasLifecycleHook(LifecycleHooks.AfterContentChecked,
|
||||
DirectiveWithAfterContentCheckedMethod))
|
||||
.toBe(true);
|
||||
});
|
||||
|
||||
it("should be false otherwise", () => {
|
||||
expect(metadata(DirectiveNoHooks, new DirectiveMetadata()).callAfterContentChecked)
|
||||
expect(hasLifecycleHook(LifecycleHooks.AfterContentChecked, DirectiveNoHooks))
|
||||
.toBe(false);
|
||||
});
|
||||
});
|
||||
@ -97,26 +90,24 @@ export function main() {
|
||||
|
||||
describe("afterViewInit", () => {
|
||||
it("should be true when the directive has the afterViewInit method", () => {
|
||||
expect(metadata(DirectiveWithAfterViewInitMethod, new DirectiveMetadata({}))
|
||||
.callAfterViewInit)
|
||||
expect(hasLifecycleHook(LifecycleHooks.AfterViewInit, DirectiveWithAfterViewInitMethod))
|
||||
.toBe(true);
|
||||
});
|
||||
|
||||
it("should be false otherwise", () => {
|
||||
expect(metadata(DirectiveNoHooks, new DirectiveMetadata()).callAfterViewInit).toBe(false);
|
||||
expect(hasLifecycleHook(LifecycleHooks.AfterViewInit, DirectiveNoHooks)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("afterViewChecked", () => {
|
||||
it("should be true when the directive has the afterViewChecked method", () => {
|
||||
expect(metadata(DirectiveWithAfterViewCheckedMethod, new DirectiveMetadata({}))
|
||||
.callAfterViewChecked)
|
||||
expect(hasLifecycleHook(LifecycleHooks.AfterViewChecked,
|
||||
DirectiveWithAfterViewCheckedMethod))
|
||||
.toBe(true);
|
||||
});
|
||||
|
||||
it("should be false otherwise", () => {
|
||||
expect(metadata(DirectiveNoHooks, new DirectiveMetadata()).callAfterViewChecked)
|
||||
.toBe(false);
|
||||
expect(hasLifecycleHook(LifecycleHooks.AfterViewChecked, DirectiveNoHooks)).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -62,8 +62,6 @@ import {
|
||||
PipeTransform,
|
||||
ChangeDetectorRef,
|
||||
ChangeDetectionStrategy,
|
||||
ChangeDetection,
|
||||
DynamicChangeDetection,
|
||||
ChangeDetectorGenConfig
|
||||
} from 'angular2/src/core/change_detection/change_detection';
|
||||
|
||||
|
@ -35,7 +35,6 @@ import {
|
||||
ViewMetadata
|
||||
} from 'angular2/core';
|
||||
import {By} from 'angular2/src/core/debug';
|
||||
import {MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE} from 'angular2/src/core/render';
|
||||
|
||||
export function main() {
|
||||
describe('projection', () => {
|
||||
@ -421,45 +420,29 @@ export function main() {
|
||||
}));
|
||||
}
|
||||
|
||||
describe('different proto view storages', () => {
|
||||
function runTests() {
|
||||
it('should support nested conditionals that contain ng-contents',
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||
tcb.overrideView(MainComp, new ViewMetadata({
|
||||
template: `<conditional-text>a</conditional-text>`,
|
||||
directives: [ConditionalTextComponent]
|
||||
}))
|
||||
.createAsync(MainComp)
|
||||
.then((main) => {
|
||||
expect(main.debugElement.nativeElement).toHaveText('MAIN()');
|
||||
it('should support nested conditionals that contain ng-contents',
|
||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||
tcb.overrideView(MainComp, new ViewMetadata({
|
||||
template: `<conditional-text>a</conditional-text>`,
|
||||
directives: [ConditionalTextComponent]
|
||||
}))
|
||||
.createAsync(MainComp)
|
||||
.then((main) => {
|
||||
expect(main.debugElement.nativeElement).toHaveText('MAIN()');
|
||||
|
||||
var viewportElement =
|
||||
main.debugElement.componentViewChildren[0].componentViewChildren[0];
|
||||
viewportElement.inject(ManualViewportDirective).show();
|
||||
expect(main.debugElement.nativeElement).toHaveText('MAIN(FIRST())');
|
||||
var viewportElement =
|
||||
main.debugElement.componentViewChildren[0].componentViewChildren[0];
|
||||
viewportElement.inject(ManualViewportDirective).show();
|
||||
expect(main.debugElement.nativeElement).toHaveText('MAIN(FIRST())');
|
||||
|
||||
viewportElement =
|
||||
main.debugElement.componentViewChildren[0].componentViewChildren[1];
|
||||
viewportElement.inject(ManualViewportDirective).show();
|
||||
expect(main.debugElement.nativeElement).toHaveText('MAIN(FIRST(SECOND(a)))');
|
||||
viewportElement =
|
||||
main.debugElement.componentViewChildren[0].componentViewChildren[1];
|
||||
viewportElement.inject(ManualViewportDirective).show();
|
||||
expect(main.debugElement.nativeElement).toHaveText('MAIN(FIRST(SECOND(a)))');
|
||||
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
describe('serialize templates', () => {
|
||||
beforeEachBindings(() => [bind(MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE).toValue(0)]);
|
||||
runTests();
|
||||
});
|
||||
|
||||
describe("don't serialize templates", () => {
|
||||
beforeEachBindings(() => [bind(MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE).toValue(-1)]);
|
||||
runTests();
|
||||
});
|
||||
|
||||
});
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
});
|
||||
}
|
||||
|
@ -11,133 +11,9 @@ import {
|
||||
it
|
||||
} from 'angular2/test_lib';
|
||||
|
||||
import {SpyChangeDetection} from '../spies';
|
||||
import {isBlank, stringify} from 'angular2/src/core/facade/lang';
|
||||
|
||||
import {
|
||||
ChangeDetection,
|
||||
ChangeDetectorDefinition,
|
||||
BindingRecord,
|
||||
DirectiveIndex,
|
||||
Parser
|
||||
} from 'angular2/src/core/change_detection/change_detection';
|
||||
import {
|
||||
BindingRecordsCreator,
|
||||
getChangeDetectorDefinitions
|
||||
} from 'angular2/src/core/compiler/proto_view_factory';
|
||||
import {Component, Directive} from 'angular2/src/core/metadata';
|
||||
import {Key, Binding} from 'angular2/core';
|
||||
import {DirectiveResolver} from 'angular2/src/core/compiler/directive_resolver';
|
||||
import {DirectiveBinding} from 'angular2/src/core/compiler/element_injector';
|
||||
import {
|
||||
RenderElementBinder,
|
||||
EventBinding,
|
||||
RenderDirectiveMetadata,
|
||||
ViewType,
|
||||
ProtoViewDto,
|
||||
DirectiveBinder
|
||||
} from 'angular2/src/core/render/api';
|
||||
|
||||
export function main() {
|
||||
describe('ProtoViewFactory', () => {
|
||||
var changeDetection;
|
||||
var directiveResolver;
|
||||
// TODO
|
||||
|
||||
beforeEach(() => {
|
||||
directiveResolver = new DirectiveResolver();
|
||||
changeDetection = new SpyChangeDetection();
|
||||
changeDetection.prop("generateDetectors", true);
|
||||
});
|
||||
|
||||
function bindDirective(type) {
|
||||
return DirectiveBinding.createFromType(type, directiveResolver.resolve(type));
|
||||
}
|
||||
|
||||
describe('getChangeDetectorDefinitions', () => {
|
||||
|
||||
it('should create a ChangeDetectorDefinition for the root render proto view', () => {
|
||||
var renderPv = createRenderProtoView();
|
||||
var defs =
|
||||
getChangeDetectorDefinitions(bindDirective(MainComponent).metadata, renderPv, [], null);
|
||||
expect(defs.length).toBe(1);
|
||||
expect(defs[0].id).toEqual(`${stringify(MainComponent)}_comp_0`);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('BindingRecordsCreator', () => {
|
||||
var creator: BindingRecordsCreator;
|
||||
|
||||
beforeEach(() => { creator = new BindingRecordsCreator(); });
|
||||
|
||||
describe('getEventBindingRecords', () => {
|
||||
it("should return template event records", inject([Parser], (p: Parser) => {
|
||||
var ast1 = p.parseAction("1", null);
|
||||
var ast2 = p.parseAction("2", null);
|
||||
|
||||
var rec = creator.getEventBindingRecords(
|
||||
[
|
||||
new RenderElementBinder(
|
||||
{eventBindings: [new EventBinding("a", ast1)], directives: []}),
|
||||
new RenderElementBinder(
|
||||
{eventBindings: [new EventBinding("b", ast2)], directives: []})
|
||||
],
|
||||
[]);
|
||||
|
||||
expect(rec).toEqual([
|
||||
BindingRecord.createForEvent(ast1, "a", 0),
|
||||
BindingRecord.createForEvent(ast2, "b", 1)
|
||||
]);
|
||||
}));
|
||||
|
||||
it('should return host event records', inject([Parser], (p: Parser) => {
|
||||
var ast1 = p.parseAction("1", null);
|
||||
|
||||
var rec = creator.getEventBindingRecords(
|
||||
[
|
||||
new RenderElementBinder({
|
||||
eventBindings: [],
|
||||
directives: [
|
||||
new DirectiveBinder(
|
||||
{directiveIndex: 0, eventBindings: [new EventBinding("a", ast1)]})
|
||||
]
|
||||
})
|
||||
],
|
||||
[RenderDirectiveMetadata.create({id: 'some-id'})]);
|
||||
|
||||
expect(rec.length).toEqual(1);
|
||||
expect(rec[0].target.name).toEqual("a");
|
||||
expect(rec[0].implicitReceiver).toBeAnInstanceOf(DirectiveIndex);
|
||||
}));
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function directiveBinding({metadata}: {metadata?: any} = {}) {
|
||||
return new DirectiveBinding(Key.get("dummy"), null, null, metadata, [], []);
|
||||
}
|
||||
|
||||
function createRenderProtoView(elementBinders = null, type: ViewType = null,
|
||||
variableBindings = null) {
|
||||
if (isBlank(type)) {
|
||||
type = ViewType.COMPONENT;
|
||||
}
|
||||
if (isBlank(elementBinders)) {
|
||||
elementBinders = [];
|
||||
}
|
||||
if (isBlank(variableBindings)) {
|
||||
variableBindings = new Map();
|
||||
}
|
||||
return new ProtoViewDto({
|
||||
elementBinders: elementBinders,
|
||||
type: type,
|
||||
variableBindings: variableBindings,
|
||||
textBindings: [],
|
||||
transitiveNgContentCount: 0
|
||||
});
|
||||
}
|
||||
|
||||
@Component({selector: 'main-comp'})
|
||||
class MainComponent {
|
||||
});
|
||||
}
|
||||
|
@ -26,7 +26,6 @@ import {
|
||||
RenderProtoViewRef,
|
||||
RenderFragmentRef,
|
||||
ViewType,
|
||||
RenderProtoViewMergeMapping,
|
||||
RenderViewWithFragments
|
||||
} from 'angular2/src/core/render/api';
|
||||
import {AppViewManager} from 'angular2/src/core/compiler/view_manager';
|
||||
|
@ -37,11 +37,7 @@ import {
|
||||
import {DirectiveResolver} from 'angular2/src/core/compiler/directive_resolver';
|
||||
import {Component} from 'angular2/src/core/metadata';
|
||||
import {AppViewManagerUtils} from 'angular2/src/core/compiler/view_manager_utils';
|
||||
import {
|
||||
RenderProtoViewMergeMapping,
|
||||
ViewType,
|
||||
RenderViewWithFragments
|
||||
} from 'angular2/src/core/render/render';
|
||||
import {ViewType, RenderViewWithFragments} from 'angular2/src/core/render/render';
|
||||
|
||||
export function main() {
|
||||
// TODO(tbosch): add more tests here!
|
||||
|
Reference in New Issue
Block a user