chore: move to clang-format 1.0.17.
clang-format 1.0.17 substantially improves formatting for fat arrow functions and array literal detection. It also fixes a number of minor formatting issues.
This commit is contained in:
@@ -35,7 +35,8 @@ export var routerInjectables: List<any> = [
|
||||
Pipeline,
|
||||
BrowserLocation,
|
||||
Location,
|
||||
bind(Router).toFactory((registry, pipeline, location, appRoot) =>
|
||||
{ return new RootRouter(registry, pipeline, location, appRoot);},
|
||||
[RouteRegistry, Pipeline, Location, appComponentTypeToken])
|
||||
bind(Router)
|
||||
.toFactory((registry, pipeline, location,
|
||||
appRoot) => { return new RootRouter(registry, pipeline, location, appRoot);},
|
||||
[RouteRegistry, Pipeline, Location, appComponentTypeToken])
|
||||
];
|
||||
|
||||
@@ -33,8 +33,8 @@ export var iterableDiff: List<PipeFactory> = [new IterableChangesFactory(), new
|
||||
*
|
||||
* @exportedAs angular2/pipes
|
||||
*/
|
||||
export var async: List<
|
||||
PipeFactory> = [new ObservablePipeFactory(), new PromisePipeFactory(), new NullPipeFactory()];
|
||||
export var async: List<PipeFactory> =
|
||||
[new ObservablePipeFactory(), new PromisePipeFactory(), new NullPipeFactory()];
|
||||
|
||||
/**
|
||||
* Uppercase text transform.
|
||||
|
||||
@@ -45,9 +45,9 @@ function _selfRecord(r: ProtoRecord, contextIndex: number, selfIndex: number): P
|
||||
|
||||
function _findMatching(r: ProtoRecord, rs: List<ProtoRecord>) {
|
||||
return ListWrapper.find(rs, (rr) => rr.mode !== RECORD_TYPE_DIRECTIVE_LIFECYCLE &&
|
||||
rr.mode === r.mode && rr.funcOrValue === r.funcOrValue &&
|
||||
rr.contextIndex === r.contextIndex &&
|
||||
ListWrapper.equals(rr.args, r.args));
|
||||
rr.mode === r.mode && rr.funcOrValue === r.funcOrValue &&
|
||||
rr.contextIndex === r.contextIndex &&
|
||||
ListWrapper.equals(rr.args, r.args));
|
||||
}
|
||||
|
||||
function _replaceIndices(r: ProtoRecord, selfIndex: number, indexMap: Map<any, any>) {
|
||||
|
||||
@@ -71,21 +71,21 @@ function _injectorBindings(appComponentType): List<Type | Binding | List<any>> {
|
||||
.toValue(DOM.defaultDoc()),
|
||||
bind(appComponentTypeToken).toValue(appComponentType),
|
||||
bind(appComponentRefToken)
|
||||
.toAsyncFactory((dynamicComponentLoader, injector, testability, registry) =>
|
||||
{
|
||||
.toAsyncFactory(
|
||||
(dynamicComponentLoader, injector, testability, registry) => {
|
||||
|
||||
// TODO(rado): investigate whether to support bindings on root component.
|
||||
return dynamicComponentLoader.loadAsRoot(appComponentType, null, injector)
|
||||
.then((componentRef) => {
|
||||
var domView = resolveInternalDomView(componentRef.hostView.render);
|
||||
// We need to do this here to ensure that we create Testability and
|
||||
// it's ready on the window for users.
|
||||
registry.registerApplication(domView.boundElements[0], testability);
|
||||
// TODO(rado): investigate whether to support bindings on root component.
|
||||
return dynamicComponentLoader.loadAsRoot(appComponentType, null, injector)
|
||||
.then((componentRef) => {
|
||||
var domView = resolveInternalDomView(componentRef.hostView.render);
|
||||
// We need to do this here to ensure that we create Testability and
|
||||
// it's ready on the window for users.
|
||||
registry.registerApplication(domView.boundElements[0], testability);
|
||||
|
||||
return componentRef;
|
||||
});
|
||||
},
|
||||
[DynamicComponentLoader, Injector, Testability, TestabilityRegistry]),
|
||||
return componentRef;
|
||||
});
|
||||
},
|
||||
[DynamicComponentLoader, Injector, Testability, TestabilityRegistry]),
|
||||
|
||||
bind(appComponentType).toFactory((ref) => ref.instance, [appComponentRefToken]),
|
||||
bind(LifeCycle)
|
||||
@@ -93,8 +93,7 @@ function _injectorBindings(appComponentType): List<Type | Binding | List<any>> {
|
||||
[ExceptionHandler]),
|
||||
bind(EventManager)
|
||||
.toFactory(
|
||||
(ngZone) =>
|
||||
{
|
||||
(ngZone) => {
|
||||
var plugins =
|
||||
[new HammerGesturesPlugin(), new KeyEventsPlugin(), new DomEventsPlugin()];
|
||||
return new EventManager(plugins, ngZone);
|
||||
@@ -102,7 +101,7 @@ function _injectorBindings(appComponentType): List<Type | Binding | List<any>> {
|
||||
[NgZone]),
|
||||
bind(ShadowDomStrategy)
|
||||
.toFactory((styleUrlResolver, doc) =>
|
||||
new EmulatedUnscopedShadowDomStrategy(styleUrlResolver, doc.head),
|
||||
new EmulatedUnscopedShadowDomStrategy(styleUrlResolver, doc.head),
|
||||
[StyleUrlResolver, DOCUMENT_TOKEN]),
|
||||
DomRenderer,
|
||||
DefaultDomCompiler,
|
||||
@@ -293,8 +292,7 @@ export function bootstrap(appComponentType: Type,
|
||||
|
||||
PromiseWrapper.then(
|
||||
appInjector.asyncGet(appComponentRefToken),
|
||||
(componentRef) =>
|
||||
{
|
||||
(componentRef) => {
|
||||
var appChangeDetector = internalView(componentRef.hostView).changeDetector;
|
||||
// retrieve life cycle: may have already been created if injected in root component
|
||||
var lc = appInjector.get(LifeCycle);
|
||||
|
||||
@@ -94,11 +94,9 @@ export class Compiler {
|
||||
|
||||
var directiveMetadata = componentBinding.metadata;
|
||||
return this._render.compileHost(directiveMetadata)
|
||||
.then((hostRenderPv) =>
|
||||
{
|
||||
return this._compileNestedProtoViews(componentBinding, hostRenderPv,
|
||||
[componentBinding]);
|
||||
})
|
||||
.then((hostRenderPv) => {
|
||||
return this._compileNestedProtoViews(componentBinding, hostRenderPv, [componentBinding]);
|
||||
})
|
||||
.then((appProtoView) => { return new ProtoViewRef(appProtoView); });
|
||||
}
|
||||
|
||||
|
||||
@@ -239,7 +239,7 @@ export class Parse5DomAdapter extends DomAdapter {
|
||||
createTextNode(text: string) { throw _notImplemented('createTextNode'); }
|
||||
createScriptTag(attrName: string, attrValue: string) {
|
||||
return treeAdapter.createElement("script", 'http://www.w3.org/1999/xhtml',
|
||||
[{name: attrName, value: attrValue}]);
|
||||
[{name: attrName, value: attrValue}]);
|
||||
}
|
||||
createStyleElement(css: string) {
|
||||
var style = this.createElement('style');
|
||||
|
||||
@@ -86,7 +86,7 @@ function _getAppBindings() {
|
||||
.toValue(appDoc),
|
||||
bind(ShadowDomStrategy)
|
||||
.toFactory((styleUrlResolver, doc) =>
|
||||
new EmulatedUnscopedShadowDomStrategy(styleUrlResolver, doc.head),
|
||||
new EmulatedUnscopedShadowDomStrategy(styleUrlResolver, doc.head),
|
||||
[StyleUrlResolver, DOCUMENT_TOKEN]),
|
||||
DomRenderer,
|
||||
DefaultDomCompiler,
|
||||
@@ -118,14 +118,14 @@ function _getAppBindings() {
|
||||
TestComponentBuilder,
|
||||
bind(NgZone).toClass(MockNgZone),
|
||||
bind(EventManager)
|
||||
.toFactory((zone) =>
|
||||
{
|
||||
var plugins = [
|
||||
new DomEventsPlugin(),
|
||||
];
|
||||
return new EventManager(plugins, zone);
|
||||
},
|
||||
[NgZone]),
|
||||
.toFactory(
|
||||
(zone) => {
|
||||
var plugins = [
|
||||
new DomEventsPlugin(),
|
||||
];
|
||||
return new EventManager(plugins, zone);
|
||||
},
|
||||
[NgZone]),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -334,11 +334,10 @@ export class SpyObject {
|
||||
}
|
||||
|
||||
function elementText(n) {
|
||||
var hasNodes = (n) =>
|
||||
{
|
||||
var hasNodes = (n) => {
|
||||
var children = DOM.childNodes(n);
|
||||
return children && children.length > 0;
|
||||
}
|
||||
};
|
||||
|
||||
if (n instanceof Array) {
|
||||
return n.map((nn) => elementText(nn)).join("");
|
||||
|
||||
@@ -239,22 +239,22 @@ export function main() {
|
||||
{
|
||||
"dynamic": (bindingRecords, variableBindings = null, directiveRecords = null,
|
||||
registry = null, strategy = null) =>
|
||||
new DynamicProtoChangeDetector(
|
||||
registry,
|
||||
new ChangeDetectorDefinition(
|
||||
null, strategy, isBlank(variableBindings) ? [] : variableBindings,
|
||||
isBlank(bindingRecords) ? [] : bindingRecords,
|
||||
isBlank(directiveRecords) ? [] : directiveRecords)),
|
||||
new DynamicProtoChangeDetector(
|
||||
registry, new ChangeDetectorDefinition(
|
||||
null, strategy,
|
||||
isBlank(variableBindings) ? [] : variableBindings,
|
||||
isBlank(bindingRecords) ? [] : bindingRecords,
|
||||
isBlank(directiveRecords) ? [] : directiveRecords)),
|
||||
|
||||
"JIT":
|
||||
(bindingRecords, variableBindings = null, directiveRecords = null, registry = null,
|
||||
strategy = null) =>
|
||||
new JitProtoChangeDetector(
|
||||
registry, new ChangeDetectorDefinition(
|
||||
null, strategy, isBlank(variableBindings) ? [] :
|
||||
variableBindings,
|
||||
isBlank(bindingRecords) ? [] : bindingRecords,
|
||||
isBlank(directiveRecords) ? [] : directiveRecords))
|
||||
"JIT": (bindingRecords, variableBindings = null, directiveRecords = null, registry = null,
|
||||
strategy = null) =>
|
||||
new JitProtoChangeDetector(
|
||||
registry, new ChangeDetectorDefinition(
|
||||
null,
|
||||
strategy, isBlank(variableBindings) ? [] :
|
||||
variableBindings,
|
||||
isBlank(bindingRecords) ? [] : bindingRecords,
|
||||
isBlank(directiveRecords) ? [] : directiveRecords))
|
||||
|
||||
},
|
||||
(createProtoChangeDetector, name) => {
|
||||
|
||||
@@ -19,12 +19,8 @@ export function main() {
|
||||
it("should remove non-terminal duplicate records" +
|
||||
" and update the context indices referencing them",
|
||||
() => {
|
||||
var rs = coalesce([
|
||||
r("user", [], 0, 1),
|
||||
r("first", [], 1, 2),
|
||||
r("user", [], 0, 3),
|
||||
r("last", [], 3, 4)
|
||||
]);
|
||||
var rs = coalesce(
|
||||
[r("user", [], 0, 1), r("first", [], 1, 2), r("user", [], 0, 3), r("last", [], 3, 4)]);
|
||||
|
||||
expect(rs).toEqual([r("user", [], 0, 1), r("first", [], 1, 2), r("last", [], 1, 3)]);
|
||||
});
|
||||
|
||||
@@ -456,14 +456,14 @@ export function main() {
|
||||
|
||||
function exprSources(templateBindings) {
|
||||
return ListWrapper.map(templateBindings, (binding) => isPresent(binding.expression) ?
|
||||
binding.expression.source :
|
||||
null);
|
||||
binding.expression.source :
|
||||
null);
|
||||
}
|
||||
|
||||
function exprAsts(templateBindings) {
|
||||
return ListWrapper.map(templateBindings, (binding) => isPresent(binding.expression) ?
|
||||
binding.expression :
|
||||
null);
|
||||
binding.expression :
|
||||
null);
|
||||
}
|
||||
|
||||
it('should parse an empty string', () => {
|
||||
|
||||
@@ -58,14 +58,12 @@ export function main() {
|
||||
MapWrapper.set(m, 1, 20);
|
||||
changes.check(m);
|
||||
|
||||
changes.forEachChangedItem((record) =>
|
||||
{
|
||||
previous = record.previousValue;
|
||||
current = record.currentValue;
|
||||
})
|
||||
changes.forEachChangedItem((record) => {
|
||||
previous = record.previousValue;
|
||||
current = record.currentValue;
|
||||
});
|
||||
|
||||
expect(previous)
|
||||
.toEqual(10);
|
||||
expect(previous).toEqual(10);
|
||||
expect(current).toEqual(20);
|
||||
});
|
||||
|
||||
@@ -97,11 +95,8 @@ export function main() {
|
||||
MapWrapper.delete(m, 'b');
|
||||
changes.check(m);
|
||||
expect(changes.toString())
|
||||
.toEqual(kvChangesAsString({
|
||||
map: ['a', 'd'],
|
||||
previous: ['a', 'b[BB->null]', 'd'],
|
||||
removals: ['b[BB->null]']
|
||||
}));
|
||||
.toEqual(kvChangesAsString(
|
||||
{map: ['a', 'd'], previous: ['a', 'b[BB->null]', 'd'], removals: ['b[BB->null]']}));
|
||||
|
||||
MapWrapper.clear(m);
|
||||
changes.check(m);
|
||||
|
||||
@@ -77,8 +77,7 @@ export function main() {
|
||||
}
|
||||
|
||||
function captureDirective(directive): Promise<renderApi.DirectiveMetadata> {
|
||||
return captureTemplate(
|
||||
new viewAnn.View({template: '<div></div>', directives: [directive]}))
|
||||
return captureTemplate(new viewAnn.View({template: '<div></div>', directives: [directive]}))
|
||||
.then((renderTpl) => {
|
||||
expect(renderTpl.directives.length).toBe(1);
|
||||
return renderTpl.directives[0];
|
||||
@@ -315,9 +314,11 @@ export function main() {
|
||||
createProtoView([createComponentElementBinder(directiveResolver, NestedComponent)]);
|
||||
var nestedProtoView = createProtoView();
|
||||
var compiler = createCompiler([
|
||||
createRenderProtoView([createRenderViewportElementBinder(
|
||||
createRenderProtoView([createRenderComponentElementBinder(0)],
|
||||
renderApi.ProtoViewDto.EMBEDDED_VIEW_TYPE))]),
|
||||
createRenderProtoView([
|
||||
createRenderViewportElementBinder(
|
||||
createRenderProtoView([createRenderComponentElementBinder(0)],
|
||||
renderApi.ProtoViewDto.EMBEDDED_VIEW_TYPE))
|
||||
]),
|
||||
createRenderProtoView()
|
||||
],
|
||||
[[mainProtoView, viewportProtoView], [nestedProtoView]]);
|
||||
@@ -336,11 +337,10 @@ export function main() {
|
||||
var expectedProtoView = createProtoView();
|
||||
var compiler = createCompiler([renderProtoView], [[expectedProtoView]]);
|
||||
compiler.compile(MainComponent)
|
||||
.then((protoViewRef) =>
|
||||
{
|
||||
expect(internalProtoView(protoViewRef)).toBe(expectedProtoView);
|
||||
return compiler.compile(MainComponent);
|
||||
})
|
||||
.then((protoViewRef) => {
|
||||
expect(internalProtoView(protoViewRef)).toBe(expectedProtoView);
|
||||
return compiler.compile(MainComponent);
|
||||
})
|
||||
.then((protoViewRef) => {
|
||||
expect(internalProtoView(protoViewRef)).toBe(expectedProtoView);
|
||||
async.done();
|
||||
|
||||
@@ -76,31 +76,27 @@ export function main() {
|
||||
view.context.ctxBoolProp = true;
|
||||
view.detectChanges();
|
||||
var dynamicComponent = view.rawView.viewContainers[0].views[0].locals.get("dynamic");
|
||||
dynamicComponent.done.then((_) =>
|
||||
{
|
||||
view.detectChanges();
|
||||
expect(view.rootNodes).toHaveText('hello');
|
||||
var promise = dynamicComponent.done.then((_) => {
|
||||
view.detectChanges();
|
||||
expect(view.rootNodes).toHaveText('hello');
|
||||
|
||||
view.context.ctxBoolProp = false;
|
||||
view.detectChanges();
|
||||
view.context.ctxBoolProp = false;
|
||||
view.detectChanges();
|
||||
|
||||
expect(view.rawView.viewContainers[0].views.length)
|
||||
.toBe(0);
|
||||
expect(view.rootNodes).toHaveText('');
|
||||
expect(view.rawView.viewContainers[0].views.length).toBe(0);
|
||||
expect(view.rootNodes).toHaveText('');
|
||||
|
||||
view.context.ctxBoolProp = true;
|
||||
view.detectChanges();
|
||||
view.context.ctxBoolProp = true;
|
||||
view.detectChanges();
|
||||
|
||||
var dynamicComponent =
|
||||
view.rawView.viewContainers[0].views[0].locals.get(
|
||||
"dynamic");
|
||||
return dynamicComponent.done;
|
||||
})
|
||||
.then((_) => {
|
||||
view.detectChanges();
|
||||
expect(view.rootNodes).toHaveText('hello');
|
||||
async.done();
|
||||
});
|
||||
var dynamicComponent = view.rawView.viewContainers[0].views[0].locals.get("dynamic");
|
||||
return dynamicComponent.done;
|
||||
});
|
||||
promise.then((_) => {
|
||||
view.detectChanges();
|
||||
expect(view.rootNodes).toHaveText('hello');
|
||||
async.done();
|
||||
});
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
@@ -112,8 +112,8 @@ export function main() {
|
||||
|
||||
it('should consume binding to aria-* attributes',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
tb.overrideView(
|
||||
MyComp, new viewAnn.View({template: '<div [attr.aria-label]="ctxProp"></div>'}));
|
||||
tb.overrideView(MyComp,
|
||||
new viewAnn.View({template: '<div [attr.aria-label]="ctxProp"></div>'}));
|
||||
|
||||
tb.createView(MyComp, {context: ctx})
|
||||
.then((view) => {
|
||||
@@ -234,10 +234,12 @@ export function main() {
|
||||
|
||||
describe('pipes', () => {
|
||||
beforeEachBindings(() => {
|
||||
return [bind(ChangeDetection)
|
||||
.toFactory(() => new DynamicChangeDetection(
|
||||
new PipeRegistry({"double": [new DoublePipeFactory()]})),
|
||||
[])];
|
||||
return [
|
||||
bind(ChangeDetection)
|
||||
.toFactory(() => new DynamicChangeDetection(
|
||||
new PipeRegistry({"double": [new DoublePipeFactory()]})),
|
||||
[])
|
||||
];
|
||||
});
|
||||
|
||||
it("should support pipes in bindings and bind config",
|
||||
@@ -312,8 +314,8 @@ export function main() {
|
||||
|
||||
it('should support directives where a selector matches property binding',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
tb.overrideView(MyComp, new viewAnn.View(
|
||||
{template: '<p [id]="ctxProp"></p>', directives: [IdDir]}));
|
||||
tb.overrideView(
|
||||
MyComp, new viewAnn.View({template: '<p [id]="ctxProp"></p>', directives: [IdDir]}));
|
||||
|
||||
tb.createView(MyComp, {context: ctx})
|
||||
.then((view) => {
|
||||
@@ -1007,11 +1009,8 @@ export function main() {
|
||||
</parent-providing-event-bus>
|
||||
</grand-parent-providing-event-bus>
|
||||
`,
|
||||
directives: [
|
||||
GrandParentProvidingEventBus,
|
||||
ParentProvidingEventBus,
|
||||
ChildConsumingEventBus
|
||||
]
|
||||
directives:
|
||||
[GrandParentProvidingEventBus, ParentProvidingEventBus, ChildConsumingEventBus]
|
||||
}));
|
||||
tb.createView(MyComp, {context: ctx})
|
||||
.then((view) => {
|
||||
@@ -1161,8 +1160,7 @@ export function main() {
|
||||
tb.overrideView(MyComp, new viewAnn.View({template: inlineTpl}));
|
||||
PromiseWrapper.then(
|
||||
tb.createView(MyComp),
|
||||
(value) =>
|
||||
{
|
||||
(value) => {
|
||||
throw new BaseException(
|
||||
"Test failure: should not have come here as an exception was expected");
|
||||
},
|
||||
@@ -1638,11 +1636,15 @@ function createParentBusView(p) {
|
||||
}
|
||||
@Component({
|
||||
selector: 'parent-providing-event-bus',
|
||||
hostInjector: [new Binding(
|
||||
EventBus, {toFactory: createParentBusHost, deps: [[EventBus, new visAnn.Unbounded()]]})],
|
||||
viewInjector: [new Binding(
|
||||
EventBus,
|
||||
{toFactory: createParentBusView, deps: [[FORWARD_REF(() => ParentProvidingEventBus)]]})]
|
||||
hostInjector: [
|
||||
new Binding(EventBus,
|
||||
{toFactory: createParentBusHost, deps: [[EventBus, new visAnn.Unbounded()]]})
|
||||
],
|
||||
viewInjector: [
|
||||
new Binding(
|
||||
EventBus,
|
||||
{toFactory: createParentBusView, deps: [[FORWARD_REF(() => ParentProvidingEventBus)]]})
|
||||
]
|
||||
})
|
||||
@View({
|
||||
directives: [FORWARD_REF(() => ChildConsumingEventBus)],
|
||||
|
||||
@@ -48,8 +48,7 @@ export function main() {
|
||||
}
|
||||
|
||||
|
||||
@Directive(
|
||||
{selector: "[lifecycle]", properties: ['field'], lifecycle: [onChange, onCheck, onInit]})
|
||||
@Directive({selector: "[lifecycle]", properties: ['field'], lifecycle: [onChange, onCheck, onInit]})
|
||||
class LifecycleDir {
|
||||
field;
|
||||
log: List<string>;
|
||||
|
||||
@@ -290,18 +290,17 @@ function commonTests() {
|
||||
var ran = false;
|
||||
_zone.initCallbacks({
|
||||
onTurnStart: _log.fn('onTurnStart'),
|
||||
onTurnDone: () =>
|
||||
{
|
||||
_log.add('onTurnDone(begin)');
|
||||
if (!ran) {
|
||||
microTask(() => {
|
||||
ran = true;
|
||||
_log.add('executedMicrotask');
|
||||
});
|
||||
}
|
||||
onTurnDone: () => {
|
||||
_log.add('onTurnDone(begin)');
|
||||
if (!ran) {
|
||||
microTask(() => {
|
||||
ran = true;
|
||||
_log.add('executedMicrotask');
|
||||
});
|
||||
}
|
||||
|
||||
_log.add('onTurnDone(end)');
|
||||
}
|
||||
_log.add('onTurnDone(end)');
|
||||
}
|
||||
});
|
||||
|
||||
macroTask(() => { _zone.run(_log.fn('run')); });
|
||||
@@ -323,18 +322,17 @@ function commonTests() {
|
||||
var ran = false;
|
||||
_zone.initCallbacks({
|
||||
onTurnStart: _log.fn('onTurnStart'),
|
||||
onTurnDone: () =>
|
||||
{
|
||||
_log.add('onTurnDone(begin)');
|
||||
if (!ran) {
|
||||
_log.add('onTurnDone(scheduleMicrotask)');
|
||||
microTask(() => {
|
||||
ran = true;
|
||||
_log.add('onTurnDone(executeMicrotask)');
|
||||
});
|
||||
}
|
||||
_log.add('onTurnDone(end)');
|
||||
}
|
||||
onTurnDone: () => {
|
||||
_log.add('onTurnDone(begin)');
|
||||
if (!ran) {
|
||||
_log.add('onTurnDone(scheduleMicrotask)');
|
||||
microTask(() => {
|
||||
ran = true;
|
||||
_log.add('onTurnDone(executeMicrotask)');
|
||||
});
|
||||
}
|
||||
_log.add('onTurnDone(end)');
|
||||
}
|
||||
});
|
||||
|
||||
macroTask(() => {
|
||||
@@ -361,37 +359,36 @@ function commonTests() {
|
||||
var startPromiseRan = false;
|
||||
|
||||
_zone.initCallbacks({
|
||||
onTurnStart: () =>
|
||||
{
|
||||
_log.add('onTurnStart(begin)');
|
||||
if (!startPromiseRan) {
|
||||
_log.add('onTurnStart(schedulePromise)');
|
||||
microTask(_log.fn('onTurnStart(executePromise)'));
|
||||
startPromiseRan = true;
|
||||
}
|
||||
_log.add('onTurnStart(end)');
|
||||
},
|
||||
onTurnDone: () =>
|
||||
{
|
||||
_log.add('onTurnDone(begin)');
|
||||
if (!donePromiseRan) {
|
||||
_log.add('onTurnDone(schedulePromise)');
|
||||
microTask(_log.fn('onTurnDone(executePromise)'));
|
||||
donePromiseRan = true;
|
||||
}
|
||||
_log.add('onTurnDone(end)');
|
||||
}
|
||||
onTurnStart: () => {
|
||||
_log.add('onTurnStart(begin)');
|
||||
if (!startPromiseRan) {
|
||||
_log.add('onTurnStart(schedulePromise)');
|
||||
microTask(_log.fn('onTurnStart(executePromise)'));
|
||||
startPromiseRan = true;
|
||||
}
|
||||
_log.add('onTurnStart(end)');
|
||||
},
|
||||
onTurnDone: () => {
|
||||
_log.add('onTurnDone(begin)');
|
||||
if (!donePromiseRan) {
|
||||
_log.add('onTurnDone(schedulePromise)');
|
||||
microTask(_log.fn('onTurnDone(executePromise)'));
|
||||
donePromiseRan = true;
|
||||
}
|
||||
_log.add('onTurnDone(end)');
|
||||
}
|
||||
});
|
||||
|
||||
macroTask(() => {
|
||||
_zone.run(() => {
|
||||
_log.add('run start');
|
||||
PromiseWrapper.resolve(null).then((_) => {
|
||||
_log.add('promise then');
|
||||
PromiseWrapper.resolve(null)
|
||||
.then(_log.fn('promise foo'));
|
||||
return PromiseWrapper.resolve(null);
|
||||
}).then(_log.fn('promise bar'));
|
||||
PromiseWrapper.resolve(null)
|
||||
.then((_) => {
|
||||
_log.add('promise then');
|
||||
PromiseWrapper.resolve(null).then(_log.fn('promise foo'));
|
||||
return PromiseWrapper.resolve(null);
|
||||
})
|
||||
.then(_log.fn('promise bar'));
|
||||
_log.add('run end');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -68,9 +68,8 @@ export function main() {
|
||||
it('should return a promise when instantiating a sync binding ' +
|
||||
'with an async dependency',
|
||||
inject([AsyncTestCompleter], (async) => {
|
||||
var injector =
|
||||
Injector
|
||||
.resolveAndCreate([bind(UserList).toAsyncFactory(fetchUsers), UserController]);
|
||||
var injector = Injector.resolveAndCreate(
|
||||
[bind(UserList).toAsyncFactory(fetchUsers), UserController]);
|
||||
|
||||
injector.asyncGet(UserController)
|
||||
.then(function(userController) {
|
||||
@@ -145,9 +144,8 @@ export function main() {
|
||||
|
||||
it('should not throw when instantiating a sync binding with a resolved async dependency',
|
||||
inject([AsyncTestCompleter], (async) => {
|
||||
var injector =
|
||||
Injector
|
||||
.resolveAndCreate([bind(UserList).toAsyncFactory(fetchUsers), UserController]);
|
||||
var injector = Injector.resolveAndCreate(
|
||||
[bind(UserList).toAsyncFactory(fetchUsers), UserController]);
|
||||
|
||||
injector.asyncGet(UserList).then((_) => {
|
||||
expect(() => { injector.get(UserController); }).not.toThrow();
|
||||
|
||||
@@ -167,9 +167,8 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should support overriding factory dependencies', () => {
|
||||
var injector =
|
||||
Injector
|
||||
.resolveAndCreate([Engine, bind(Car).toFactory((e) => new SportsCar(e), [Engine])]);
|
||||
var injector = Injector.resolveAndCreate(
|
||||
[Engine, bind(Car).toFactory((e) => new SportsCar(e), [Engine])]);
|
||||
|
||||
var car = injector.get(Car);
|
||||
expect(car).toBeAnInstanceOf(SportsCar);
|
||||
@@ -191,9 +190,8 @@ export function main() {
|
||||
});
|
||||
|
||||
it("should use the last binding when there are multiple bindings for same token", () => {
|
||||
var injector =
|
||||
Injector
|
||||
.resolveAndCreate([bind(Engine).toClass(Engine), bind(Engine).toClass(TurboEngine)]);
|
||||
var injector = Injector.resolveAndCreate(
|
||||
[bind(Engine).toClass(Engine), bind(Engine).toClass(TurboEngine)]);
|
||||
|
||||
expect(injector.get(Engine)).toBeAnInstanceOf(TurboEngine);
|
||||
});
|
||||
@@ -278,7 +276,7 @@ export function main() {
|
||||
|
||||
describe("default bindings", () => {
|
||||
it("should be used when no matching binding found", () => {
|
||||
var injector = Injector.resolveAndCreate([], { defaultBindings: true });
|
||||
var injector = Injector.resolveAndCreate([], {defaultBindings: true});
|
||||
|
||||
var car = injector.get(Car);
|
||||
|
||||
@@ -327,7 +325,7 @@ export function main() {
|
||||
});
|
||||
|
||||
it("should create child injectors without default bindings", () => {
|
||||
var parent = Injector.resolveAndCreate([], { defaultBindings: true });
|
||||
var parent = Injector.resolveAndCreate([], {defaultBindings: true});
|
||||
var child = parent.resolveAndCreateChild([]);
|
||||
|
||||
// child delegates to parent the creation of Car
|
||||
@@ -393,10 +391,11 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should support overriding factory dependencies with dependency annotations', () => {
|
||||
var bindings = Injector.resolve(
|
||||
[bind("token")
|
||||
.toFactory((e) => "result",
|
||||
[[new ann.Inject("dep"), new CustomDependencyAnnotation()]])]);
|
||||
var bindings = Injector.resolve([
|
||||
bind("token")
|
||||
.toFactory((e) => "result",
|
||||
[[new ann.Inject("dep"), new CustomDependencyAnnotation()]])
|
||||
]);
|
||||
var binding = bindings[Key.get("token").id];
|
||||
|
||||
expect(binding.dependencies[0].key.token).toEqual("dep");
|
||||
|
||||
@@ -139,10 +139,8 @@ export function main() {
|
||||
});
|
||||
|
||||
it("should support nested groups", () => {
|
||||
var g = new ControlGroup({
|
||||
"one": new Control("111"),
|
||||
"nested": new ControlGroup({"two": new Control("222")})
|
||||
});
|
||||
var g = new ControlGroup(
|
||||
{"one": new Control("111"), "nested": new ControlGroup({"two": new Control("222")})});
|
||||
expect(g.value).toEqual({"one": "111", "nested": {"two": "222"}});
|
||||
|
||||
g.controls["nested"].controls["two"].updateValue("333");
|
||||
@@ -154,10 +152,8 @@ export function main() {
|
||||
describe("find", () => {
|
||||
var g;
|
||||
beforeEach(() => {
|
||||
g = new ControlGroup({
|
||||
"one": new Control("111"),
|
||||
"nested": new ControlGroup({"two": new Control("222")})
|
||||
});
|
||||
g = new ControlGroup(
|
||||
{"one": new Control("111"), "nested": new ControlGroup({"two": new Control("222")})});
|
||||
});
|
||||
|
||||
it("should return a control if it is present", () => {
|
||||
|
||||
@@ -42,11 +42,9 @@ export function main() {
|
||||
|
||||
it('should not allow overriding a template after it has been resolved', () => {
|
||||
resolver.resolve(SomeComponent);
|
||||
expect(() =>
|
||||
{
|
||||
resolver.setView(SomeComponent,
|
||||
new viewImpl.View({template: 'overridden template'}));
|
||||
})
|
||||
expect(() => {
|
||||
resolver.setView(SomeComponent, new viewImpl.View({template: 'overridden template'}));
|
||||
})
|
||||
.toThrowError(
|
||||
`The component ${stringify(SomeComponent)} has already been compiled, its configuration can not be changed`);
|
||||
});
|
||||
@@ -101,9 +99,9 @@ export function main() {
|
||||
|
||||
it('should not allow overriding a directive after its template has been resolved', () => {
|
||||
resolver.resolve(SomeComponent);
|
||||
expect(
|
||||
() =>
|
||||
{ resolver.overrideViewDirective(SomeComponent, SomeDirective, SomeOtherDirective); })
|
||||
expect(() => {
|
||||
resolver.overrideViewDirective(SomeComponent, SomeDirective, SomeOtherDirective);
|
||||
})
|
||||
.toThrowError(
|
||||
`The component ${stringify(SomeComponent)} has already been compiled, its configuration can not be changed`);
|
||||
});
|
||||
|
||||
@@ -36,14 +36,13 @@ export function main() {
|
||||
if (isBlank(directives)) directives = annotatedDirectives;
|
||||
|
||||
return new CompilePipeline([
|
||||
new MockStep((parent, current, control) =>
|
||||
{
|
||||
if (isPresent(propertyBindings)) {
|
||||
StringMapWrapper.forEach(propertyBindings, (ast, name) => {
|
||||
current.bindElement().bindProperty(name, ast);
|
||||
});
|
||||
}
|
||||
}),
|
||||
new MockStep((parent, current, control) => {
|
||||
if (isPresent(propertyBindings)) {
|
||||
StringMapWrapper.forEach(propertyBindings, (ast, name) => {
|
||||
current.bindElement().bindProperty(name, ast);
|
||||
});
|
||||
}
|
||||
}),
|
||||
new DirectiveParser(parser, directives)
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -39,12 +39,14 @@ export function main() {
|
||||
|
||||
it('should inherit protoViewBuilders to children', () => {
|
||||
var element = el('<div><div><span viewroot><span></span></span></div></div>');
|
||||
var pipeline = new CompilePipeline([new MockStep((parent, current, control) => {
|
||||
if (isPresent(DOM.getAttribute(current.element, 'viewroot'))) {
|
||||
current.inheritedProtoView =
|
||||
new ProtoViewBuilder(current.element, ProtoViewDto.EMBEDDED_VIEW_TYPE);
|
||||
}
|
||||
})]);
|
||||
var pipeline = new CompilePipeline([
|
||||
new MockStep((parent, current, control) => {
|
||||
if (isPresent(DOM.getAttribute(current.element, 'viewroot'))) {
|
||||
current.inheritedProtoView =
|
||||
new ProtoViewBuilder(current.element, ProtoViewDto.EMBEDDED_VIEW_TYPE);
|
||||
}
|
||||
})
|
||||
]);
|
||||
var results = pipeline.process(element);
|
||||
expect(results[0].inheritedProtoView).toBe(results[1].inheritedProtoView);
|
||||
expect(results[2].inheritedProtoView).toBe(results[3].inheritedProtoView);
|
||||
@@ -52,11 +54,13 @@ export function main() {
|
||||
|
||||
it('should inherit elementBinderBuilders to children', () => {
|
||||
var element = el('<div bind><div><span bind><span></span></span></div></div>');
|
||||
var pipeline = new CompilePipeline([new MockStep((parent, current, control) => {
|
||||
if (isPresent(DOM.getAttribute(current.element, 'bind'))) {
|
||||
current.bindElement();
|
||||
}
|
||||
})]);
|
||||
var pipeline = new CompilePipeline([
|
||||
new MockStep((parent, current, control) => {
|
||||
if (isPresent(DOM.getAttribute(current.element, 'bind'))) {
|
||||
current.bindElement();
|
||||
}
|
||||
})
|
||||
]);
|
||||
var results = pipeline.process(element);
|
||||
expect(results[0].inheritedElementBinder).toBe(results[1].inheritedElementBinder);
|
||||
expect(results[2].inheritedElementBinder).toBe(results[3].inheritedElementBinder);
|
||||
@@ -70,11 +74,13 @@ export function main() {
|
||||
|
||||
it('should calculate distanceToParent / parent correctly', () => {
|
||||
var element = el('<div bind><div bind></div><div><div bind></div></div></div>');
|
||||
var pipeline = new CompilePipeline([new MockStep((parent, current, control) => {
|
||||
if (isPresent(DOM.getAttribute(current.element, 'bind'))) {
|
||||
current.bindElement();
|
||||
}
|
||||
})]);
|
||||
var pipeline = new CompilePipeline([
|
||||
new MockStep((parent, current, control) => {
|
||||
if (isPresent(DOM.getAttribute(current.element, 'bind'))) {
|
||||
current.bindElement();
|
||||
}
|
||||
})
|
||||
]);
|
||||
var results = pipeline.process(element);
|
||||
expect(results[0].inheritedElementBinder.distanceToParent).toBe(0);
|
||||
expect(results[1].inheritedElementBinder.distanceToParent).toBe(1);
|
||||
@@ -101,8 +107,8 @@ export function main() {
|
||||
var element = el('<div id="1"><span wrap0="1" id="2"><b id="3"></b></span></div>');
|
||||
var step0Log = [];
|
||||
var step1Log = [];
|
||||
var pipeline = new CompilePipeline(
|
||||
[createWrapperStep('wrap0', step0Log), createLoggerStep(step1Log)]);
|
||||
var pipeline =
|
||||
new CompilePipeline([createWrapperStep('wrap0', step0Log), createLoggerStep(step1Log)]);
|
||||
var result = pipeline.process(element);
|
||||
expect(step0Log).toEqual(['1', '1<2', '2<3']);
|
||||
expect(step1Log).toEqual(['1', '1<wrap0#0', 'wrap0#0<2', '2<3']);
|
||||
@@ -149,8 +155,8 @@ export function main() {
|
||||
var element = el('<div id="1"><span wrap0="2" id="2"><b id="3"></b></span></div>');
|
||||
var step0Log = [];
|
||||
var step1Log = [];
|
||||
var pipeline = new CompilePipeline(
|
||||
[createWrapperStep('wrap0', step0Log), createLoggerStep(step1Log)]);
|
||||
var pipeline =
|
||||
new CompilePipeline([createWrapperStep('wrap0', step0Log), createLoggerStep(step1Log)]);
|
||||
var result = pipeline.process(element);
|
||||
expect(step0Log).toEqual(['1', '1<2', '2<3']);
|
||||
expect(step1Log).toEqual(['1', '1<wrap0#0', 'wrap0#0<wrap0#1', 'wrap0#1<2', '2<3']);
|
||||
@@ -165,12 +171,11 @@ export function main() {
|
||||
var resultLog = [];
|
||||
var newChild = new CompileElement(el('<div id="3"></div>'));
|
||||
var pipeline = new CompilePipeline([
|
||||
new MockStep((parent, current, control) =>
|
||||
{
|
||||
if (StringWrapper.equals(DOM.getAttribute(current.element, 'id'), '1')) {
|
||||
control.addChild(newChild);
|
||||
}
|
||||
}),
|
||||
new MockStep((parent, current, control) => {
|
||||
if (StringWrapper.equals(DOM.getAttribute(current.element, 'id'), '1')) {
|
||||
control.addChild(newChild);
|
||||
}
|
||||
}),
|
||||
createLoggerStep(resultLog)
|
||||
]);
|
||||
var result = pipeline.process(element);
|
||||
|
||||
@@ -15,12 +15,11 @@ export function main() {
|
||||
describe('PropertyBindingParser', () => {
|
||||
function createPipeline(hasNestedProtoView = false) {
|
||||
return new CompilePipeline([
|
||||
new MockStep((parent, current, control) =>
|
||||
{
|
||||
if (hasNestedProtoView) {
|
||||
current.bindElement().bindNestedProtoView(el('<template></template>'));
|
||||
}
|
||||
}),
|
||||
new MockStep((parent, current, control) => {
|
||||
if (hasNestedProtoView) {
|
||||
current.bindElement().bindNestedProtoView(el('<template></template>'));
|
||||
}
|
||||
}),
|
||||
new PropertyBindingParser(new Parser(new Lexer()))
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -52,12 +52,11 @@ export function main() {
|
||||
xhr.expect('base/foo', 'xhr template');
|
||||
var template = new ViewDefinition({absUrl: 'base/foo'});
|
||||
loader.load(template)
|
||||
.then((el) =>
|
||||
{
|
||||
expect(DOM.content(el)).toHaveText('xhr template');
|
||||
firstEl = el;
|
||||
return loader.load(template);
|
||||
})
|
||||
.then((el) => {
|
||||
expect(DOM.content(el)).toHaveText('xhr template');
|
||||
firstEl = el;
|
||||
return loader.load(template);
|
||||
})
|
||||
.then((el) => {
|
||||
expect(el).not.toBe(firstEl);
|
||||
expect(DOM.content(el)).toHaveText('xhr template');
|
||||
|
||||
@@ -58,8 +58,7 @@ export function main() {
|
||||
inject([AsyncTestCompleter, DomTestbed], (async, tb) => {
|
||||
tb.compileAll([
|
||||
someComponent,
|
||||
new ViewDefinition(
|
||||
{componentId: 'someComponent', template: 'hello', directives: []})
|
||||
new ViewDefinition({componentId: 'someComponent', template: 'hello', directives: []})
|
||||
])
|
||||
.then((protoViewDtos) => {
|
||||
var rootView = tb.createRootView(protoViewDtos[0]);
|
||||
@@ -74,8 +73,7 @@ export function main() {
|
||||
it('should update text nodes', inject([AsyncTestCompleter, DomTestbed], (async, tb) => {
|
||||
tb.compileAll([
|
||||
someComponent,
|
||||
new ViewDefinition(
|
||||
{componentId: 'someComponent', template: '{{a}}', directives: []})
|
||||
new ViewDefinition({componentId: 'someComponent', template: '{{a}}', directives: []})
|
||||
])
|
||||
.then((protoViewDtos) => {
|
||||
var rootView = tb.createRootView(protoViewDtos[0]);
|
||||
|
||||
@@ -158,10 +158,11 @@ export function main() {
|
||||
it("should include view container nodes", () => {
|
||||
var lightDomEl = el("<div><template></template></div>");
|
||||
var lightDom = createLightDom(
|
||||
new FakeView(
|
||||
[new FakeViewContainer(DOM.firstChild(lightDomEl), // template element
|
||||
[el('<a></a>')] // light DOM nodes of view container
|
||||
)]),
|
||||
new FakeView([
|
||||
new FakeViewContainer(DOM.firstChild(lightDomEl), // template element
|
||||
[el('<a></a>')] // light DOM nodes of view container
|
||||
)
|
||||
]),
|
||||
null, lightDomEl);
|
||||
|
||||
expect(toHtml(lightDom.expandedDomNodes())).toEqual(["<a></a>"]);
|
||||
@@ -169,12 +170,14 @@ export function main() {
|
||||
|
||||
it("should include content nodes", () => {
|
||||
var lightDomEl = el("<div><content></content></div>");
|
||||
var lightDom = createLightDom(
|
||||
new FakeView([new FakeContentTag(DOM.firstChild(lightDomEl), // content element
|
||||
'', // selector
|
||||
[el('<a></a>')] // light DOM nodes of content tag
|
||||
)]),
|
||||
null, lightDomEl);
|
||||
var lightDom =
|
||||
createLightDom(new FakeView([
|
||||
new FakeContentTag(DOM.firstChild(lightDomEl), // content element
|
||||
'', // selector
|
||||
[el('<a></a>')] // light DOM nodes of content tag
|
||||
)
|
||||
]),
|
||||
null, lightDomEl);
|
||||
|
||||
expect(toHtml(lightDom.expandedDomNodes())).toEqual(["<a></a>"]);
|
||||
});
|
||||
|
||||
@@ -43,8 +43,8 @@ export function main() {
|
||||
styleInliner, styleUrlResolver, null),
|
||||
[StyleInliner, StyleUrlResolver]),
|
||||
"unscoped": bind(ShadowDomStrategy)
|
||||
.toFactory((styleUrlResolver) =>
|
||||
new EmulatedUnscopedShadowDomStrategy(styleUrlResolver, null),
|
||||
.toFactory((styleUrlResolver) => new EmulatedUnscopedShadowDomStrategy(
|
||||
styleUrlResolver, null),
|
||||
[StyleUrlResolver])
|
||||
};
|
||||
if (DOM.supportsNativeShadowDOM()) {
|
||||
@@ -404,8 +404,8 @@ var mainDir =
|
||||
var simple = new DirectiveMetadata(
|
||||
{selector: 'simple', id: 'simple', type: DirectiveMetadata.COMPONENT_TYPE});
|
||||
|
||||
var empty = new DirectiveMetadata(
|
||||
{selector: 'empty', id: 'empty', type: DirectiveMetadata.COMPONENT_TYPE});
|
||||
var empty =
|
||||
new DirectiveMetadata({selector: 'empty', id: 'empty', type: DirectiveMetadata.COMPONENT_TYPE});
|
||||
|
||||
var dynamicComponent = new DirectiveMetadata(
|
||||
{selector: 'dynamic', id: 'dynamic', type: DirectiveMetadata.COMPONENT_TYPE});
|
||||
@@ -425,11 +425,11 @@ var outerWithIndirectNestedComponent = new DirectiveMetadata({
|
||||
type: DirectiveMetadata.COMPONENT_TYPE
|
||||
});
|
||||
|
||||
var outerComponent = new DirectiveMetadata(
|
||||
{selector: 'outer', id: 'outer', type: DirectiveMetadata.COMPONENT_TYPE});
|
||||
var outerComponent =
|
||||
new DirectiveMetadata({selector: 'outer', id: 'outer', type: DirectiveMetadata.COMPONENT_TYPE});
|
||||
|
||||
var innerComponent = new DirectiveMetadata(
|
||||
{selector: 'inner', id: 'inner', type: DirectiveMetadata.COMPONENT_TYPE});
|
||||
var innerComponent =
|
||||
new DirectiveMetadata({selector: 'inner', id: 'inner', type: DirectiveMetadata.COMPONENT_TYPE});
|
||||
|
||||
var innerInnerComponent = new DirectiveMetadata(
|
||||
{selector: 'innerinner', id: 'innerinner', type: DirectiveMetadata.COMPONENT_TYPE});
|
||||
|
||||
@@ -46,9 +46,10 @@ export function main() {
|
||||
RouteRegistry,
|
||||
DirectiveResolver,
|
||||
bind(Location).toClass(SpyLocation),
|
||||
bind(Router).toFactory((registry, pipeline, location) =>
|
||||
{ return new RootRouter(registry, pipeline, location, MyComp); },
|
||||
[RouteRegistry, Pipeline, Location])
|
||||
bind(Router)
|
||||
.toFactory((registry, pipeline,
|
||||
location) => { return new RootRouter(registry, pipeline, location, MyComp); },
|
||||
[RouteRegistry, Pipeline, Location])
|
||||
]);
|
||||
|
||||
beforeEach(inject([TestBed, Router, Location], (testBed, router, loc) => {
|
||||
@@ -60,10 +61,10 @@ export function main() {
|
||||
}));
|
||||
|
||||
function compile(template: string = "<router-outlet></router-outlet>") {
|
||||
tb.overrideView(MyComp, new annotations.View({
|
||||
template: ('<div>' + template + '</div>'),
|
||||
directives: [RouterOutlet, RouterLink]
|
||||
}));
|
||||
tb.overrideView(
|
||||
MyComp,
|
||||
new annotations.View(
|
||||
{template: ('<div>' + template + '</div>'), directives: [RouterOutlet, RouterLink]}));
|
||||
return tb.createView(MyComp, {context: ctx}).then((v) => { view = v; });
|
||||
}
|
||||
|
||||
@@ -84,11 +85,10 @@ export function main() {
|
||||
compile()
|
||||
.then((_) => rtr.config({'path': '/user/:name', 'component': UserCmp}))
|
||||
.then((_) => rtr.navigate('/user/brian'))
|
||||
.then((_) =>
|
||||
{
|
||||
view.detectChanges();
|
||||
expect(view.rootNodes).toHaveText('hello brian');
|
||||
})
|
||||
.then((_) => {
|
||||
view.detectChanges();
|
||||
expect(view.rootNodes).toHaveText('hello brian');
|
||||
})
|
||||
.then((_) => rtr.navigate('/user/igor'))
|
||||
.then((_) => {
|
||||
view.detectChanges();
|
||||
@@ -116,11 +116,10 @@ export function main() {
|
||||
.then((_) => rtr.config({'path': '/ab', 'components': {'left': A, 'right': B}}))
|
||||
.then((_) => rtr.config({'path': '/ba', 'components': {'left': B, 'right': A}}))
|
||||
.then((_) => rtr.navigate('/ab'))
|
||||
.then((_) =>
|
||||
{
|
||||
view.detectChanges();
|
||||
expect(view.rootNodes).toHaveText('left { A } | right { B }');
|
||||
})
|
||||
.then((_) => {
|
||||
view.detectChanges();
|
||||
expect(view.rootNodes).toHaveText('left { A } | right { B }');
|
||||
})
|
||||
.then((_) => rtr.navigate('/ba'))
|
||||
.then((_) => {
|
||||
view.detectChanges();
|
||||
@@ -175,12 +174,11 @@ export function main() {
|
||||
compile()
|
||||
.then((_) => rtr.config({'path': '/team/:id', 'component': TeamCmp}))
|
||||
.then((_) => rtr.navigate('/team/angular/user/rado'))
|
||||
.then((_) =>
|
||||
{
|
||||
view.detectChanges();
|
||||
expect(teamCmpCount).toBe(1);
|
||||
expect(view.rootNodes).toHaveText('team angular { hello rado }');
|
||||
})
|
||||
.then((_) => {
|
||||
view.detectChanges();
|
||||
expect(teamCmpCount).toBe(1);
|
||||
expect(view.rootNodes).toHaveText('team angular { hello rado }');
|
||||
})
|
||||
.then((_) => rtr.navigate('/team/angular/user/victor'))
|
||||
.then((_) => {
|
||||
view.detectChanges();
|
||||
|
||||
@@ -34,9 +34,10 @@ export function main() {
|
||||
RouteRegistry,
|
||||
DirectiveResolver,
|
||||
bind(Location).toClass(SpyLocation),
|
||||
bind(Router).toFactory((registry, pipeline, location) =>
|
||||
{ return new RootRouter(registry, pipeline, location, AppCmp); },
|
||||
[RouteRegistry, Pipeline, Location])
|
||||
bind(Router)
|
||||
.toFactory((registry, pipeline,
|
||||
location) => { return new RootRouter(registry, pipeline, location, AppCmp); },
|
||||
[RouteRegistry, Pipeline, Location])
|
||||
]);
|
||||
|
||||
|
||||
@@ -78,11 +79,10 @@ export function main() {
|
||||
|
||||
router.registerOutlet(outlet)
|
||||
.then((_) => router.navigate('/a'))
|
||||
.then((_) =>
|
||||
{
|
||||
expect(outlet.spy('activate')).not.toHaveBeenCalled();
|
||||
return router.config({'path': '/a', 'component': 'A'});
|
||||
})
|
||||
.then((_) => {
|
||||
expect(outlet.spy('activate')).not.toHaveBeenCalled();
|
||||
return router.config({'path': '/a', 'component': 'A'});
|
||||
})
|
||||
.then((_) => {
|
||||
expect(outlet.spy('activate')).toHaveBeenCalled();
|
||||
async.done();
|
||||
|
||||
@@ -36,8 +36,7 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should ignore the base path when the url has a scheme',
|
||||
() =>
|
||||
{
|
||||
() => {
|
||||
expect(resolver.resolve('http://www.foo.com', 'http://www.bar.com'))
|
||||
.toEqual('http://www.bar.com');
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user