fix: add types for ts2dart's façade handling.
... in many, many places.
This commit is contained in:
parent
c4ecbf0a7f
commit
f3d741854a
|
@ -1,5 +1,6 @@
|
|||
import {isPresent, isBlank, BaseException, FunctionWrapper} from 'angular2/src/facade/lang';
|
||||
import {List, ListWrapper, MapWrapper, StringMapWrapper} from 'angular2/src/facade/collection';
|
||||
import {Locals} from 'angular2/src/change_detection/parser/locals';
|
||||
|
||||
import {AbstractChangeDetector} from './abstract_change_detector';
|
||||
import {BindingRecord} from './binding_record';
|
||||
|
@ -12,7 +13,7 @@ import {ProtoRecord, RecordType} from './proto_record';
|
|||
import {ExpressionChangedAfterItHasBeenChecked, ChangeDetectionError} from './exceptions';
|
||||
|
||||
export class DynamicChangeDetector extends AbstractChangeDetector {
|
||||
locals: any = null;
|
||||
locals: Locals = null;
|
||||
values: List<any>;
|
||||
changes: List<any>;
|
||||
pipes: List<any>;
|
||||
|
@ -36,7 +37,7 @@ export class DynamicChangeDetector extends AbstractChangeDetector {
|
|||
ListWrapper.fill(this.changes, false);
|
||||
}
|
||||
|
||||
hydrate(context: any, locals: any, directives: any) {
|
||||
hydrate(context: any, locals: Locals, directives: any) {
|
||||
this.mode = ChangeDetectionUtil.changeDetectionMode(this.changeControlStrategy);
|
||||
this.values[0] = context;
|
||||
this.locals = locals;
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
import {isBlank, isPresent, FunctionWrapper, BaseException} from "angular2/src/facade/lang";
|
||||
import {List, Map, ListWrapper, StringMapWrapper} from "angular2/src/facade/collection";
|
||||
import {Locals} from "./locals";
|
||||
|
||||
export class AST {
|
||||
eval(context, locals) { throw new BaseException("Not supported"); }
|
||||
eval(context, locals: Locals) { throw new BaseException("Not supported"); }
|
||||
|
||||
get isAssignable(): boolean { return false; }
|
||||
|
||||
assign(context, locals, value) { throw new BaseException("Not supported"); }
|
||||
assign(context, locals: Locals, value) { throw new BaseException("Not supported"); }
|
||||
|
||||
visit(visitor: AstVisitor): any { return null; }
|
||||
|
||||
|
@ -14,7 +15,7 @@ export class AST {
|
|||
}
|
||||
|
||||
export class EmptyExpr extends AST {
|
||||
eval(context, locals) { return null; }
|
||||
eval(context, locals: Locals) { return null; }
|
||||
|
||||
visit(visitor: AstVisitor) {
|
||||
// do nothing
|
||||
|
@ -22,7 +23,7 @@ export class EmptyExpr extends AST {
|
|||
}
|
||||
|
||||
export class ImplicitReceiver extends AST {
|
||||
eval(context, locals) { return context; }
|
||||
eval(context, locals: Locals) { return context; }
|
||||
|
||||
visit(visitor: AstVisitor) { return visitor.visitImplicitReceiver(this); }
|
||||
}
|
||||
|
@ -33,7 +34,7 @@ export class ImplicitReceiver extends AST {
|
|||
export class Chain extends AST {
|
||||
constructor(public expressions: List<any>) { super(); }
|
||||
|
||||
eval(context, locals) {
|
||||
eval(context, locals: Locals) {
|
||||
var result;
|
||||
for (var i = 0; i < this.expressions.length; i++) {
|
||||
var last = this.expressions[i].eval(context, locals);
|
||||
|
@ -48,7 +49,7 @@ export class Chain extends AST {
|
|||
export class Conditional extends AST {
|
||||
constructor(public condition: AST, public trueExp: AST, public falseExp: AST) { super(); }
|
||||
|
||||
eval(context, locals) {
|
||||
eval(context, locals: Locals) {
|
||||
if (this.condition.eval(context, locals)) {
|
||||
return this.trueExp.eval(context, locals);
|
||||
} else {
|
||||
|
@ -65,7 +66,7 @@ export class AccessMember extends AST {
|
|||
super();
|
||||
}
|
||||
|
||||
eval(context, locals) {
|
||||
eval(context, locals: Locals) {
|
||||
if (this.receiver instanceof ImplicitReceiver && isPresent(locals) &&
|
||||
locals.contains(this.name)) {
|
||||
return locals.get(this.name);
|
||||
|
@ -77,7 +78,7 @@ export class AccessMember extends AST {
|
|||
|
||||
get isAssignable(): boolean { return true; }
|
||||
|
||||
assign(context, locals, value) {
|
||||
assign(context, locals: Locals, value) {
|
||||
var evaluatedContext = this.receiver.eval(context, locals);
|
||||
|
||||
if (this.receiver instanceof ImplicitReceiver && isPresent(locals) &&
|
||||
|
@ -97,7 +98,7 @@ export class SafeAccessMember extends AST {
|
|||
super();
|
||||
}
|
||||
|
||||
eval(context, locals) {
|
||||
eval(context, locals: Locals) {
|
||||
var evaluatedReceiver = this.receiver.eval(context, locals);
|
||||
return isBlank(evaluatedReceiver) ? null : this.getter(evaluatedReceiver);
|
||||
}
|
||||
|
@ -108,7 +109,7 @@ export class SafeAccessMember extends AST {
|
|||
export class KeyedAccess extends AST {
|
||||
constructor(public obj: AST, public key: AST) { super(); }
|
||||
|
||||
eval(context, locals) {
|
||||
eval(context, locals: Locals) {
|
||||
var obj: any = this.obj.eval(context, locals);
|
||||
var key: any = this.key.eval(context, locals);
|
||||
return obj[key];
|
||||
|
@ -116,7 +117,7 @@ export class KeyedAccess extends AST {
|
|||
|
||||
get isAssignable(): boolean { return true; }
|
||||
|
||||
assign(context, locals, value) {
|
||||
assign(context, locals: Locals, value) {
|
||||
var obj: any = this.obj.eval(context, locals);
|
||||
var key: any = this.key.eval(context, locals);
|
||||
obj[key] = value;
|
||||
|
@ -138,7 +139,7 @@ export class Pipe extends AST {
|
|||
export class LiteralPrimitive extends AST {
|
||||
constructor(public value) { super(); }
|
||||
|
||||
eval(context, locals) { return this.value; }
|
||||
eval(context, locals: Locals) { return this.value; }
|
||||
|
||||
visit(visitor: AstVisitor) { return visitor.visitLiteralPrimitive(this); }
|
||||
}
|
||||
|
@ -146,7 +147,7 @@ export class LiteralPrimitive extends AST {
|
|||
export class LiteralArray extends AST {
|
||||
constructor(public expressions: List<any>) { super(); }
|
||||
|
||||
eval(context, locals) {
|
||||
eval(context, locals: Locals) {
|
||||
return ListWrapper.map(this.expressions, (e) => e.eval(context, locals));
|
||||
}
|
||||
|
||||
|
@ -156,7 +157,7 @@ export class LiteralArray extends AST {
|
|||
export class LiteralMap extends AST {
|
||||
constructor(public keys: List<any>, public values: List<any>) { super(); }
|
||||
|
||||
eval(context, locals) {
|
||||
eval(context, locals: Locals) {
|
||||
var res = StringMapWrapper.create();
|
||||
for (var i = 0; i < this.keys.length; ++i) {
|
||||
StringMapWrapper.set(res, this.keys[i], this.values[i].eval(context, locals));
|
||||
|
@ -178,7 +179,7 @@ export class Interpolation extends AST {
|
|||
export class Binary extends AST {
|
||||
constructor(public operation: string, public left: AST, public right: AST) { super(); }
|
||||
|
||||
eval(context, locals) {
|
||||
eval(context, locals: Locals) {
|
||||
var left: any = this.left.eval(context, locals);
|
||||
switch (this.operation) {
|
||||
case '&&':
|
||||
|
@ -229,7 +230,7 @@ export class Binary extends AST {
|
|||
export class PrefixNot extends AST {
|
||||
constructor(public expression: AST) { super(); }
|
||||
|
||||
eval(context, locals) { return !this.expression.eval(context, locals); }
|
||||
eval(context, locals: Locals) { return !this.expression.eval(context, locals); }
|
||||
|
||||
visit(visitor: AstVisitor) { return visitor.visitPrefixNot(this); }
|
||||
}
|
||||
|
@ -237,7 +238,7 @@ export class PrefixNot extends AST {
|
|||
export class Assignment extends AST {
|
||||
constructor(public target: AST, public value: AST) { super(); }
|
||||
|
||||
eval(context, locals) {
|
||||
eval(context, locals: Locals) {
|
||||
return this.target.assign(context, locals, this.value.eval(context, locals));
|
||||
}
|
||||
|
||||
|
@ -250,7 +251,7 @@ export class MethodCall extends AST {
|
|||
super();
|
||||
}
|
||||
|
||||
eval(context, locals) {
|
||||
eval(context, locals: Locals) {
|
||||
var evaluatedArgs = evalList(context, locals, this.args);
|
||||
if (this.receiver instanceof ImplicitReceiver && isPresent(locals) &&
|
||||
locals.contains(this.name)) {
|
||||
|
@ -271,7 +272,7 @@ export class SafeMethodCall extends AST {
|
|||
super();
|
||||
}
|
||||
|
||||
eval(context, locals) {
|
||||
eval(context, locals: Locals) {
|
||||
var evaluatedReceiver = this.receiver.eval(context, locals);
|
||||
if (isBlank(evaluatedReceiver)) return null;
|
||||
var evaluatedArgs = evalList(context, locals, this.args);
|
||||
|
@ -284,7 +285,7 @@ export class SafeMethodCall extends AST {
|
|||
export class FunctionCall extends AST {
|
||||
constructor(public target: AST, public args: List<any>) { super(); }
|
||||
|
||||
eval(context, locals) {
|
||||
eval(context, locals: Locals) {
|
||||
var obj: any = this.target.eval(context, locals);
|
||||
if (!(obj instanceof Function)) {
|
||||
throw new BaseException(`${obj} is not a function`);
|
||||
|
@ -298,11 +299,11 @@ export class FunctionCall extends AST {
|
|||
export class ASTWithSource extends AST {
|
||||
constructor(public ast: AST, public source: string, public location: string) { super(); }
|
||||
|
||||
eval(context, locals) { return this.ast.eval(context, locals); }
|
||||
eval(context, locals: Locals) { return this.ast.eval(context, locals); }
|
||||
|
||||
get isAssignable(): boolean { return this.ast.isAssignable; }
|
||||
|
||||
assign(context, locals, value) { return this.ast.assign(context, locals, value); }
|
||||
assign(context, locals: Locals, value) { return this.ast.assign(context, locals, value); }
|
||||
|
||||
visit(visitor: AstVisitor) { return this.ast.visit(visitor); }
|
||||
|
||||
|
@ -413,7 +414,7 @@ var _evalListCache = [
|
|||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
||||
];
|
||||
|
||||
function evalList(context, locals, exps: List<any>) {
|
||||
function evalList(context, locals: Locals, exps: List<any>) {
|
||||
var length = exps.length;
|
||||
if (length > 10) {
|
||||
throw new BaseException("Cannot have more than 10 argument");
|
||||
|
|
|
@ -609,7 +609,7 @@ class _DuplicateItemRecordList {
|
|||
}
|
||||
|
||||
class _DuplicateMap {
|
||||
map: Map<any, any>;
|
||||
map: Map<any, _DuplicateItemRecordList>;
|
||||
constructor() { this.map = MapWrapper.create(); }
|
||||
|
||||
put(record: CollectionChangeRecord) {
|
||||
|
|
|
@ -150,7 +150,7 @@ export class TreeNode<T extends TreeNode<any>> {
|
|||
get parent() { return this._parent; }
|
||||
|
||||
// TODO(rado): replace with a function call, does too much work for a getter.
|
||||
get children() {
|
||||
get children(): TreeNode<any>[] {
|
||||
var res = [];
|
||||
var child = this._head;
|
||||
while (child != null) {
|
||||
|
|
|
@ -9,8 +9,7 @@ import {NgControl} from './ng_control';
|
|||
import {Control} from '../model';
|
||||
import {setUpControl} from './shared';
|
||||
|
||||
const formControlBinding =
|
||||
CONST_EXPR(new Binding(NgControl, {toAlias: forwardRef(() => NgModel)}));
|
||||
const formControlBinding = CONST_EXPR(new Binding(NgControl, {toAlias: forwardRef(() => NgModel)}));
|
||||
|
||||
/**
|
||||
* Binds a domain model to the form.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/// <reference path="../../../../typings/hammerjs/hammerjs"/>
|
||||
/// <reference path="../../../../typings/hammerjs/hammerjs.d.ts"/>
|
||||
|
||||
import {HammerGesturesPluginCommon} from './hammer_common';
|
||||
import {isPresent, BaseException} from 'angular2/src/facade/lang';
|
||||
|
|
|
@ -90,8 +90,8 @@ export class Router {
|
|||
*/
|
||||
config(config: any): Promise<any> {
|
||||
if (config instanceof List) {
|
||||
config.forEach(
|
||||
(configObject) => { this._registry.config(this.hostComponent, configObject); });
|
||||
(<List<any>>config)
|
||||
.forEach((configObject) => { this._registry.config(this.hostComponent, configObject); });
|
||||
} else {
|
||||
this._registry.config(this.hostComponent, config);
|
||||
}
|
||||
|
|
|
@ -128,7 +128,7 @@ export class ViewProxy {
|
|||
this._view.changeDetector.checkNoChanges();
|
||||
}
|
||||
|
||||
querySelector(selector) { return queryView(this._view, selector); }
|
||||
querySelector(selector): any { return queryView(this._view, selector); }
|
||||
|
||||
destroy() { this._componentRef.dispose(); }
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ export function viewRootNodes(view): List</*node*/ any> {
|
|||
return resolveInternalDomView(view.render).rootNodes;
|
||||
}
|
||||
|
||||
export function queryView(view, selector: string) {
|
||||
export function queryView(view, selector: string): any {
|
||||
var rootNodes = viewRootNodes(view);
|
||||
for (var i = 0; i < rootNodes.length; ++i) {
|
||||
var res = DOM.querySelector(rootNodes[i], selector);
|
||||
|
|
|
@ -6,7 +6,7 @@ import {MapWrapper} from 'angular2/src/facade/collection';
|
|||
|
||||
export function main() {
|
||||
describe('Locals', () => {
|
||||
var locals;
|
||||
var locals: Locals;
|
||||
beforeEach(() => {
|
||||
locals = new Locals(null, MapWrapper.createFromPairs([['key', 'value'], ['nullKey', null]]));
|
||||
});
|
||||
|
|
|
@ -12,7 +12,6 @@ export function main() {
|
|||
describe('collection_changes', function() {
|
||||
describe('CollectionChanges', function() {
|
||||
var changes;
|
||||
var l;
|
||||
|
||||
beforeEach(() => { changes = new IterableChanges(); });
|
||||
|
||||
|
@ -26,7 +25,7 @@ export function main() {
|
|||
});
|
||||
|
||||
it('should support iterables', () => {
|
||||
l = new TestIterable();
|
||||
let l = new TestIterable();
|
||||
|
||||
changes.check(l);
|
||||
expect(changes.toString()).toEqual(iterableChangesAsString({collection: []}));
|
||||
|
@ -49,17 +48,17 @@ export function main() {
|
|||
});
|
||||
|
||||
it('should detect additions', () => {
|
||||
l = [];
|
||||
let l = [];
|
||||
changes.check(l);
|
||||
expect(changes.toString()).toEqual(iterableChangesAsString({collection: []}));
|
||||
|
||||
ListWrapper.push(l, 'a');
|
||||
l.push('a');
|
||||
changes.check(l);
|
||||
expect(changes.toString())
|
||||
.toEqual(
|
||||
iterableChangesAsString({collection: ['a[null->0]'], additions: ['a[null->0]']}));
|
||||
|
||||
ListWrapper.push(l, 'b');
|
||||
l.push('b');
|
||||
changes.check(l);
|
||||
expect(changes.toString())
|
||||
.toEqual(iterableChangesAsString(
|
||||
|
@ -67,7 +66,7 @@ export function main() {
|
|||
});
|
||||
|
||||
it('should support changing the reference', () => {
|
||||
l = [0];
|
||||
let l = [0];
|
||||
changes.check(l);
|
||||
|
||||
l = [1, 0];
|
||||
|
@ -92,12 +91,12 @@ export function main() {
|
|||
});
|
||||
|
||||
it('should handle swapping element', () => {
|
||||
l = [1, 2];
|
||||
let l = [1, 2];
|
||||
changes.check(l);
|
||||
|
||||
ListWrapper.clear(l);
|
||||
ListWrapper.push(l, 2);
|
||||
ListWrapper.push(l, 1);
|
||||
l.push(2);
|
||||
l.push(1);
|
||||
changes.check(l);
|
||||
expect(changes.toString())
|
||||
.toEqual(iterableChangesAsString({
|
||||
|
@ -108,7 +107,7 @@ export function main() {
|
|||
});
|
||||
|
||||
it('should handle swapping element', () => {
|
||||
l = ['a', 'b', 'c'];
|
||||
let l = ['a', 'b', 'c'];
|
||||
changes.check(l);
|
||||
|
||||
ListWrapper.removeAt(l, 1);
|
||||
|
@ -122,7 +121,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
ListWrapper.removeAt(l, 1);
|
||||
ListWrapper.push(l, 'a');
|
||||
l.push('a');
|
||||
changes.check(l);
|
||||
expect(changes.toString())
|
||||
.toEqual(iterableChangesAsString({
|
||||
|
@ -133,23 +132,23 @@ export function main() {
|
|||
});
|
||||
|
||||
it('should detect changes in list', () => {
|
||||
l = [];
|
||||
let l = [];
|
||||
changes.check(l);
|
||||
|
||||
ListWrapper.push(l, 'a');
|
||||
l.push('a');
|
||||
changes.check(l);
|
||||
expect(changes.toString())
|
||||
.toEqual(
|
||||
iterableChangesAsString({collection: ['a[null->0]'], additions: ['a[null->0]']}));
|
||||
|
||||
ListWrapper.push(l, 'b');
|
||||
l.push('b');
|
||||
changes.check(l);
|
||||
expect(changes.toString())
|
||||
.toEqual(iterableChangesAsString(
|
||||
{collection: ['a', 'b[null->1]'], previous: ['a'], additions: ['b[null->1]']}));
|
||||
|
||||
ListWrapper.push(l, 'c');
|
||||
ListWrapper.push(l, 'd');
|
||||
l.push('c');
|
||||
l.push('d');
|
||||
changes.check(l);
|
||||
expect(changes.toString())
|
||||
.toEqual(iterableChangesAsString({
|
||||
|
@ -169,10 +168,10 @@ export function main() {
|
|||
}));
|
||||
|
||||
ListWrapper.clear(l);
|
||||
ListWrapper.push(l, 'd');
|
||||
ListWrapper.push(l, 'c');
|
||||
ListWrapper.push(l, 'b');
|
||||
ListWrapper.push(l, 'a');
|
||||
l.push('d');
|
||||
l.push('c');
|
||||
l.push('b');
|
||||
l.push('a');
|
||||
changes.check(l);
|
||||
expect(changes.toString())
|
||||
.toEqual(iterableChangesAsString({
|
||||
|
@ -184,7 +183,7 @@ export function main() {
|
|||
});
|
||||
|
||||
it('should test string by value rather than by reference (Dart)', () => {
|
||||
l = ['a', 'boo'];
|
||||
let l = ['a', 'boo'];
|
||||
changes.check(l);
|
||||
|
||||
var b = 'b';
|
||||
|
@ -196,7 +195,7 @@ export function main() {
|
|||
});
|
||||
|
||||
it('should ignore [NaN] != [NaN] (JS)', () => {
|
||||
l = [NumberWrapper.NaN];
|
||||
let l = [NumberWrapper.NaN];
|
||||
changes.check(l);
|
||||
changes.check(l);
|
||||
expect(changes.toString())
|
||||
|
@ -205,7 +204,7 @@ export function main() {
|
|||
});
|
||||
|
||||
it('should detect [NaN] moves', () => {
|
||||
l = [NumberWrapper.NaN, NumberWrapper.NaN];
|
||||
let l = [NumberWrapper.NaN, NumberWrapper.NaN];
|
||||
changes.check(l);
|
||||
|
||||
ListWrapper.insert(l, 0, 'foo');
|
||||
|
@ -220,7 +219,7 @@ export function main() {
|
|||
});
|
||||
|
||||
it('should remove and add same item', () => {
|
||||
l = ['a', 'b', 'c'];
|
||||
let l = ['a', 'b', 'c'];
|
||||
changes.check(l);
|
||||
|
||||
ListWrapper.removeAt(l, 1);
|
||||
|
@ -245,7 +244,7 @@ export function main() {
|
|||
});
|
||||
|
||||
it('should support duplicates', () => {
|
||||
l = ['a', 'a', 'a', 'b', 'b'];
|
||||
let l = ['a', 'a', 'a', 'b', 'b'];
|
||||
changes.check(l);
|
||||
|
||||
ListWrapper.removeAt(l, 0);
|
||||
|
@ -260,7 +259,7 @@ export function main() {
|
|||
});
|
||||
|
||||
it('should support insertions/moves', () => {
|
||||
l = ['a', 'a', 'b', 'b'];
|
||||
let l = ['a', 'a', 'b', 'b'];
|
||||
changes.check(l);
|
||||
|
||||
ListWrapper.insert(l, 0, 'b');
|
||||
|
@ -275,13 +274,13 @@ export function main() {
|
|||
});
|
||||
|
||||
it('should not report unnecessary moves', () => {
|
||||
l = ['a', 'b', 'c'];
|
||||
let l = ['a', 'b', 'c'];
|
||||
changes.check(l);
|
||||
|
||||
ListWrapper.clear(l);
|
||||
ListWrapper.push(l, 'b');
|
||||
ListWrapper.push(l, 'a');
|
||||
ListWrapper.push(l, 'c');
|
||||
l.push('b');
|
||||
l.push('a');
|
||||
l.push('c');
|
||||
changes.check(l);
|
||||
expect(changes.toString())
|
||||
.toEqual(iterableChangesAsString({
|
||||
|
|
|
@ -16,7 +16,7 @@ import {bootstrap} from 'angular2/src/core/application';
|
|||
import {Component, Directive, View} from 'angular2/annotations';
|
||||
import {DOM} from 'angular2/src/dom/dom_adapter';
|
||||
import {PromiseWrapper} from 'angular2/src/facade/async';
|
||||
import {bind, Inject} from 'angular2/di';
|
||||
import {bind, Inject, Injector} from 'angular2/di';
|
||||
import {LifeCycle} from 'angular2/src/core/life_cycle/life_cycle';
|
||||
import {Testability, TestabilityRegistry} from 'angular2/src/core/testability/testability';
|
||||
import {DOCUMENT_TOKEN} from 'angular2/src/render/dom/dom_renderer';
|
||||
|
@ -181,7 +181,7 @@ export function main() {
|
|||
|
||||
PromiseWrapper.all([refPromise1, refPromise2])
|
||||
.then((refs) => {
|
||||
var registry = refs[0].injector.get(TestabilityRegistry);
|
||||
var registry = (<Injector>refs[0].injector).get(TestabilityRegistry);
|
||||
PromiseWrapper.all([
|
||||
refs[0]
|
||||
.injector.asyncGet(Testability),
|
||||
|
|
|
@ -29,7 +29,11 @@ import {AppViewManager} from 'angular2/src/core/compiler/view_manager';
|
|||
export function main() {
|
||||
describe('DynamicComponentLoader', function() {
|
||||
describe("loading into existing location", () => {
|
||||
it('should work', inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
function ijTestBed(fn: (ts: TestBed, async: AsyncTestCompleter) => void) {
|
||||
return inject([TestBed, AsyncTestCompleter], fn);
|
||||
}
|
||||
|
||||
it('should work', ijTestBed((tb: TestBed, async) => {
|
||||
tb.overrideView(MyComp, new viewAnn.View({
|
||||
template: '<dynamic-comp #dynamic></dynamic-comp>',
|
||||
directives: [DynamicComp]
|
||||
|
@ -48,7 +52,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it('should inject dependencies of the dynamically-loaded component',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
ijTestBed((tb: TestBed, async) => {
|
||||
tb.overrideView(MyComp, new viewAnn.View({
|
||||
template: '<dynamic-comp #dynamic></dynamic-comp>',
|
||||
directives: [DynamicComp]
|
||||
|
@ -65,7 +69,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it('should allow to destroy and create them via viewcontainer directives',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
ijTestBed((tb: TestBed, async) => {
|
||||
tb.overrideView(MyComp, new viewAnn.View({
|
||||
template:
|
||||
'<div><dynamic-comp #dynamic template="ng-if: ctxBoolProp"></dynamic-comp></div>',
|
||||
|
@ -103,7 +107,8 @@ export function main() {
|
|||
|
||||
describe("loading next to an existing location", () => {
|
||||
it('should work',
|
||||
inject([DynamicComponentLoader, TestBed, AsyncTestCompleter], (loader, tb, async) => {
|
||||
inject([DynamicComponentLoader, TestBed, AsyncTestCompleter], (loader, tb: TestBed,
|
||||
async) => {
|
||||
tb.overrideView(
|
||||
MyComp,
|
||||
new viewAnn.View(
|
||||
|
@ -121,7 +126,8 @@ export function main() {
|
|||
}));
|
||||
|
||||
it('should return a disposable component ref',
|
||||
inject([DynamicComponentLoader, TestBed, AsyncTestCompleter], (loader, tb, async) => {
|
||||
inject([DynamicComponentLoader, TestBed, AsyncTestCompleter], (loader, tb: TestBed,
|
||||
async) => {
|
||||
tb.overrideView(
|
||||
MyComp,
|
||||
new viewAnn.View(
|
||||
|
@ -148,7 +154,8 @@ export function main() {
|
|||
}));
|
||||
|
||||
it('should update host properties',
|
||||
inject([DynamicComponentLoader, TestBed, AsyncTestCompleter], (loader, tb, async) => {
|
||||
inject([DynamicComponentLoader, TestBed, AsyncTestCompleter], (loader, tb: TestBed,
|
||||
async) => {
|
||||
tb.overrideView(
|
||||
MyComp,
|
||||
new viewAnn.View(
|
||||
|
@ -175,7 +182,7 @@ export function main() {
|
|||
|
||||
describe('loading into a new location', () => {
|
||||
it('should allow to create, update and destroy components',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.overrideView(MyComp, new viewAnn.View({
|
||||
template: '<imp-ng-cmp #impview></imp-ng-cmp>',
|
||||
directives: [ImperativeViewComponentUsingNgComponent]
|
||||
|
@ -206,10 +213,9 @@ export function main() {
|
|||
});
|
||||
|
||||
describe('loadAsRoot', () => {
|
||||
|
||||
it('should allow to create, update and destroy components',
|
||||
inject([TestBed, AsyncTestCompleter, DynamicComponentLoader, DOCUMENT_TOKEN, Injector],
|
||||
(tb, async, dcl, doc, injector) => {
|
||||
(tb: TestBed, async, dcl, doc, injector) => {
|
||||
var rootEl = el('<child-cmp></child-cmp>');
|
||||
DOM.appendChild(doc.body, rootEl);
|
||||
dcl.loadAsRoot(ChildComp, null, injector)
|
||||
|
|
|
@ -236,7 +236,7 @@ export function main() {
|
|||
return ProtoElementInjector.create(parent, index, directiveBinding, hasShadowRoot, distance);
|
||||
}
|
||||
|
||||
function humanize(tree, names: List<List<any>>) {
|
||||
function humanize(tree: TreeNode<any>, names: List<List<any>>) {
|
||||
var lookupName = (item) =>
|
||||
ListWrapper.last(ListWrapper.find(names, (pair) => pair[0] === item));
|
||||
|
||||
|
|
|
@ -83,7 +83,8 @@ export function main() {
|
|||
|
||||
|
||||
describe('react to record changes', function() {
|
||||
it('should consume text node changes', inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
it('should consume text node changes',
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.overrideView(MyComp, new viewAnn.View({template: '<div>{{ctxProp}}</div>'}));
|
||||
tb.createView(MyComp, {context: ctx})
|
||||
.then((view) => {
|
||||
|
@ -96,7 +97,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it('should consume element binding changes',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.overrideView(MyComp, new viewAnn.View({template: '<div [id]="ctxProp"></div>'}));
|
||||
|
||||
tb.createView(MyComp, {context: ctx})
|
||||
|
@ -111,7 +112,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it('should consume binding to aria-* attributes',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.overrideView(MyComp,
|
||||
new viewAnn.View({template: '<div [attr.aria-label]="ctxProp"></div>'}));
|
||||
|
||||
|
@ -133,7 +134,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it('should consume binding to property names where attr name and property name do not match',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.overrideView(MyComp,
|
||||
new viewAnn.View({template: '<div [tabindex]="ctxNumProp"></div>'}));
|
||||
|
||||
|
@ -152,7 +153,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it('should consume binding to camel-cased properties using dash-cased syntax in templates',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.overrideView(MyComp,
|
||||
new viewAnn.View({template: '<input [read-only]="ctxBoolProp">'}));
|
||||
|
||||
|
@ -171,7 +172,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it('should consume binding to inner-html',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.overrideView(MyComp,
|
||||
new viewAnn.View({template: '<div inner-html="{{ctxProp}}"></div>'}));
|
||||
|
||||
|
@ -191,7 +192,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it('should ignore bindings to unknown properties',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.overrideView(MyComp,
|
||||
new viewAnn.View({template: '<div unknown="{{ctxProp}}"></div>'}));
|
||||
|
||||
|
@ -207,7 +208,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it('should consume directive watch expression change.',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
var tpl = '<div>' +
|
||||
'<div my-dir [elprop]="ctxProp"></div>' +
|
||||
'<div my-dir elprop="Hi there!"></div>' +
|
||||
|
@ -243,7 +244,7 @@ export function main() {
|
|||
});
|
||||
|
||||
it("should support pipes in bindings and bind config",
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.overrideView(MyComp, new viewAnn.View({
|
||||
template:
|
||||
'<component-with-pipes #comp [prop]="ctxProp | double"></component-with-pipes>',
|
||||
|
@ -264,7 +265,8 @@ export function main() {
|
|||
}));
|
||||
});
|
||||
|
||||
it('should support nested components.', inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
it('should support nested components.',
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.overrideView(
|
||||
MyComp,
|
||||
new viewAnn.View({template: '<child-cmp></child-cmp>', directives: [ChildComp]}));
|
||||
|
@ -281,7 +283,7 @@ export function main() {
|
|||
|
||||
// GH issue 328 - https://github.com/angular/angular/issues/328
|
||||
it('should support different directive types on a single node',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.overrideView(MyComp, new viewAnn.View({
|
||||
template: '<child-cmp my-dir [elprop]="ctxProp"></child-cmp>',
|
||||
directives: [MyDir, ChildComp]
|
||||
|
@ -302,7 +304,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it('should support directives where a binding attribute is not given',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.overrideView(MyComp, new viewAnn.View({
|
||||
// No attribute "el-prop" specified.
|
||||
template: '<p my-dir></p>',
|
||||
|
@ -313,7 +315,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it('should support directives where a selector matches property binding',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.overrideView(
|
||||
MyComp, new viewAnn.View({template: '<p [id]="ctxProp"></p>', directives: [IdDir]}));
|
||||
|
||||
|
@ -334,7 +336,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it('should allow specifying directives as bindings',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.overrideView(MyComp, new viewAnn.View({
|
||||
template: '<child-cmp></child-cmp>',
|
||||
directives: [bind(ChildComp).toClass(ChildComp)]
|
||||
|
@ -350,7 +352,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it('should read directives metadata from their binding token',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.overrideView(MyComp, new viewAnn.View({
|
||||
template: '<div public-api><div needs-public-api></div></div>',
|
||||
directives: [bind(PublicApi).toClass(PrivateImpl), NeedsPublicApi]
|
||||
|
@ -360,7 +362,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it('should support template directives via `<template>` elements.',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.overrideView(MyComp, new viewAnn.View({
|
||||
template:
|
||||
'<div><template some-viewport var-greeting="some-tmpl"><copy-me>{{greeting}}</copy-me></template></div>',
|
||||
|
@ -382,7 +384,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it('should support template directives via `template` attribute.',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.overrideView(MyComp, new viewAnn.View({
|
||||
template:
|
||||
'<div><copy-me template="some-viewport: var greeting=some-tmpl">{{greeting}}</copy-me></div>',
|
||||
|
@ -403,7 +405,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it('should allow to transplant embedded ProtoViews into other ViewContainers',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.overrideView(MyComp, new viewAnn.View({
|
||||
template:
|
||||
'<some-directive><toolbar><template toolbarpart var-toolbar-prop="toolbarProp">{{ctxProp}},{{toolbarProp}},<cmp-with-parent></cmp-with-parent></template></toolbar></some-directive>',
|
||||
|
@ -424,7 +426,7 @@ export function main() {
|
|||
|
||||
describe("variable bindings", () => {
|
||||
it('should assign a component to a var-',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.overrideView(MyComp, new viewAnn.View({
|
||||
template: '<p><child-cmp var-alice></child-cmp></p>',
|
||||
directives: [ChildComp]
|
||||
|
@ -440,7 +442,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it('should assign a directive to a var-',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.overrideView(MyComp, new viewAnn.View({
|
||||
template: '<p><div [export-dir] #localdir="dir"></div></p>',
|
||||
directives: [ExportDir]
|
||||
|
@ -456,7 +458,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it('should make the assigned component accessible in property bindings',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.overrideView(MyComp, new viewAnn.View({
|
||||
template: '<p><child-cmp var-alice></child-cmp>{{alice.ctxProp}}</p>',
|
||||
directives: [ChildComp]
|
||||
|
@ -474,7 +476,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it('should assign two component instances each with a var-',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.overrideView(MyComp, new viewAnn.View({
|
||||
template: '<p><child-cmp var-alice></child-cmp><child-cmp var-bob></p>',
|
||||
directives: [ChildComp]
|
||||
|
@ -494,7 +496,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it('should assign the component instance to a var- with shorthand syntax',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.overrideView(
|
||||
MyComp,
|
||||
new viewAnn.View(
|
||||
|
@ -511,7 +513,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it('should assign the element instance to a user-defined variable',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.overrideView(
|
||||
MyComp, new viewAnn.View({template: '<p><div var-alice><i>Hello</i></div></p>'}));
|
||||
|
||||
|
@ -528,7 +530,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it('should change dash-case to camel-case',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.overrideView(MyComp, new viewAnn.View({
|
||||
template: '<p><child-cmp var-super-alice></child-cmp></p>',
|
||||
directives: [ChildComp]
|
||||
|
@ -546,7 +548,7 @@ export function main() {
|
|||
|
||||
describe("ON_PUSH components", () => {
|
||||
it("should use ChangeDetectorRef to manually request a check",
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
|
||||
tb.overrideView(MyComp, new viewAnn.View({
|
||||
template: '<push-cmp-with-ref #cmp></push-cmp-with-ref>',
|
||||
|
@ -573,7 +575,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it("should be checked when its bindings got updated",
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
|
||||
tb.overrideView(MyComp, new viewAnn.View({
|
||||
template: '<push-cmp [prop]="ctxProp" #cmp></push-cmp>',
|
||||
|
@ -597,7 +599,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it('should not affect updating properties on the component',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.overrideView(MyComp, new viewAnn.View({
|
||||
template: '<push-cmp-with-ref [prop]="ctxProp" #cmp></push-cmp-with-ref>',
|
||||
directives: [[[PushCmpWithRef]]]
|
||||
|
@ -622,7 +624,7 @@ export function main() {
|
|||
});
|
||||
|
||||
it('should create a component that injects a @Parent',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.overrideView(MyComp, new viewAnn.View({
|
||||
template:
|
||||
'<some-directive><cmp-with-parent #child></cmp-with-parent></some-directive>',
|
||||
|
@ -640,7 +642,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it('should create a component that injects an @Ancestor',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.overrideView(MyComp, new viewAnn.View({
|
||||
template: `
|
||||
<some-directive>
|
||||
|
@ -662,7 +664,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it('should create a component that injects an @Ancestor through viewcontainer directive',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.overrideView(MyComp, new viewAnn.View({
|
||||
template: `
|
||||
<some-directive>
|
||||
|
@ -686,7 +688,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it('should support events via EventEmitter',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.overrideView(MyComp, new viewAnn.View({
|
||||
template: '<div emitter listener></div>',
|
||||
directives: [DirectiveEmitingEvent, DirectiveListeningEvent]
|
||||
|
@ -711,7 +713,8 @@ export function main() {
|
|||
});
|
||||
}));
|
||||
|
||||
it('should support [()] syntax', inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
it('should support [()] syntax',
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.overrideView(MyComp, new viewAnn.View({
|
||||
template: '<div [(control)]="ctxProp" two-way></div>',
|
||||
directives: [DirectiveWithTwoWayBinding]
|
||||
|
@ -738,7 +741,7 @@ export function main() {
|
|||
|
||||
if (DOM.supportsDOMEvents()) {
|
||||
it("should support invoking methods on the host element via hostActions",
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.overrideView(MyComp, new viewAnn.View({
|
||||
template: '<div update-host-actions></div>',
|
||||
directives: [DirectiveUpdatingHostActions]
|
||||
|
@ -760,7 +763,8 @@ export function main() {
|
|||
}));
|
||||
}
|
||||
|
||||
it('should support render events', inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
it('should support render events',
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.overrideView(
|
||||
MyComp,
|
||||
new viewAnn.View(
|
||||
|
@ -782,7 +786,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it('should support render global events',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.overrideView(
|
||||
MyComp,
|
||||
new viewAnn.View(
|
||||
|
@ -810,7 +814,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it('should support updating host element via hostAttributes',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.overrideView(MyComp, new viewAnn.View({
|
||||
template: '<div update-host-attributes></div>',
|
||||
directives: [DirectiveUpdatingHostAttributes]
|
||||
|
@ -827,7 +831,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it('should support updating host element via hostProperties',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.overrideView(MyComp, new viewAnn.View({
|
||||
template: '<div update-host-properties></div>',
|
||||
directives: [DirectiveUpdatingHostProperties]
|
||||
|
@ -851,7 +855,7 @@ export function main() {
|
|||
|
||||
if (DOM.supportsDOMEvents()) {
|
||||
it('should support preventing default on render events',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.overrideView(MyComp, new viewAnn.View({
|
||||
template:
|
||||
'<input type="checkbox" listenerprevent></input><input type="checkbox" listenernoprevent></input>',
|
||||
|
@ -873,7 +877,7 @@ export function main() {
|
|||
}
|
||||
|
||||
it('should support render global events from multiple directives',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.overrideView(MyComp, new viewAnn.View({
|
||||
template: '<div *ng-if="ctxBoolProp" listener listenerother></div>',
|
||||
directives: [NgIf, DirectiveListeningDomEvent, DirectiveListeningDomEventOther]
|
||||
|
@ -911,7 +915,7 @@ export function main() {
|
|||
describe('dynamic ViewContainers', () => {
|
||||
|
||||
it('should allow to create a ViewContainerRef at any bound location',
|
||||
inject([TestBed, AsyncTestCompleter, Compiler], (tb, async, compiler) => {
|
||||
inject([TestBed, AsyncTestCompleter, Compiler], (tb: TestBed, async, compiler) => {
|
||||
tb.overrideView(MyComp, new viewAnn.View({
|
||||
template: '<div><dynamic-vp #dynamic></dynamic-vp></div>',
|
||||
directives: [DynamicViewport]
|
||||
|
@ -929,7 +933,8 @@ export function main() {
|
|||
|
||||
});
|
||||
|
||||
it('should support static attributes', inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
it('should support static attributes',
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.overrideView(
|
||||
MyComp,
|
||||
new viewAnn.View(
|
||||
|
@ -948,7 +953,8 @@ export function main() {
|
|||
});
|
||||
|
||||
describe("dependency injection", () => {
|
||||
it("should support hostInjector", inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
it("should support hostInjector",
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.overrideView(MyComp, new viewAnn.View({
|
||||
template: `
|
||||
<directive-providing-injectable>
|
||||
|
@ -969,7 +975,7 @@ export function main() {
|
|||
|
||||
|
||||
it('should prioritze hostInjector over viewInjector for the same binding',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.overrideView(MyComp, new viewAnn.View({
|
||||
template: `
|
||||
<directive-providing-injectable>
|
||||
|
@ -989,7 +995,8 @@ export function main() {
|
|||
});
|
||||
}));
|
||||
|
||||
it("should support viewInjector", inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
it("should support viewInjector",
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.overrideView(DirectiveProvidingInjectableInView, new viewAnn.View({
|
||||
template: `
|
||||
<directive-consuming-injectable #consuming>
|
||||
|
@ -1007,7 +1014,8 @@ export function main() {
|
|||
});
|
||||
}));
|
||||
|
||||
it("should support unbounded lookup", inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
it("should support unbounded lookup",
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.overrideView(MyComp, new viewAnn.View({
|
||||
template: `
|
||||
<directive-providing-injectable>
|
||||
|
@ -1038,7 +1046,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it("should support the event-bus scenario",
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.overrideView(MyComp, new viewAnn.View({
|
||||
template: `
|
||||
<grand-parent-providing-event-bus>
|
||||
|
@ -1074,7 +1082,7 @@ export function main() {
|
|||
|
||||
describe("error handling", () => {
|
||||
it('should report a meaningful error when a directive is missing annotation',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.overrideView(MyComp,
|
||||
new viewAnn.View({directives: [SomeDirectiveMissingAnnotation]}));
|
||||
|
||||
|
@ -1082,11 +1090,12 @@ export function main() {
|
|||
expect(e.message).toEqual(
|
||||
`No Directive annotation found on ${stringify(SomeDirectiveMissingAnnotation)}`);
|
||||
async.done();
|
||||
return null;
|
||||
});
|
||||
}));
|
||||
|
||||
it('should report a meaningful error when a directive is null',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
|
||||
tb.overrideView(MyComp, new viewAnn.View({directives: [[null]]}));
|
||||
|
||||
|
@ -1094,12 +1103,13 @@ export function main() {
|
|||
expect(e.message).toEqual(
|
||||
`Unexpected directive value 'null' on the View of component '${stringify(MyComp)}'`);
|
||||
async.done();
|
||||
return null;
|
||||
});
|
||||
}));
|
||||
|
||||
if (!IS_DARTIUM) {
|
||||
it('should report a meaningful error when a directive is undefined',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
|
||||
var undefinedValue;
|
||||
|
||||
|
@ -1109,12 +1119,13 @@ export function main() {
|
|||
expect(e.message).toEqual(
|
||||
`Unexpected directive value 'undefined' on the View of component '${stringify(MyComp)}'`);
|
||||
async.done();
|
||||
return null;
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
it('should specify a location of an error that happened during change detection (text)',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
|
||||
tb.overrideView(MyComp, new viewAnn.View({template: '{{a.b}}'}));
|
||||
|
||||
|
@ -1127,7 +1138,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it('should specify a location of an error that happened during change detection (element property)',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
|
||||
tb.overrideView(MyComp, new viewAnn.View({template: '<div [prop]="a.b"></div>'}));
|
||||
|
||||
|
@ -1140,7 +1151,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it('should specify a location of an error that happened during change detection (directive property)',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
|
||||
tb.overrideView(
|
||||
MyComp,
|
||||
|
@ -1156,7 +1167,8 @@ export function main() {
|
|||
}));
|
||||
});
|
||||
|
||||
it('should support imperative views', inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
it('should support imperative views',
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.overrideView(MyComp, new viewAnn.View({
|
||||
template: '<simple-imp-cmp></simple-imp-cmp>',
|
||||
directives: [SimpleImperativeViewComponent]
|
||||
|
@ -1210,27 +1222,27 @@ export function main() {
|
|||
}
|
||||
|
||||
it('should raise an error if no directive is registered for a template with template bindings',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
expectCompileError(tb, '<div><div template="if: foo"></div></div>',
|
||||
'Missing directive to handle \'if\' in <div template="if: foo">',
|
||||
() => async.done());
|
||||
}));
|
||||
|
||||
it('should raise an error for missing template directive (1)',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
expectCompileError(tb, '<div><template foo></template></div>',
|
||||
'Missing directive to handle: <template foo>', () => async.done());
|
||||
}));
|
||||
|
||||
it('should raise an error for missing template directive (2)',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
expectCompileError(tb, '<div><template *ng-if="condition"></template></div>',
|
||||
'Missing directive to handle: <template *ng-if="condition">',
|
||||
() => async.done());
|
||||
}));
|
||||
|
||||
it('should raise an error for missing template directive (3)',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
expectCompileError(
|
||||
tb, '<div *ng-if="condition"></div>',
|
||||
'Missing directive to handle \'if\' in MyComp: <div *ng-if="condition">',
|
||||
|
|
|
@ -26,7 +26,7 @@ export function main() {
|
|||
describe('Query API', () => {
|
||||
|
||||
it('should contain all direct child directives in the light dom',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
var template = '<div text="1"></div>' +
|
||||
'<needs-query text="2"><div text="3">' +
|
||||
'<div text="too-deep"></div>' +
|
||||
|
@ -43,7 +43,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it('should contain all directives in the light dom when descendants flag is used',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
var template = '<div text="1"></div>' +
|
||||
'<needs-query-desc text="2"><div text="3">' +
|
||||
'<div text="4"></div>' +
|
||||
|
@ -60,7 +60,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it('should contain all directives in the light dom',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
var template = '<div text="1"></div>' +
|
||||
'<needs-query text="2"><div text="3"></div></needs-query>' +
|
||||
'<div text="4"></div>';
|
||||
|
@ -78,7 +78,7 @@ export function main() {
|
|||
// but due to a bug with how injectors are hooked up query considers the
|
||||
// directives to be distances 2 instead of direct children.
|
||||
it('should reflect dynamically inserted directives',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
var template =
|
||||
'<div text="1"></div>' +
|
||||
'<needs-query-desc text="2"><div *ng-if="shouldShow" [text]="\'3\'"></div></needs-query-desc>' +
|
||||
|
@ -98,7 +98,8 @@ export function main() {
|
|||
});
|
||||
}));
|
||||
|
||||
it('should reflect moved directives', inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
it('should reflect moved directives',
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
var template =
|
||||
'<div text="1"></div>' +
|
||||
'<needs-query-desc text="2"><div *ng-for="var i of list" [text]="i"></div></needs-query-desc>' +
|
||||
|
|
|
@ -32,7 +32,7 @@ export function main() {
|
|||
beforeEach(() => { ctx = new MyComp(); });
|
||||
|
||||
it('should invoke lifecycle methods onChange > onInit > onCheck > onAllChangesDone',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.overrideView(
|
||||
MyComp,
|
||||
new viewAnn.View(
|
||||
|
|
|
@ -18,7 +18,7 @@ import {Type} from 'angular2/src/facade/lang';
|
|||
export function main() {
|
||||
describe("forwardRef integration", function() {
|
||||
it('should instantiate components which are declared using forwardRef',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.createView(App).then((view) => {
|
||||
view.detectChanges();
|
||||
expect(view.rootNodes).toHaveText('frame(lock)');
|
||||
|
|
|
@ -3,7 +3,7 @@ import {Key, KeyRegistry} from 'angular2/di';
|
|||
|
||||
export function main() {
|
||||
describe("key", function() {
|
||||
var registry;
|
||||
var registry: KeyRegistry;
|
||||
|
||||
beforeEach(function() { registry = new KeyRegistry(); });
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ export function main() {
|
|||
describe('binding to CSS class list', () => {
|
||||
|
||||
it('should add classes specified in an object literal',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
var template = '<div [class]="{foo: true, bar: false}"></div>';
|
||||
|
||||
tb.createView(TestComponent, {html: template})
|
||||
|
@ -38,7 +38,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it('should add and remove classes based on changes in object literal values',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
var template = '<div [class]="{foo: condition, bar: !condition}"></div>';
|
||||
|
||||
tb.createView(TestComponent, {html: template})
|
||||
|
@ -55,7 +55,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it('should add and remove classes based on changes to the expression object',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
var template = '<div [class]="expr"></div>';
|
||||
|
||||
tb.createView(TestComponent, {html: template})
|
||||
|
@ -80,7 +80,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it('should retain existing classes when expression evaluates to null',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
var template = '<div [class]="expr"></div>';
|
||||
|
||||
tb.createView(TestComponent, {html: template})
|
||||
|
@ -101,7 +101,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it('should co-operate with the class attribute',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
var template = '<div [class]="expr" class="init foo"></div>';
|
||||
|
||||
tb.createView(TestComponent, {html: template})
|
||||
|
@ -119,7 +119,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it('should co-operate with the class attribute and class.name binding',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
var template = '<div class="init foo" [class]="expr" [class.baz]="condition"></div>';
|
||||
|
||||
tb.createView(TestComponent, {html: template})
|
||||
|
|
|
@ -27,7 +27,8 @@ export function main() {
|
|||
var TEMPLATE =
|
||||
'<div><copy-me template="ng-for #item of items">{{item.toString()}};</copy-me></div>';
|
||||
|
||||
it('should reflect initial elements', inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
it('should reflect initial elements',
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.createView(TestComponent, {html: TEMPLATE})
|
||||
.then((view) => {
|
||||
view.detectChanges();
|
||||
|
@ -36,7 +37,8 @@ export function main() {
|
|||
});
|
||||
}));
|
||||
|
||||
it('should reflect added elements', inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
it('should reflect added elements',
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.createView(TestComponent, {html: TEMPLATE})
|
||||
.then((view) => {
|
||||
view.detectChanges();
|
||||
|
@ -49,7 +51,8 @@ export function main() {
|
|||
});
|
||||
}));
|
||||
|
||||
it('should reflect removed elements', inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
it('should reflect removed elements',
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.createView(TestComponent, {html: TEMPLATE})
|
||||
.then((view) => {
|
||||
view.detectChanges();
|
||||
|
@ -62,7 +65,8 @@ export function main() {
|
|||
});
|
||||
}));
|
||||
|
||||
it('should reflect moved elements', inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
it('should reflect moved elements',
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.createView(TestComponent, {html: TEMPLATE})
|
||||
.then((view) => {
|
||||
view.detectChanges();
|
||||
|
@ -77,7 +81,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it('should reflect a mix of all changes (additions/removals/moves)',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.createView(TestComponent, {html: TEMPLATE})
|
||||
.then((view) => {
|
||||
view.context.items = [0, 1, 2, 3, 4, 5];
|
||||
|
@ -92,7 +96,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it('should iterate over an array of objects',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
var template = '<ul><li template="ng-for #item of items">{{item["name"]}};</li></ul>';
|
||||
|
||||
tb.createView(TestComponent, {html: template})
|
||||
|
@ -119,7 +123,8 @@ export function main() {
|
|||
});
|
||||
}));
|
||||
|
||||
it('should gracefully handle nulls', inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
it('should gracefully handle nulls',
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
var template = '<ul><li template="ng-for #item of null">{{item}};</li></ul>';
|
||||
tb.createView(TestComponent, {html: template})
|
||||
.then((view) => {
|
||||
|
@ -130,7 +135,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it('should gracefully handle ref changing to null and back',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.createView(TestComponent, {html: TEMPLATE})
|
||||
.then((view) => {
|
||||
view.detectChanges();
|
||||
|
@ -148,7 +153,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it('should throw on ref changing to string',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.createView(TestComponent, {html: TEMPLATE})
|
||||
.then((view) => {
|
||||
view.detectChanges();
|
||||
|
@ -160,7 +165,8 @@ export function main() {
|
|||
});
|
||||
}));
|
||||
|
||||
it('should works with duplicates', inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
it('should works with duplicates',
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.createView(TestComponent, {html: TEMPLATE})
|
||||
.then((view) => {
|
||||
var a = new Foo();
|
||||
|
@ -171,7 +177,8 @@ export function main() {
|
|||
});
|
||||
}));
|
||||
|
||||
it('should repeat over nested arrays', inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
it('should repeat over nested arrays',
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
var template = '<div>' +
|
||||
'<div template="ng-for #item of items">' +
|
||||
'<div template="ng-for #subitem of item">' +
|
||||
|
@ -197,7 +204,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it('should repeat over nested arrays with no intermediate element',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
var template = '<div><template [ng-for] #item [ng-for-of]="items">' +
|
||||
'<div template="ng-for #subitem of item">' +
|
||||
'{{subitem}}-{{item.length}};' +
|
||||
|
@ -216,7 +223,8 @@ export function main() {
|
|||
});
|
||||
}));
|
||||
|
||||
it('should display indices correctly', inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
it('should display indices correctly',
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
var template =
|
||||
'<div><copy-me template="ng-for: var item of items; var i=index">{{i.toString()}}</copy-me></div>';
|
||||
|
||||
|
|
|
@ -22,7 +22,8 @@ import {NgIf} from 'angular2/src/directives/ng_if';
|
|||
|
||||
export function main() {
|
||||
describe('if directive', () => {
|
||||
it('should work in a template attribute', inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
it('should work in a template attribute',
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
var html = '<div><copy-me template="ng-if booleanCondition">hello</copy-me></div>';
|
||||
|
||||
tb.createView(TestComponent, {html: html})
|
||||
|
@ -34,7 +35,8 @@ export function main() {
|
|||
});
|
||||
}));
|
||||
|
||||
it('should work in a template element', inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
it('should work in a template element',
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
var html =
|
||||
'<div><template [ng-if]="booleanCondition"><copy-me>hello2</copy-me></template></div>';
|
||||
|
||||
|
@ -48,7 +50,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it('should toggle node when condition changes',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
var html = '<div><copy-me template="ng-if booleanCondition">hello</copy-me></div>';
|
||||
|
||||
tb.createView(TestComponent, {html: html})
|
||||
|
@ -72,7 +74,8 @@ export function main() {
|
|||
});
|
||||
}));
|
||||
|
||||
it('should handle nested if correctly', inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
it('should handle nested if correctly',
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
var html =
|
||||
'<div><template [ng-if]="booleanCondition"><copy-me *ng-if="nestedBooleanCondition">hello</copy-me></template></div>';
|
||||
|
||||
|
@ -107,7 +110,8 @@ export function main() {
|
|||
});
|
||||
}));
|
||||
|
||||
it('should update several nodes with if', inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
it('should update several nodes with if',
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
var html =
|
||||
'<div>' +
|
||||
'<copy-me template="ng-if numberCondition + 1 >= 2">helloNumber</copy-me>' +
|
||||
|
@ -139,7 +143,7 @@ export function main() {
|
|||
|
||||
if (!IS_DARTIUM) {
|
||||
it('should not add the element twice if the condition goes from true to true (JS)',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
var html = '<div><copy-me template="ng-if numberCondition">hello</copy-me></div>';
|
||||
|
||||
tb.createView(TestComponent, {html: html})
|
||||
|
@ -158,7 +162,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it('should not recreate the element if the condition goes from true to true (JS)',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
var html = '<div><copy-me template="ng-if numberCondition">hello</copy-me></div>';
|
||||
|
||||
tb.createView(TestComponent, {html: html})
|
||||
|
@ -177,7 +181,7 @@ export function main() {
|
|||
|
||||
if (IS_DARTIUM) {
|
||||
it('should not create the element if the condition is not a boolean (DART)',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
var html = '<div><copy-me template="ng-if numberCondition">hello</copy-me></div>';
|
||||
|
||||
tb.createView(TestComponent, {html: html})
|
||||
|
|
|
@ -21,7 +21,8 @@ import {TestBed} from 'angular2/src/test_lib/test_bed';
|
|||
export function main() {
|
||||
describe('switch', () => {
|
||||
describe('switch value changes', () => {
|
||||
it('should switch amongst when values', inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
it('should switch amongst when values',
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
var template = '<div>' +
|
||||
'<ul [ng-switch]="switchValue">' +
|
||||
'<template [ng-switch-when]="\'a\'"><li>when a</li></template>' +
|
||||
|
@ -46,7 +47,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it('should switch amongst when values with fallback to default',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
var template = '<div>' +
|
||||
'<ul [ng-switch]="switchValue">' +
|
||||
'<li template="ng-switch-when \'a\'">when a</li>' +
|
||||
|
@ -71,7 +72,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it('should support multiple whens with the same value',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
var template = '<div>' +
|
||||
'<ul [ng-switch]="switchValue">' +
|
||||
'<template [ng-switch-when]="\'a\'"><li>when a1;</li></template>' +
|
||||
|
@ -101,7 +102,8 @@ export function main() {
|
|||
});
|
||||
|
||||
describe('when values changes', () => {
|
||||
it('should switch amongst when values', inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
it('should switch amongst when values',
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
var template = '<div>' +
|
||||
'<ul [ng-switch]="switchValue">' +
|
||||
'<template [ng-switch-when]="when1"><li>when 1;</li></template>' +
|
||||
|
|
|
@ -22,7 +22,8 @@ import {TestBed} from 'angular2/src/test_lib/test_bed';
|
|||
|
||||
export function main() {
|
||||
describe('non-bindable', () => {
|
||||
it('should not interpolate children', inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
it('should not interpolate children',
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
var template = '<div>{{text}}<span ng-non-bindable>{{text}}</span></div>';
|
||||
tb.createView(TestComponent, {html: template})
|
||||
.then((view) => {
|
||||
|
@ -33,7 +34,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it('should ignore directives on child nodes',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
var template = '<div ng-non-bindable><span id=child test-dec>{{text}}</span></div>';
|
||||
tb.createView(TestComponent, {html: template})
|
||||
.then((view) => {
|
||||
|
@ -45,7 +46,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it('should trigger directives on the same node',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
var template = '<div><span id=child ng-non-bindable test-dec>{{text}}</span></div>';
|
||||
tb.createView(TestComponent, {html: template})
|
||||
.then((view) => {
|
||||
|
|
|
@ -34,7 +34,7 @@ import {
|
|||
export function main() {
|
||||
describe("integration tests", () => {
|
||||
it("should initialize DOM elements with the given form object",
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
var ctx = MyComp.create({form: new ControlGroup({"login": new Control("loginValue")})});
|
||||
|
||||
var t = `<div [ng-form-model]="form">
|
||||
|
@ -52,7 +52,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it("should update the control group values on DOM change",
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
var form = new ControlGroup({"login": new Control("oldValue")});
|
||||
var ctx = MyComp.create({form: form});
|
||||
|
||||
|
@ -92,7 +92,8 @@ export function main() {
|
|||
});
|
||||
})));
|
||||
|
||||
it("should work with single controls", inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
it("should work with single controls",
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
var control = new Control("loginValue");
|
||||
var ctx = MyComp.create({form: control});
|
||||
|
||||
|
@ -113,7 +114,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it("should update DOM elements when rebinding the control group",
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
var form = new ControlGroup({"login": new Control("oldValue")});
|
||||
var ctx = MyComp.create({form: form});
|
||||
|
||||
|
@ -134,7 +135,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it("should update DOM elements when updating the value of a control",
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
var login = new Control("oldValue");
|
||||
var form = new ControlGroup({"login": login});
|
||||
var ctx = MyComp.create({form: form});
|
||||
|
@ -158,7 +159,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it("should mark controls as touched after interacting with the DOM control",
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
var login = new Control("oldValue");
|
||||
var form = new ControlGroup({"login": login});
|
||||
var ctx = MyComp.create({form: form});
|
||||
|
@ -184,7 +185,8 @@ export function main() {
|
|||
}));
|
||||
|
||||
describe("different control types", () => {
|
||||
it("should support <input type=text>", inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
it("should support <input type=text>",
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
var ctx = MyComp.create({form: new ControlGroup({"text": new Control("old")})});
|
||||
|
||||
var t = `<div [ng-form-model]="form">
|
||||
|
@ -206,7 +208,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it("should support <input> without type",
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
var ctx = MyComp.create({form: new ControlGroup({"text": new Control("old")})});
|
||||
|
||||
var t = `<div [ng-form-model]="form">
|
||||
|
@ -227,7 +229,8 @@ export function main() {
|
|||
});
|
||||
}));
|
||||
|
||||
it("should support <textarea>", inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
it("should support <textarea>",
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
var ctx = MyComp.create({form: new ControlGroup({"text": new Control('old')})});
|
||||
|
||||
var t = `<div [ng-form-model]="form">
|
||||
|
@ -248,7 +251,8 @@ export function main() {
|
|||
});
|
||||
}));
|
||||
|
||||
it("should support <type=checkbox>", inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
it("should support <type=checkbox>",
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
var ctx = MyComp.create({form: new ControlGroup({"checkbox": new Control(true)})});
|
||||
|
||||
var t = `<div [ng-form-model]="form">
|
||||
|
@ -269,7 +273,7 @@ export function main() {
|
|||
});
|
||||
}));
|
||||
|
||||
it("should support <select>", inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
it("should support <select>", inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
var ctx = MyComp.create({form: new ControlGroup({"city": new Control("SF")})});
|
||||
|
||||
var t = `<div [ng-form-model]="form">
|
||||
|
@ -297,7 +301,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it("should support custom value accessors",
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
var ctx = MyComp.create({form: new ControlGroup({"name": new Control("aa")})});
|
||||
|
||||
var t = `<div [ng-form-model]="form">
|
||||
|
@ -321,7 +325,7 @@ export function main() {
|
|||
|
||||
describe("validations", () => {
|
||||
it("should use validators defined in html",
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
var form = new ControlGroup({"login": new Control("aa")});
|
||||
var ctx = MyComp.create({form: form});
|
||||
|
||||
|
@ -345,7 +349,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it("should use validators defined in the model",
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
var form = new ControlGroup({"login": new Control("aa", Validators.required)});
|
||||
var ctx = MyComp.create({form: form});
|
||||
|
||||
|
@ -371,7 +375,7 @@ export function main() {
|
|||
|
||||
describe("nested forms", () => {
|
||||
it("should init DOM with the given form object",
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
var form =
|
||||
new ControlGroup({"nested": new ControlGroup({"login": new Control("value")})});
|
||||
var ctx = MyComp.create({form: form});
|
||||
|
@ -392,7 +396,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it("should update the control group values on DOM change",
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
var form =
|
||||
new ControlGroup({"nested": new ControlGroup({"login": new Control("value")})});
|
||||
var ctx = MyComp.create({form: form});
|
||||
|
@ -468,7 +472,7 @@ export function main() {
|
|||
|
||||
describe("template-driven forms", () => {
|
||||
it("should add new controls and control groups",
|
||||
inject([TestBed], fakeAsync(tb => {
|
||||
inject([TestBed], fakeAsync((tb: TestBed) => {
|
||||
var ctx = MyComp.create({name: null});
|
||||
|
||||
var t = `<form>
|
||||
|
@ -491,7 +495,7 @@ export function main() {
|
|||
})));
|
||||
|
||||
it("should emit ng-submit event on submit",
|
||||
inject([TestBed], fakeAsync(tb => {
|
||||
inject([TestBed], fakeAsync((tb: TestBed) => {
|
||||
var ctx = MyComp.create({name: 'old'});
|
||||
|
||||
var t = `<div><form (ng-submit)="name='updated'"></form></div>`;
|
||||
|
@ -508,7 +512,7 @@ export function main() {
|
|||
})));
|
||||
|
||||
it("should not create a template-driven form when ng-no-form is used",
|
||||
inject([TestBed], fakeAsync(tb => {
|
||||
inject([TestBed], fakeAsync((tb: TestBed) => {
|
||||
var ctx = MyComp.create({name: null});
|
||||
|
||||
var t = `<form ng-no-form>
|
||||
|
@ -522,7 +526,7 @@ export function main() {
|
|||
});
|
||||
})));
|
||||
|
||||
it("should remove controls", inject([TestBed], fakeAsync(tb => {
|
||||
it("should remove controls", inject([TestBed], fakeAsync((tb: TestBed) => {
|
||||
var ctx = MyComp.create({name: 'show'});
|
||||
|
||||
var t = `<form>
|
||||
|
@ -550,7 +554,7 @@ export function main() {
|
|||
})));
|
||||
|
||||
it("should remove control groups",
|
||||
inject([TestBed], fakeAsync(tb => {
|
||||
inject([TestBed], fakeAsync((tb: TestBed) => {
|
||||
var ctx = MyComp.create({name: 'show'});
|
||||
|
||||
|
||||
|
@ -579,7 +583,7 @@ export function main() {
|
|||
})));
|
||||
|
||||
it("should support ng-model for complex forms",
|
||||
inject([TestBed], fakeAsync(tb => {
|
||||
inject([TestBed], fakeAsync((tb: TestBed) => {
|
||||
var ctx = MyComp.create({name: "oldValue"});
|
||||
|
||||
var t = `<form>
|
||||
|
@ -606,7 +610,7 @@ export function main() {
|
|||
|
||||
|
||||
it("should support ng-model for single fields",
|
||||
inject([TestBed], fakeAsync(tb => {
|
||||
inject([TestBed], fakeAsync((tb: TestBed) => {
|
||||
var ctx = MyComp.create({name: "oldValue"});
|
||||
|
||||
var t = `<div><input type="text" [(ng-model)]="name"></div>`;
|
||||
|
@ -632,7 +636,7 @@ export function main() {
|
|||
|
||||
describe("setting status classes", () => {
|
||||
it("should work with single fields",
|
||||
inject([TestBed], fakeAsync(tb => {
|
||||
inject([TestBed], fakeAsync((tb: TestBed) => {
|
||||
var form = new Control("", Validators.required);
|
||||
var ctx = MyComp.create({form: form});
|
||||
|
||||
|
@ -664,7 +668,7 @@ export function main() {
|
|||
})));
|
||||
|
||||
it("should work with complex model-driven forms",
|
||||
inject([TestBed], fakeAsync(tb => {
|
||||
inject([TestBed], fakeAsync((tb: TestBed) => {
|
||||
var form = new ControlGroup({"name": new Control("", Validators.required)});
|
||||
var ctx = MyComp.create({form: form});
|
||||
|
||||
|
@ -697,7 +701,7 @@ export function main() {
|
|||
})));
|
||||
|
||||
it("should work with ng-model",
|
||||
inject([TestBed], fakeAsync(tb => {
|
||||
inject([TestBed], fakeAsync((tb: TestBed) => {
|
||||
var ctx = MyComp.create({name: ""});
|
||||
|
||||
var t = `<div><input [(ng-model)]="name" required></div>`;
|
||||
|
|
|
@ -352,7 +352,7 @@ export function main() {
|
|||
|
||||
describe("ControlArray", () => {
|
||||
describe("adding/removing", () => {
|
||||
var a;
|
||||
var a: ControlArray;
|
||||
var c1, c2, c3;
|
||||
|
||||
beforeEach(() => {
|
||||
|
@ -434,7 +434,8 @@ export function main() {
|
|||
});
|
||||
|
||||
describe("dirty", () => {
|
||||
var c, a;
|
||||
var c: Control;
|
||||
var a: ControlArray;
|
||||
|
||||
beforeEach(() => {
|
||||
c = new Control('value');
|
||||
|
@ -451,7 +452,8 @@ export function main() {
|
|||
});
|
||||
|
||||
describe("valueChanges", () => {
|
||||
var a, c1, c2;
|
||||
var a: ControlArray;
|
||||
var c1, c2;
|
||||
|
||||
beforeEach(() => {
|
||||
c1 = new Control("old1");
|
||||
|
|
|
@ -15,7 +15,7 @@ import {PromiseWrapper} from 'angular2/src/facade/async';
|
|||
|
||||
export function main() {
|
||||
describe('XHRImpl', () => {
|
||||
var xhr;
|
||||
var xhr: XHRImpl;
|
||||
var url200 = '/base/modules/angular2/test/services/static_assets/200.html';
|
||||
var url404 = '/base/modules/angular2/test/services/static_assets/404.html';
|
||||
|
||||
|
@ -33,6 +33,7 @@ export function main() {
|
|||
PromiseWrapper.catchError(xhr.get(url404), (e) => {
|
||||
expect(e).toEqual(`Failed to load ${url404}`);
|
||||
async.done();
|
||||
return null;
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
|
|
@ -16,7 +16,7 @@ import {isPresent} from 'angular2/src/facade/lang';
|
|||
|
||||
export function main() {
|
||||
describe('MockXHR', () => {
|
||||
var xhr;
|
||||
var xhr: MockXHR;
|
||||
|
||||
beforeEach(() => { xhr = new MockXHR(); });
|
||||
|
||||
|
|
|
@ -161,7 +161,7 @@ export class PerflogMetric extends Metric {
|
|||
}
|
||||
}
|
||||
|
||||
_aggregateEvents(events, markName): StringMap<string, any> {
|
||||
_aggregateEvents(events: List<StringMap<string, any>>, markName): StringMap<string, any> {
|
||||
var result = {'scriptTime': 0, 'pureScriptTime': 0};
|
||||
if (this._perfLogFeatures.gc) {
|
||||
result['gcTime'] = 0;
|
||||
|
|
|
@ -51,7 +51,7 @@ export class IOsDriverExtension extends WebDriverExtension {
|
|||
});
|
||||
}
|
||||
|
||||
_convertPerfRecordsToEvents(records, events = null) {
|
||||
_convertPerfRecordsToEvents(records: any[], events = null) {
|
||||
if (isBlank(events)) {
|
||||
events = [];
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ import {Promise, PromiseWrapper} from 'angular2/src/facade/async';
|
|||
|
||||
export function main() {
|
||||
describe('runner', () => {
|
||||
var injector;
|
||||
var injector: Injector;
|
||||
var runner;
|
||||
|
||||
function createRunner(defaultBindings = null) {
|
||||
|
|
|
@ -120,7 +120,7 @@
|
|||
"temp": "^0.8.1",
|
||||
"ternary-stream": "^1.2.3",
|
||||
"through2": "^0.6.1",
|
||||
"ts2dart": "^0.5.9",
|
||||
"ts2dart": "^0.6.0",
|
||||
"tsd": "^0.6.0",
|
||||
"typescript": "alexeagle/TypeScript#error_is_class",
|
||||
"vinyl": "^0.4.6",
|
||||
|
|
|
@ -54,7 +54,11 @@ function getSourceTree() {
|
|||
'angular2/test/http/**/*',
|
||||
'angular2/http.ts'
|
||||
]);
|
||||
var transpiled = ts2dart(tsInputTree, {generateLibraryName: true, generateSourceMap: false});
|
||||
var transpiled = ts2dart(tsInputTree, {
|
||||
generateLibraryName: true,
|
||||
generateSourceMap: false,
|
||||
translateBuiltins: true,
|
||||
});
|
||||
// Native sources, dart only examples, etc.
|
||||
var dartSrcs = modulesFunnel(['**/*.dart', '**/*.ng_meta.json', '**/css/**']);
|
||||
return mergeTrees([transpiled, dartSrcs]);
|
||||
|
|
|
@ -6,6 +6,7 @@ export interface TranspilerOptions {
|
|||
generateLibraryName?: boolean;
|
||||
generateSourceMap?: boolean;
|
||||
basePath?: string;
|
||||
translateBuiltins?: boolean;
|
||||
}
|
||||
|
||||
export class Transpiler {
|
||||
|
|
Loading…
Reference in New Issue