chore(tests): enable lint, make it green. (#10224)

This commit is contained in:
Victor Berchet 2016-07-21 17:12:00 -07:00 committed by GitHub
parent 27b87ef535
commit 00aa7a76b6
106 changed files with 1599 additions and 1634 deletions

View File

@ -97,7 +97,7 @@ gulp.task('lint', ['format:enforce', 'tools:build'], () => {
// Built-in rules are at // Built-in rules are at
// https://github.com/palantir/tslint#supported-rules // https://github.com/palantir/tslint#supported-rules
const tslintConfig = require('./tslint.json'); const tslintConfig = require('./tslint.json');
return gulp.src(['modules/@angular/**/*.ts', '!modules/@angular/*/test/**']) return gulp.src(['modules/@angular/**/*.ts'])
.pipe(tslint({ .pipe(tslint({
tslint: require('tslint').default, tslint: require('tslint').default,
configuration: tslintConfig, configuration: tslintConfig,

View File

@ -581,7 +581,7 @@ export function main() {
})); }));
}); });
}) });
} }
@Component({selector: 'test-cmp', directives: [NgClass, NgFor], template: ''}) @Component({selector: 'test-cmp', directives: [NgClass, NgFor], template: ''})

View File

@ -6,8 +6,7 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {beforeEach, beforeEachProviders, ddescribe, describe, iit, inject, it, xit,} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, beforeEach, beforeEachProviders, ddescribe, describe, iit, inject, it, xit,} from '@angular/core/testing/testing_internal';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {TestComponentBuilder} from '@angular/core/testing'; import {TestComponentBuilder} from '@angular/core/testing';
import {ListWrapper} from '../../src/facade/collection'; import {ListWrapper} from '../../src/facade/collection';
import {IS_DART} from '../../src/facade/lang'; import {IS_DART} from '../../src/facade/lang';
@ -182,7 +181,7 @@ export function main() {
.then((fixture) => { .then((fixture) => {
fixture.debugElement.componentInstance.items = 'whaaa'; fixture.debugElement.componentInstance.items = 'whaaa';
try { try {
fixture.detectChanges() fixture.detectChanges();
} catch (e) { } catch (e) {
expect(e.message).toContain( expect(e.message).toContain(
`Cannot find a differ supporting object 'whaaa' of type 'string'. NgFor only supports binding to Iterables such as Arrays.`); `Cannot find a differ supporting object 'whaaa' of type 'string'. NgFor only supports binding to Iterables such as Arrays.`);

View File

@ -6,9 +6,8 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {beforeEach, ddescribe, describe, iit, inject, it, xit,} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, beforeEach, ddescribe, describe, iit, inject, it, xit,} from '@angular/core/testing/testing_internal';
import {TestComponentBuilder} from '@angular/core/testing'; import {TestComponentBuilder} from '@angular/core/testing';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {expect} from '@angular/platform-browser/testing/matchers'; import {expect} from '@angular/platform-browser/testing/matchers';
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter'; import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';

View File

@ -6,8 +6,7 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {beforeEachProviders, beforeEach, ddescribe, describe, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, beforeEachProviders, beforeEach, ddescribe, describe, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {TestComponentBuilder} from '@angular/core/testing'; import {TestComponentBuilder} from '@angular/core/testing';
import {Component, Injectable} from '@angular/core'; import {Component, Injectable} from '@angular/core';

View File

@ -6,9 +6,8 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {beforeEach, beforeEachProviders, ddescribe, xdescribe, describe, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, beforeEach, beforeEachProviders, ddescribe, xdescribe, describe, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal';
import {TestComponentBuilder} from '@angular/core/testing'; import {TestComponentBuilder} from '@angular/core/testing';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {StringMapWrapper} from '../../src/facade/collection'; import {StringMapWrapper} from '../../src/facade/collection';
@ -191,7 +190,7 @@ export function main() {
async.done(); async.done();
}); });
})); }));
}) });
} }
@Component({selector: 'test-cmp', directives: [NgStyle], template: ''}) @Component({selector: 'test-cmp', directives: [NgStyle], template: ''})

View File

@ -6,8 +6,8 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {beforeEach, ddescribe, describe, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, beforeEach, ddescribe, describe, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {Component} from '@angular/core'; import {Component} from '@angular/core';
import {TestComponentBuilder} from '@angular/core/testing'; import {TestComponentBuilder} from '@angular/core/testing';

View File

@ -6,9 +6,8 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {beforeEach, ddescribe, describe, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, beforeEach, ddescribe, describe, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal';
import {TestComponentBuilder} from '@angular/core/testing'; import {TestComponentBuilder} from '@angular/core/testing';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {Component, Directive, TemplateRef, ContentChildren, QueryList} from '@angular/core'; import {Component, Directive, TemplateRef, ContentChildren, QueryList} from '@angular/core';
import {NgTemplateOutlet} from '@angular/common'; import {NgTemplateOutlet} from '@angular/common';

View File

@ -6,12 +6,11 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {beforeEach, ddescribe, describe, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, beforeEach, ddescribe, describe, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal';
import {TestComponentBuilder} from '@angular/core/testing'; import {TestComponentBuilder} from '@angular/core/testing';
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter'; import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
import {Component, Directive} from '@angular/core'; import {Component, Directive} from '@angular/core';
import {ElementRef} from '@angular/core/src/linker/element_ref'; import {ElementRef} from '@angular/core/src/linker/element_ref';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
export function main() { export function main() {
describe('non-bindable', () => { describe('non-bindable', () => {
@ -61,7 +60,7 @@ export function main() {
async.done(); async.done();
}); });
})); }));
}) });
} }
@Directive({selector: '[test-dec]'}) @Directive({selector: '[test-dec]'})

View File

@ -8,11 +8,9 @@
import {NgFor, NgIf} from '@angular/common'; import {NgFor, NgIf} from '@angular/common';
import {Control, ControlGroup, ControlValueAccessor, DeprecatedFormsModule, NG_ASYNC_VALIDATORS, NG_VALIDATORS, NgControl, NgForm, RadioButtonState, Validator, Validators} from '@angular/common/src/forms-deprecated'; import {Control, ControlGroup, ControlValueAccessor, DeprecatedFormsModule, NG_ASYNC_VALIDATORS, NG_VALIDATORS, NgControl, NgForm, RadioButtonState, Validator, Validators} from '@angular/common/src/forms-deprecated';
import {Component, Directive, EventEmitter, Output} from '@angular/core'; import {Component, Directive, EventEmitter, Input, Output, Provider, forwardRef} from '@angular/core';
import {Input, Provider, forwardRef} from '@angular/core';
import {ComponentFixture, TestComponentBuilder, configureModule, fakeAsync, flushMicrotasks, tick} from '@angular/core/testing'; import {ComponentFixture, TestComponentBuilder, configureModule, fakeAsync, flushMicrotasks, tick} from '@angular/core/testing';
import {afterEach, beforeEach, ddescribe, describe, expect, iit, inject, it, xit} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, afterEach, beforeEach, ddescribe, describe, expect, iit, inject, it, xit} from '@angular/core/testing/testing_internal';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {By} from '@angular/platform-browser/src/dom/debug/by'; import {By} from '@angular/platform-browser/src/dom/debug/by';
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter'; import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
import {dispatchEvent} from '@angular/platform-browser/testing/browser_util'; import {dispatchEvent} from '@angular/platform-browser/testing/browser_util';
@ -24,7 +22,7 @@ import {PromiseWrapper} from '../../src/facade/promise';
export function main() { export function main() {
describe('integration tests', () => { describe('integration tests', () => {
beforeEach(() => {configureModule({modules: [DeprecatedFormsModule]})}); beforeEach(() => { configureModule({modules: [DeprecatedFormsModule]}); });
it('should initialize DOM elements with the given form object', it('should initialize DOM elements with the given form object',
inject( inject(

View File

@ -6,9 +6,8 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {ddescribe, describe, it, iit, xit, expect, beforeEach, afterEach, inject,} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, ddescribe, describe, it, iit, xit, expect, beforeEach, afterEach, inject,} from '@angular/core/testing/testing_internal';
import {fakeAsync, flushMicrotasks, tick} from '@angular/core/testing'; import {fakeAsync, flushMicrotasks, tick} from '@angular/core/testing';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {ControlGroup, Control, ControlArray, Validators} from '@angular/common/src/forms-deprecated'; import {ControlGroup, Control, ControlArray, Validators} from '@angular/common/src/forms-deprecated';
import {IS_DART, isPresent} from '../../src/facade/lang'; import {IS_DART, isPresent} from '../../src/facade/lang';
import {PromiseWrapper} from '../../src/facade/promise'; import {PromiseWrapper} from '../../src/facade/promise';
@ -430,7 +429,7 @@ export function main() {
// rename contains into has // rename contains into has
it('should return false when the component is not included', it('should return false when the component is not included',
() => { expect(group.contains('optional')).toEqual(false); }) () => { expect(group.contains('optional')).toEqual(false); });
it('should return false when there is no component with the given name', it('should return false when there is no component with the given name',
() => { expect(group.contains('something else')).toEqual(false); }); () => { expect(group.contains('something else')).toEqual(false); });
@ -605,7 +604,7 @@ export function main() {
expect(g.errors).toEqual({'async': true}); expect(g.errors).toEqual({'async': true});
expect(g.find(['one']).errors).toEqual({'async': true}); expect(g.find(['one']).errors).toEqual({'async': true});
})); }));
}) });
}); });
describe('ControlArray', () => { describe('ControlArray', () => {
@ -829,7 +828,7 @@ export function main() {
expect(g.errors).toEqual({'async': true}); expect(g.errors).toEqual({'async': true});
expect(g.pending).toEqual(false); expect(g.pending).toEqual(false);
})); }));
}) });
}); });
}); });
} }

View File

@ -19,9 +19,9 @@ export function main() {
function validator(key: string, error: any) { function validator(key: string, error: any) {
return function(c: AbstractControl) { return function(c: AbstractControl) {
var r = {}; var r = {};
(r as any /** TODO #9100 */)[key] = error; (r as any)[key] = error;
return r; return r;
} };
} }
class AsyncValidatorDirective { class AsyncValidatorDirective {

View File

@ -6,8 +6,7 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {ddescribe, describe, it, iit, xit, expect, beforeEach, afterEach, inject,} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, ddescribe, describe, it, iit, xit, expect, beforeEach, afterEach, inject,} from '@angular/core/testing/testing_internal';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {SpyChangeDetectorRef} from '../spies'; import {SpyChangeDetectorRef} from '../spies';
import {isBlank} from '../../src/facade/lang'; import {isBlank} from '../../src/facade/lang';
import {AsyncPipe} from '@angular/common'; import {AsyncPipe} from '@angular/common';
@ -45,7 +44,7 @@ export function main() {
TimerWrapper.setTimeout(() => { TimerWrapper.setTimeout(() => {
expect(pipe.transform(emitter)).toEqual(new WrappedValue(message)); expect(pipe.transform(emitter)).toEqual(new WrappedValue(message));
async.done(); async.done();
}, 0) }, 0);
})); }));
@ -58,7 +57,7 @@ export function main() {
pipe.transform(emitter); pipe.transform(emitter);
expect(pipe.transform(emitter)).toBe(message); expect(pipe.transform(emitter)).toBe(message);
async.done(); async.done();
}, 0) }, 0);
})); }));
it('should dispose of the existing subscription when subscribing to a new observable', it('should dispose of the existing subscription when subscribing to a new observable',
@ -74,7 +73,7 @@ export function main() {
TimerWrapper.setTimeout(() => { TimerWrapper.setTimeout(() => {
expect(pipe.transform(newEmitter)).toBe(null); expect(pipe.transform(newEmitter)).toBe(null);
async.done(); async.done();
}, 0) }, 0);
})); }));
it('should request a change detection check upon receiving a new value', it('should request a change detection check upon receiving a new value',
@ -85,7 +84,7 @@ export function main() {
TimerWrapper.setTimeout(() => { TimerWrapper.setTimeout(() => {
expect(ref.spy('markForCheck')).toHaveBeenCalled(); expect(ref.spy('markForCheck')).toHaveBeenCalled();
async.done(); async.done();
}, 10) }, 10);
})); }));
}); });
@ -103,7 +102,7 @@ export function main() {
TimerWrapper.setTimeout(() => { TimerWrapper.setTimeout(() => {
expect(pipe.transform(emitter)).toBe(null); expect(pipe.transform(emitter)).toBe(null);
async.done(); async.done();
}, 0) }, 0);
})); }));
}); });
}); });
@ -135,7 +134,7 @@ export function main() {
TimerWrapper.setTimeout(() => { TimerWrapper.setTimeout(() => {
expect(pipe.transform(completer.promise)).toEqual(new WrappedValue(message)); expect(pipe.transform(completer.promise)).toEqual(new WrappedValue(message));
async.done(); async.done();
}, timer) }, timer);
})); }));
it('should return unwrapped value when nothing has changed since the last call', it('should return unwrapped value when nothing has changed since the last call',
@ -147,7 +146,7 @@ export function main() {
pipe.transform(completer.promise); pipe.transform(completer.promise);
expect(pipe.transform(completer.promise)).toBe(message); expect(pipe.transform(completer.promise)).toBe(message);
async.done(); async.done();
}, timer) }, timer);
})); }));
it('should dispose of the existing subscription when subscribing to a new promise', it('should dispose of the existing subscription when subscribing to a new promise',
@ -163,7 +162,7 @@ export function main() {
TimerWrapper.setTimeout(() => { TimerWrapper.setTimeout(() => {
expect(pipe.transform(newCompleter.promise)).toBe(null); expect(pipe.transform(newCompleter.promise)).toBe(null);
async.done(); async.done();
}, timer) }, timer);
})); }));
it('should request a change detection check upon receiving a new value', it('should request a change detection check upon receiving a new value',
@ -175,7 +174,7 @@ export function main() {
TimerWrapper.setTimeout(() => { TimerWrapper.setTimeout(() => {
expect(markForCheck).toHaveBeenCalled(); expect(markForCheck).toHaveBeenCalled();
async.done(); async.done();
}, timer) }, timer);
})); }));
describe('ngOnDestroy', () => { describe('ngOnDestroy', () => {
@ -186,7 +185,7 @@ export function main() {
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
pipe.transform(completer.promise); pipe.transform(completer.promise);
expect(pipe.transform(completer.promise)).toBe(null); expect(pipe.transform(completer.promise)).toBe(null);
completer.resolve(message) completer.resolve(message);
TimerWrapper.setTimeout(() => { TimerWrapper.setTimeout(() => {

View File

@ -6,8 +6,7 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {ddescribe, describe, it, iit, xit, expect, beforeEach, afterEach, inject,} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, ddescribe, describe, it, iit, xit, expect, beforeEach, afterEach, inject,} from '@angular/core/testing/testing_internal';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {TestComponentBuilder} from '@angular/core/testing'; import {TestComponentBuilder} from '@angular/core/testing';
import {Json, StringWrapper} from '../../src/facade/lang'; import {Json, StringWrapper} from '../../src/facade/lang';

View File

@ -7,7 +7,6 @@
*/ */
import {ddescribe, describe, it, iit, xit, expect, beforeEach, afterEach, inject,} from '@angular/core/testing/testing_internal'; import {ddescribe, describe, it, iit, xit, expect, beforeEach, afterEach, inject,} from '@angular/core/testing/testing_internal';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {ReplacePipe} from '@angular/common'; import {ReplacePipe} from '@angular/common';
import {RegExpWrapper, StringJoiner} from '../../src/facade/lang'; import {RegExpWrapper, StringJoiner} from '../../src/facade/lang';

View File

@ -6,9 +6,8 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {ddescribe, describe, it, iit, xit, expect, beforeEach, afterEach, inject,} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, ddescribe, describe, it, iit, xit, expect, beforeEach, afterEach, inject,} from '@angular/core/testing/testing_internal';
import {TestComponentBuilder} from '@angular/core/testing'; import {TestComponentBuilder} from '@angular/core/testing';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {browserDetection} from '@angular/platform-browser/testing/browser_util'; import {browserDetection} from '@angular/platform-browser/testing/browser_util';
import {Component} from '@angular/core'; import {Component} from '@angular/core';

View File

@ -8,7 +8,7 @@
import * as ts from 'typescript'; import * as ts from 'typescript';
import {ReflectorHost, ReflectorHostContext} from '../src/reflector_host'; import {ReflectorHostContext} from '../src/reflector_host';
export type Entry = string | Directory; export type Entry = string | Directory;
@ -19,7 +19,7 @@ export class MockContext implements ReflectorHostContext {
fileExists(fileName: string): boolean { return typeof this.getEntry(fileName) === 'string'; } fileExists(fileName: string): boolean { return typeof this.getEntry(fileName) === 'string'; }
directoryExists(path: string): boolean { return typeof this.getEntry(path) === 'object' } directoryExists(path: string): boolean { return typeof this.getEntry(path) === 'object'; }
readFile(fileName: string): string|undefined { readFile(fileName: string): string|undefined {
let data = this.getEntry(fileName); let data = this.getEntry(fileName);

View File

@ -21,7 +21,7 @@ describe('reflector_host', () => {
beforeEach(() => { beforeEach(() => {
context = new MockContext('/tmp/src', clone(FILES)); context = new MockContext('/tmp/src', clone(FILES));
host = new MockCompilerHost(context) host = new MockCompilerHost(context);
program = ts.createProgram( program = ts.createProgram(
['main.ts'], { ['main.ts'], {
module: ts.ModuleKind.CommonJS, module: ts.ModuleKind.CommonJS,
@ -93,10 +93,10 @@ describe('reflector_host', () => {
expect(reflectorHost.getStaticSymbol('angularjs', 'SomeAngularSymbol')).toBeDefined(); expect(reflectorHost.getStaticSymbol('angularjs', 'SomeAngularSymbol')).toBeDefined();
}); });
it('should be able to read a metadata file', it('should be able to read a metadata file', () => {
() => { expect(reflectorHost.getMetadataFor('node_modules/@angular/core.d.ts'))
expect(reflectorHost.getMetadataFor('node_modules/@angular/core.d.ts')) .toEqual({__symbolic: 'module', version: 1, metadata: {foo: {__symbolic: 'class'}}});
.toEqual({__symbolic: 'module', version: 1, metadata: {foo: {__symbolic: 'class'}}})}); });
it('should be able to read metadata from an otherwise unused .d.ts file ', () => { it('should be able to read metadata from an otherwise unused .d.ts file ', () => {
expect(reflectorHost.getMetadataFor('node_modules/@angular/unused.d.ts')).toBeUndefined(); expect(reflectorHost.getMetadataFor('node_modules/@angular/unused.d.ts')).toBeUndefined();
@ -107,7 +107,8 @@ describe('reflector_host', () => {
}); });
}); });
const dummyModule = 'export let foo: any[];' const dummyModule = 'export let foo: any[];';
const FILES: Entry = { const FILES: Entry = {
'tmp': { 'tmp': {
'src': { 'src': {
@ -134,7 +135,7 @@ const FILES: Entry = {
} }
} }
} }
} };
function clone(entry: Entry): Entry { function clone(entry: Entry): Entry {
if (typeof entry === 'string') { if (typeof entry === 'string') {

View File

@ -51,7 +51,7 @@ export function main() {
}; };
var getAnimationAstFromEntryAst = var getAnimationAstFromEntryAst =
(ast: AnimationEntryAst) => { return ast.stateTransitions[0].animation; } (ast: AnimationEntryAst) => { return ast.stateTransitions[0].animation; };
var parseAnimationAst = (data: AnimationMetadata[]) => { var parseAnimationAst = (data: AnimationMetadata[]) => {
return getAnimationAstFromEntryAst(parseAnimation(data).ast); return getAnimationAstFromEntryAst(parseAnimation(data).ast);

View File

@ -176,7 +176,7 @@ export function main() {
describe('CompileAnimationAnimateMetadata', () => { describe('CompileAnimationAnimateMetadata', () => {
it('should serialize with full data', () => { it('should serialize with full data', () => {
let full = new CompileAnimationAnimateMetadata( let full = new CompileAnimationAnimateMetadata(
'1s linear', new CompileAnimationStyleMetadata(0, [{'opacity': 0.5, 'color': 'blue'}])) '1s linear', new CompileAnimationStyleMetadata(0, [{'opacity': 0.5, 'color': 'blue'}]));
expect(CompileAnimationAnimateMetadata.fromJson(full.toJson())).toEqual(full); expect(CompileAnimationAnimateMetadata.fromJson(full.toJson())).toEqual(full);
}); });

View File

@ -22,6 +22,9 @@ function _assertTokens(tokens: CssToken[], valuesArr: string[]): void {
class MyVisitor implements CssAstVisitor { class MyVisitor implements CssAstVisitor {
captures: {[key: string]: any[]} = {}; captures: {[key: string]: any[]} = {};
/**
* @internal
*/
_capture(method: string, ast: CssAst, context: any) { _capture(method: string, ast: CssAst, context: any) {
this.captures[method] = isPresent(this.captures[method]) ? this.captures[method] : []; this.captures[method] = isPresent(this.captures[method]) ? this.captures[method] : [];
this.captures[method].push([ast, context]); this.captures[method].push([ast, context]);

View File

@ -13,8 +13,7 @@ import {XHR} from '@angular/compiler/src/xhr';
import {MockXHR} from '@angular/compiler/testing/xhr_mock'; import {MockXHR} from '@angular/compiler/testing/xhr_mock';
import {ViewEncapsulation} from '@angular/core/src/metadata/view'; import {ViewEncapsulation} from '@angular/core/src/metadata/view';
import {configureCompiler} from '@angular/core/testing'; import {configureCompiler} from '@angular/core/testing';
import {beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xit} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xit} from '@angular/core/testing/testing_internal';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {SpyXHR} from './spies'; import {SpyXHR} from './spies';
import {TEST_COMPILER_PROVIDERS} from './test_bindings'; import {TEST_COMPILER_PROVIDERS} from './test_bindings';
@ -53,7 +52,7 @@ export function main() {
templateUrl: null, templateUrl: null,
styles: [], styles: [],
styleUrls: [] styleUrls: []
})) }));
expect(template.template).toEqual('a'); expect(template.template).toEqual('a');
expect(template.templateUrl).toEqual('package:some/module/a.js'); expect(template.templateUrl).toEqual('package:some/module/a.js');
})); }));
@ -66,7 +65,7 @@ export function main() {
templateUrl: null, templateUrl: null,
styles: [], styles: [],
styleUrls: ['test.css'] styleUrls: ['test.css']
})) }));
expect(template.styleUrls).toEqual(['package:some/module/test.css']); expect(template.styleUrls).toEqual(['package:some/module/test.css']);
})); }));
@ -79,7 +78,7 @@ export function main() {
templateUrl: null, templateUrl: null,
styles: [], styles: [],
styleUrls: [] styleUrls: []
})) }));
expect(template.styleUrls).toEqual(['package:some/module/test.css']); expect(template.styleUrls).toEqual(['package:some/module/test.css']);
})); }));
@ -91,7 +90,7 @@ export function main() {
templateUrl: null, templateUrl: null,
styles: [], styles: [],
styleUrls: ['test.css'] styleUrls: ['test.css']
})) }));
expect(template.encapsulation).toEqual(ViewEncapsulation.Emulated); expect(template.encapsulation).toEqual(ViewEncapsulation.Emulated);
})); }));
@ -107,7 +106,7 @@ export function main() {
templateUrl: null, templateUrl: null,
styles: [], styles: [],
styleUrls: ['test.css'] styleUrls: ['test.css']
})) }));
expect(template.encapsulation).toEqual(ViewEncapsulation.None); expect(template.encapsulation).toEqual(ViewEncapsulation.None);
})); }));
}); });
@ -277,7 +276,7 @@ export function main() {
dirType, dirType,
new CompileTemplateMetadata({encapsulation: null, styles: [], styleUrls: []}), 'a', new CompileTemplateMetadata({encapsulation: null, styles: [], styleUrls: []}), 'a',
'package:some/module/'); 'package:some/module/');
expect(template.template).toEqual('a') expect(template.template).toEqual('a');
})); }));
it('should collect ngContent', it('should collect ngContent',

View File

@ -312,7 +312,7 @@ export function main() {
if (binding.keyIsVar) { if (binding.keyIsVar) {
return 'let ' + binding.key + (isBlank(binding.name) ? '=null' : '=' + binding.name); return 'let ' + binding.key + (isBlank(binding.name) ? '=null' : '=' + binding.name);
} else { } else {
return binding.key + (isBlank(binding.expression) ? '' : `=${binding.expression}`) return binding.key + (isBlank(binding.expression) ? '' : `=${binding.expression}`);
} }
}); });
} }
@ -550,7 +550,7 @@ export function main() {
it('should be able to recover from a missing ]', () => recover('[a,b', '[a, b]')); it('should be able to recover from a missing ]', () => recover('[a,b', '[a, b]'));
it('should be able to recover from a missing selector', () => recover('a.')); it('should be able to recover from a missing selector', () => recover('a.'));
it('should be able to recover from a missing selector in a array literal', it('should be able to recover from a missing selector in a array literal',
() => recover('[[a.], b, c]')) () => recover('[[a.], b, c]'));
}); });
}); });
} }

View File

@ -1,3 +1,11 @@
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {AST, Binary, BindingPipe, Chain, Conditional, EmptyExpr, FunctionCall, ImplicitReceiver, Interpolation, KeyedRead, KeyedWrite, LiteralArray, LiteralMap, LiteralPrimitive, MethodCall, ParseSpan, PrefixNot, PropertyRead, PropertyWrite, Quote, RecursiveAstVisitor, SafeMethodCall, SafePropertyRead} from '../../src/expression_parser/ast'; import {AST, Binary, BindingPipe, Chain, Conditional, EmptyExpr, FunctionCall, ImplicitReceiver, Interpolation, KeyedRead, KeyedWrite, LiteralArray, LiteralMap, LiteralPrimitive, MethodCall, ParseSpan, PrefixNot, PropertyRead, PropertyWrite, Quote, RecursiveAstVisitor, SafeMethodCall, SafePropertyRead} from '../../src/expression_parser/ast';
import {unparse} from './unparser'; import {unparse} from './unparser';

View File

@ -65,13 +65,14 @@ export function main() {
]); ]);
}); });
it('should store the locations', it('should store the locations', () => {
() => {expect(tokenizeAndHumanizeSourceSpans('<!--t\ne\rs\r\nt-->')).toEqual([ expect(tokenizeAndHumanizeSourceSpans('<!--t\ne\rs\r\nt-->')).toEqual([
[HtmlTokenType.COMMENT_START, '<!--'], [HtmlTokenType.COMMENT_START, '<!--'],
[HtmlTokenType.RAW_TEXT, 't\ne\rs\r\nt'], [HtmlTokenType.RAW_TEXT, 't\ne\rs\r\nt'],
[HtmlTokenType.COMMENT_END, '-->'], [HtmlTokenType.COMMENT_END, '-->'],
[HtmlTokenType.EOF, ''], [HtmlTokenType.EOF, ''],
])}); ]);
});
it('should report <!- without -', () => { it('should report <!- without -', () => {
expect(tokenizeAndHumanizeErrors('<!-a')).toEqual([ expect(tokenizeAndHumanizeErrors('<!-a')).toEqual([

View File

@ -8,28 +8,27 @@
import {beforeEach, ddescribe, describe, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal'; import {beforeEach, ddescribe, describe, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal';
import {IS_DART} from '../../src/facade/lang';
import * as typed from './output_emitter_codegen_typed'; import * as typed from './output_emitter_codegen_typed';
import * as untyped from './output_emitter_codegen_untyped'; import * as untyped from './output_emitter_codegen_untyped';
import {jitStatements} from '@angular/compiler/src/output/output_jit'; import {jitStatements} from '@angular/compiler/src/output/output_jit';
import {interpretStatements} from '@angular/compiler/src/output/output_interpreter'; import {interpretStatements} from '@angular/compiler/src/output/output_interpreter';
import {codegenStmts, ExternalClass} from './output_emitter_util'; import {codegenStmts, ExternalClass} from './output_emitter_util';
import {EventEmitter} from '@angular/core'; import {BaseException, EventEmitter} from '@angular/core';
import {ViewType} from '@angular/core/src/linker/view_type'; import {ViewType} from '@angular/core/src/linker/view_type';
import {BaseException} from '@angular/core';
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter'; import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
import {browserDetection} from '@angular/platform-browser/testing/browser_util' import {browserDetection} from '@angular/platform-browser/testing/browser_util';
export function main() { export function main() {
var outputDefs: any[] /** TODO #9100 */ = []; outputDefs.push({ var outputDefs: any[] /** TODO #9100 */ = [];
outputDefs.push({
'getExpressions': () => interpretStatements(codegenStmts, 'getExpressions'), 'getExpressions': () => interpretStatements(codegenStmts, 'getExpressions'),
'name': 'interpreted' 'name': 'interpreted'
}); });
if (IS_DART || !getDOM().supportsDOMEvents()) {
// Our generator only works on node.js and Dart... if (!getDOM().supportsDOMEvents()) {
// Our generator only works on node.js
outputDefs.push({'getExpressions': () => typed.getExpressions, 'name': 'typed'}); outputDefs.push({'getExpressions': () => typed.getExpressions, 'name': 'typed'});
} if (!IS_DART) { } else {
// Our generator only works on node.js and Dart... // Our generator only works on node.js and Dart...
if (!getDOM().supportsDOMEvents()) { if (!getDOM().supportsDOMEvents()) {
outputDefs.push({'getExpressions': () => untyped.getExpressions, 'name': 'untyped'}); outputDefs.push({'getExpressions': () => untyped.getExpressions, 'name': 'untyped'});
@ -40,166 +39,155 @@ export function main() {
}); });
} }
describe( describe('output emitter', () => {
'output emitter', outputDefs.forEach((outputDef) => {
() => { describe(`${outputDef['name']}`, () => {
outputDefs.forEach((outputDef) => { var expressions: any /** TODO #9100 */;
describe(`${outputDef['name']}`, () => { beforeEach(() => { expressions = outputDef['getExpressions']()(); });
var expressions: any /** TODO #9100 */;
beforeEach(() => { expressions = outputDef['getExpressions']()(); });
it('should support literals', () => { it('should support literals', () => {
expect(expressions['stringLiteral']).toEqual('Hello World!'); expect(expressions['stringLiteral']).toEqual('Hello World!');
expect(expressions['intLiteral']).toEqual(42); expect(expressions['intLiteral']).toEqual(42);
expect(expressions['boolLiteral']).toEqual(true); expect(expressions['boolLiteral']).toEqual(true);
expect(expressions['arrayLiteral']).toEqual([0]); expect(expressions['arrayLiteral']).toEqual([0]);
expect(expressions['mapLiteral']).toEqual({'key0': 0}); expect(expressions['mapLiteral']).toEqual({'key0': 0});
}); });
it('should support reading vars/keys/props', () => { it('should support reading vars/keys/props', () => {
expect(expressions['readVar']).toEqual('someValue'); expect(expressions['readVar']).toEqual('someValue');
expect(expressions['readKey']).toEqual('someValue'); expect(expressions['readKey']).toEqual('someValue');
expect(expressions['readPropExternalInstance']).toEqual('someValue'); expect(expressions['readPropExternalInstance']).toEqual('someValue');
expect(expressions['readPropDynamicInstance']).toEqual('dynamicValue'); expect(expressions['readPropDynamicInstance']).toEqual('dynamicValue');
expect(expressions['readGetterDynamicInstance']) expect(expressions['readGetterDynamicInstance'])
.toEqual({'data': 'someValue', 'dynamicProp': 'dynamicValue'}); .toEqual({'data': 'someValue', 'dynamicProp': 'dynamicValue'});
}); });
it('should support writing to vars / keys / props', () => { it('should support writing to vars / keys / props', () => {
expect(expressions['changedVar']).toEqual('changedValue'); expect(expressions['changedVar']).toEqual('changedValue');
expect(expressions['changedKey']).toEqual('changedValue'); expect(expressions['changedKey']).toEqual('changedValue');
expect(expressions['changedPropExternalInstance']).toEqual('changedValue'); expect(expressions['changedPropExternalInstance']).toEqual('changedValue');
expect(expressions['changedPropDynamicInstance']).toEqual('changedValue'); expect(expressions['changedPropDynamicInstance']).toEqual('changedValue');
}); });
it('should support declaring functions with parameters and return', () => { it('should support declaring functions with parameters and return', () => {
expect(expressions['fn']('someParam')).toEqual({'param': 'someParam'}); expect(expressions['fn']('someParam')).toEqual({'param': 'someParam'});
expect(expressions['closureInDynamicInstance']('someParam')).toEqual({ expect(expressions['closureInDynamicInstance']('someParam'))
'param': 'someParam', .toEqual({'param': 'someParam', 'data': 'someValue', 'dynamicProp': 'dynamicValue'});
'data': 'someValue', });
'dynamicProp': 'dynamicValue'
});
});
it('should support invoking functions and methods', () => { it('should support invoking functions and methods', () => {
expect(expressions['invokeFn']).toEqual({'param': 'someParam'}); expect(expressions['invokeFn']).toEqual({'param': 'someParam'});
expect(expressions['concatedArray']).toEqual([0, 1]); expect(expressions['concatedArray']).toEqual([0, 1]);
expect(expressions['invokeMethodExternalInstance']) expect(expressions['invokeMethodExternalInstance'])
.toEqual({'data': 'someValue', 'param': 'someParam'}); .toEqual({'data': 'someValue', 'param': 'someParam'});
expect(expressions['invokeMethodExternalInstanceViaBind']) expect(expressions['invokeMethodExternalInstanceViaBind'])
.toEqual({'data': 'someValue', 'param': 'someParam'}); .toEqual({'data': 'someValue', 'param': 'someParam'});
expect(expressions['invokeMethodDynamicInstance']).toEqual({ expect(expressions['invokeMethodDynamicInstance'])
'data': 'someValue', .toEqual({'data': 'someValue', 'dynamicProp': 'dynamicValue', 'param': 'someParam'});
'dynamicProp': 'dynamicValue', expect(expressions['invokeMethodDynamicInstanceViaBind'])
'param': 'someParam' .toEqual({'data': 'someValue', 'dynamicProp': 'dynamicValue', 'param': 'someParam'});
}); });
expect(expressions['invokeMethodDynamicInstanceViaBind']).toEqual({
'data': 'someValue',
'dynamicProp': 'dynamicValue',
'param': 'someParam'
});
});
it('should support conditionals', () => { it('should support conditionals', () => {
expect(expressions['conditionalTrue']).toEqual('true'); expect(expressions['conditionalTrue']).toEqual('true');
expect(expressions['conditionalFalse']).toEqual('false'); expect(expressions['conditionalFalse']).toEqual('false');
}); });
it('should support not', () => { expect(expressions['not']).toEqual(true); }); it('should support not', () => { expect(expressions['not']).toEqual(true); });
it('should support reading external identifiers', () => { it('should support reading external identifiers', () => {
expect(expressions['externalTestIdentifier']).toBe(ExternalClass); expect(expressions['externalTestIdentifier']).toBe(ExternalClass);
expect(expressions['externalSrcIdentifier']).toBe(EventEmitter); expect(expressions['externalSrcIdentifier']).toBe(EventEmitter);
expect(expressions['externalEnumIdentifier']).toBe(ViewType.HOST); expect(expressions['externalEnumIdentifier']).toBe(ViewType.HOST);
}); });
it('should support instantiating classes', () => { it('should support instantiating classes', () => {
expect(expressions['externalInstance']).toBeAnInstanceOf(ExternalClass); expect(expressions['externalInstance']).toBeAnInstanceOf(ExternalClass);
// Note: toBeAnInstanceOf does not check super classes in Dart... // Note: toBeAnInstanceOf does not check super classes in Dart...
expect(expressions['dynamicInstance'] instanceof ExternalClass).toBe(true); expect(expressions['dynamicInstance'] instanceof ExternalClass).toBe(true);
}); });
describe('operators', () => { describe('operators', () => {
var ops: any /** TODO #9100 */; var ops: any /** TODO #9100 */;
var aObj: any /** TODO #9100 */, bObj: any /** TODO #9100 */; var aObj: any /** TODO #9100 */, bObj: any /** TODO #9100 */;
beforeEach(() => { beforeEach(() => {
ops = expressions['operators']; ops = expressions['operators'];
aObj = new Object(); aObj = new Object();
bObj = new Object(); bObj = new Object();
}); });
it('should support ==', () => { it('should support ==', () => {
expect(ops['=='](aObj, aObj)).toBe(true); expect(ops['=='](aObj, aObj)).toBe(true);
expect(ops['=='](aObj, bObj)).toBe(false); expect(ops['=='](aObj, bObj)).toBe(false);
expect(ops['=='](1, 1)).toBe(true); expect(ops['=='](1, 1)).toBe(true);
expect(ops['=='](0, 1)).toBe(false); expect(ops['=='](0, 1)).toBe(false);
expect(ops['==']('a', 'a')).toBe(true); expect(ops['==']('a', 'a')).toBe(true);
expect(ops['==']('a', 'b')).toBe(false); expect(ops['==']('a', 'b')).toBe(false);
}); });
it('should support !=', () => { it('should support !=', () => {
expect(ops['!='](aObj, aObj)).toBe(false); expect(ops['!='](aObj, aObj)).toBe(false);
expect(ops['!='](aObj, bObj)).toBe(true); expect(ops['!='](aObj, bObj)).toBe(true);
expect(ops['!='](1, 1)).toBe(false); expect(ops['!='](1, 1)).toBe(false);
expect(ops['!='](0, 1)).toBe(true); expect(ops['!='](0, 1)).toBe(true);
expect(ops['!=']('a', 'a')).toBe(false); expect(ops['!=']('a', 'a')).toBe(false);
expect(ops['!=']('a', 'b')).toBe(true); expect(ops['!=']('a', 'b')).toBe(true);
}); });
it('should support ===', () => { it('should support ===', () => {
expect(ops['==='](aObj, aObj)).toBe(true); expect(ops['==='](aObj, aObj)).toBe(true);
expect(ops['==='](aObj, bObj)).toBe(false); expect(ops['==='](aObj, bObj)).toBe(false);
expect(ops['==='](1, 1)).toBe(true); expect(ops['==='](1, 1)).toBe(true);
expect(ops['==='](0, 1)).toBe(false); expect(ops['==='](0, 1)).toBe(false);
}); });
it('should support !==', () => { it('should support !==', () => {
expect(ops['!=='](aObj, aObj)).toBe(false); expect(ops['!=='](aObj, aObj)).toBe(false);
expect(ops['!=='](aObj, bObj)).toBe(true); expect(ops['!=='](aObj, bObj)).toBe(true);
expect(ops['!=='](1, 1)).toBe(false); expect(ops['!=='](1, 1)).toBe(false);
expect(ops['!=='](0, 1)).toBe(true); expect(ops['!=='](0, 1)).toBe(true);
}); });
it('should support -', () => { expect(ops['-'](3, 2)).toEqual(1); }); it('should support -', () => { expect(ops['-'](3, 2)).toEqual(1); });
it('should support +', () => { expect(ops['+'](1, 2)).toEqual(3); }); it('should support +', () => { expect(ops['+'](1, 2)).toEqual(3); });
it('should support /', () => { expect(ops['/'](6, 2)).toEqual(3); }); it('should support /', () => { expect(ops['/'](6, 2)).toEqual(3); });
it('should support *', () => { expect(ops['*'](2, 3)).toEqual(6); }); it('should support *', () => { expect(ops['*'](2, 3)).toEqual(6); });
it('should support %', () => { expect(ops['%'](3, 2)).toEqual(1); }); it('should support %', () => { expect(ops['%'](3, 2)).toEqual(1); });
it('should support &&', () => { it('should support &&', () => {
expect(ops['&&'](true, true)).toBe(true); expect(ops['&&'](true, true)).toBe(true);
expect(ops['&&'](true, false)).toBe(false); expect(ops['&&'](true, false)).toBe(false);
}); });
it('should support ||', () => { it('should support ||', () => {
expect(ops['||'](true, false)).toBe(true); expect(ops['||'](true, false)).toBe(true);
expect(ops['||'](false, false)).toBe(false); expect(ops['||'](false, false)).toBe(false);
}); });
it('should support <', () => { it('should support <', () => {
expect(ops['<'](1, 2)).toBe(true); expect(ops['<'](1, 2)).toBe(true);
expect(ops['<'](1, 1)).toBe(false); expect(ops['<'](1, 1)).toBe(false);
}); });
it('should support <=', () => { it('should support <=', () => {
expect(ops['<='](1, 2)).toBe(true); expect(ops['<='](1, 2)).toBe(true);
expect(ops['<='](1, 1)).toBe(true); expect(ops['<='](1, 1)).toBe(true);
}); });
it('should support >', () => { it('should support >', () => {
expect(ops['>'](2, 1)).toBe(true); expect(ops['>'](2, 1)).toBe(true);
expect(ops['>'](1, 1)).toBe(false); expect(ops['>'](1, 1)).toBe(false);
}); });
it('should support >=', () => { it('should support >=', () => {
expect(ops['>='](2, 1)).toBe(true); expect(ops['>='](2, 1)).toBe(true);
expect(ops['>='](1, 1)).toBe(true); expect(ops['>='](1, 1)).toBe(true);
});
});
it('should support throwing errors',
() => { expect(expressions['throwError']).toThrowError('someError'); });
it('should support catching errors', () => {
function someOperation() { throw new BaseException('Boom!'); }
var errorAndStack = expressions['catchError'](someOperation);
expect(errorAndStack[0].message).toEqual('Boom!');
// Somehow we don't get stacktraces on ios7...
if (!browserDetection.isIOS7 && !browserDetection.isIE) {
expect(errorAndStack[1].toString()).toContain('someOperation');
}
});
}); });
}); });
it('should support throwing errors',
() => { expect(expressions['throwError']).toThrowError('someError'); });
it('should support catching errors', () => {
function someOperation() { throw new BaseException('Boom!'); }
var errorAndStack = expressions['catchError'](someOperation);
expect(errorAndStack[0].message).toEqual('Boom!');
// Somehow we don't get stacktraces on ios7...
if (!browserDetection.isIOS7 && !browserDetection.isIE) {
expect(errorAndStack[1].toString()).toContain('someOperation');
}
});
}); });
});
});
} }

View File

@ -1,3 +1,11 @@
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {beforeEach, ddescribe, xdescribe, describe, expect, iit, inject, beforeEachProviders, it, xit,} from '@angular/core/testing/testing_internal'; import {beforeEach, ddescribe, xdescribe, describe, expect, iit, inject, beforeEachProviders, it, xit,} from '@angular/core/testing/testing_internal';
import {Injectable, Component, Input, ViewMetadata, Compiler, ComponentFactory, Injector, AppModule, AppModuleMetadata, AppModuleFactory} from '@angular/core'; import {Injectable, Component, Input, ViewMetadata, Compiler, ComponentFactory, Injector, AppModule, AppModuleMetadata, AppModuleFactory} from '@angular/core';
import {ConcreteType, stringify} from '../src/facade/lang'; import {ConcreteType, stringify} from '../src/facade/lang';

View File

@ -6,8 +6,7 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {SelectorMatcher} from '@angular/compiler/src/selector'; import {CssSelector, SelectorMatcher} from '@angular/compiler/src/selector';
import {CssSelector} from '@angular/compiler/src/selector';
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter'; import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
import {el} from '@angular/platform-browser/testing/browser_util'; import {el} from '@angular/platform-browser/testing/browser_util';

View File

@ -1065,15 +1065,15 @@ Reference "#a" is defined several times ("<div #a></div><div [ERROR ->]#a></div>
type: type:
new CompileTypeMetadata({moduleUrl: someModuleUrl, name: `SomeComp${compCounter++}`}), new CompileTypeMetadata({moduleUrl: someModuleUrl, name: `SomeComp${compCounter++}`}),
template: new CompileTemplateMetadata({ngContentSelectors: ngContentSelectors}) template: new CompileTemplateMetadata({ngContentSelectors: ngContentSelectors})
}) });
} }
function createDir(selector: string): CompileDirectiveMetadata { function createDir(selector: string): CompileDirectiveMetadata {
return CompileDirectiveMetadata.create({ return CompileDirectiveMetadata.create({
selector: selector, selector: selector,
type: type: new CompileTypeMetadata(
new CompileTypeMetadata({moduleUrl: someModuleUrl, name: `SomeDir${compCounter++}`}) {moduleUrl: someModuleUrl, name: `SomeDir${compCounter++}`})
}) });
} }
describe('project text nodes', () => { describe('project text nodes', () => {

View File

@ -6,13 +6,11 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {beforeEach, ddescribe, xdescribe, describe, expect, iit, inject, beforeEachProviders, it, xit,} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, beforeEach, ddescribe, xdescribe, describe, expect, iit, inject, beforeEachProviders, it, xit,} from '@angular/core/testing/testing_internal';
import {TestComponentBuilder, ComponentFixtureAutoDetect, ComponentFixtureNoNgZone, withProviders} from '@angular/core/testing'; import {TestComponentBuilder, ComponentFixtureAutoDetect, ComponentFixtureNoNgZone, withProviders} from '@angular/core/testing';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {Injectable, Component, Input, ViewMetadata} from '@angular/core'; import {Injectable, Component, Input, ViewMetadata} from '@angular/core';
import {NgIf} from '@angular/common'; import {NgIf} from '@angular/common';
import {TimerWrapper} from '../src/facade/async'; import {TimerWrapper} from '../src/facade/async';
import {IS_DART} from '../src/facade/lang';
import {PromiseWrapper} from '../src/facade/promise'; import {PromiseWrapper} from '../src/facade/promise';
import {dispatchEvent} from '@angular/platform-browser/testing/browser_util'; import {dispatchEvent} from '@angular/platform-browser/testing/browser_util';
@ -328,291 +326,289 @@ export function main() {
expect(componentFixture.nativeElement).toHaveText('Mock'); expect(componentFixture.nativeElement).toHaveText('Mock');
})); }));
if (!IS_DART) { describe('ComponentFixture', () => {
describe('ComponentFixture', () => { it('should auto detect changes if autoDetectChanges is called',
it('should auto detect changes if autoDetectChanges is called', inject(
inject( [TestComponentBuilder, AsyncTestCompleter],
[TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.createAsync(AutoDetectComp).then((componentFixture) => { tcb.createAsync(AutoDetectComp).then((componentFixture) => {
expect(componentFixture.ngZone).not.toBeNull(); expect(componentFixture.ngZone).not.toBeNull();
componentFixture.autoDetectChanges(); componentFixture.autoDetectChanges();
expect(componentFixture.nativeElement).toHaveText('1');
let element = componentFixture.debugElement.children[0];
dispatchEvent(element.nativeElement, 'click');
expect(componentFixture.isStable()).toBe(true);
expect(componentFixture.nativeElement).toHaveText('11');
async.done();
});
}));
it('should auto detect changes if ComponentFixtureAutoDetect is provided as true',
withProviders(() => [{provide: ComponentFixtureAutoDetect, useValue: true}])
.inject(
[TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.createAsync(AutoDetectComp).then((componentFixture) => {
expect(componentFixture.nativeElement).toHaveText('1');
let element = componentFixture.debugElement.children[0];
dispatchEvent(element.nativeElement, 'click');
expect(componentFixture.nativeElement).toHaveText('11');
async.done();
});
}));
it('should signal through whenStable when the fixture is stable (autoDetectChanges)',
inject(
[TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.createAsync(AsyncComp).then((componentFixture) => {
componentFixture.autoDetectChanges();
expect(componentFixture.nativeElement).toHaveText('1');
let element = componentFixture.debugElement.children[0];
dispatchEvent(element.nativeElement, 'click');
expect(componentFixture.nativeElement).toHaveText('1');
// Component is updated asynchronously. Wait for the fixture to become stable
// before checking for new value.
expect(componentFixture.isStable()).toBe(false);
componentFixture.whenStable().then((waited) => {
expect(waited).toBe(true);
expect(componentFixture.nativeElement).toHaveText('11');
async.done();
});
});
}));
it('should signal through isStable when the fixture is stable (no autoDetectChanges)',
inject(
[TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.createAsync(AsyncComp).then((componentFixture) => {
componentFixture.detectChanges();
expect(componentFixture.nativeElement).toHaveText('1');
let element = componentFixture.debugElement.children[0];
dispatchEvent(element.nativeElement, 'click');
expect(componentFixture.nativeElement).toHaveText('1');
// Component is updated asynchronously. Wait for the fixture to become stable
// before checking.
componentFixture.whenStable().then((waited) => {
expect(waited).toBe(true);
componentFixture.detectChanges();
expect(componentFixture.nativeElement).toHaveText('11');
async.done();
});
});
}));
it('should wait for macroTask(setTimeout) while checking for whenStable ' +
'(autoDetectChanges)',
inject(
[TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.createAsync(AsyncTimeoutComp).then((componentFixture) => {
componentFixture.autoDetectChanges();
expect(componentFixture.nativeElement).toHaveText('1');
let element = componentFixture.debugElement.children[0];
dispatchEvent(element.nativeElement, 'click');
expect(componentFixture.nativeElement).toHaveText('1');
// Component is updated asynchronously. Wait for the fixture to become
// stable before checking for new value.
expect(componentFixture.isStable()).toBe(false);
componentFixture.whenStable().then((waited) => {
expect(waited).toBe(true);
expect(componentFixture.nativeElement).toHaveText('11');
async.done();
});
});
}));
it('should wait for macroTask(setTimeout) while checking for whenStable ' +
'(no autoDetectChanges)',
inject(
[TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.createAsync(AsyncTimeoutComp).then((componentFixture) => {
componentFixture.detectChanges();
expect(componentFixture.nativeElement).toHaveText('1');
let element = componentFixture.debugElement.children[0];
dispatchEvent(element.nativeElement, 'click');
expect(componentFixture.nativeElement).toHaveText('1');
// Component is updated asynchronously. Wait for the fixture to become
// stable before checking for new value.
expect(componentFixture.isStable()).toBe(false);
componentFixture.whenStable().then((waited) => {
expect(waited).toBe(true);
componentFixture.detectChanges();
expect(componentFixture.nativeElement).toHaveText('11');
async.done();
});
});
}));
it('should wait for nested macroTasks(setTimeout) while checking for whenStable ' +
'(autoDetectChanges)',
inject(
[TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.createAsync(NestedAsyncTimeoutComp).then((componentFixture) => {
componentFixture.autoDetectChanges();
expect(componentFixture.nativeElement).toHaveText('1');
let element = componentFixture.debugElement.children[0];
dispatchEvent(element.nativeElement, 'click');
expect(componentFixture.nativeElement).toHaveText('1');
// Component is updated asynchronously. Wait for the fixture to become
// stable before checking for new value.
expect(componentFixture.isStable()).toBe(false);
componentFixture.whenStable().then((waited) => {
expect(waited).toBe(true);
expect(componentFixture.nativeElement).toHaveText('11');
async.done();
});
});
}));
it('should wait for nested macroTasks(setTimeout) while checking for whenStable ' +
'(no autoDetectChanges)',
inject(
[TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.createAsync(NestedAsyncTimeoutComp).then((componentFixture) => {
componentFixture.detectChanges();
expect(componentFixture.nativeElement).toHaveText('1');
let element = componentFixture.debugElement.children[0];
dispatchEvent(element.nativeElement, 'click');
expect(componentFixture.nativeElement).toHaveText('1');
// Component is updated asynchronously. Wait for the fixture to become
// stable before checking for new value.
expect(componentFixture.isStable()).toBe(false);
componentFixture.whenStable().then((waited) => {
expect(waited).toBe(true);
componentFixture.detectChanges();
expect(componentFixture.nativeElement).toHaveText('11');
async.done();
});
});
}));
it('should stabilize after async task in change detection (autoDetectChanges)',
inject(
[TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.createAsync(AsyncChangeComp).then((componentFixture) => {
componentFixture.autoDetectChanges();
componentFixture.whenStable().then((_) => {
expect(componentFixture.nativeElement).toHaveText('1'); expect(componentFixture.nativeElement).toHaveText('1');
let element = componentFixture.debugElement.children[0]; let element = componentFixture.debugElement.children[0];
dispatchEvent(element.nativeElement, 'click'); dispatchEvent(element.nativeElement, 'click');
expect(componentFixture.isStable()).toBe(true); componentFixture.whenStable().then((_) => {
expect(componentFixture.nativeElement).toHaveText('11'); expect(componentFixture.nativeElement).toHaveText('11');
async.done();
});
});
});
}));
it('should stabilize after async task in change detection(no autoDetectChanges)',
inject(
[TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.createAsync(AsyncChangeComp).then((componentFixture) => {
componentFixture.detectChanges();
componentFixture.whenStable().then((_) => {
// Run detectChanges again so that stabilized value is reflected in the
// DOM.
componentFixture.detectChanges();
expect(componentFixture.nativeElement).toHaveText('1');
let element = componentFixture.debugElement.children[0];
dispatchEvent(element.nativeElement, 'click');
componentFixture.detectChanges();
componentFixture.whenStable().then((_) => {
// Run detectChanges again so that stabilized value is reflected in
// the DOM.
componentFixture.detectChanges();
expect(componentFixture.nativeElement).toHaveText('11');
async.done();
});
});
});
}));
describe('No NgZone', () => {
beforeEachProviders(() => [{provide: ComponentFixtureNoNgZone, useValue: true}]);
it('calling autoDetectChanges raises an error', () => {
inject(
[TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.createAsync(ChildComp).then((componentFixture) => {
expect(() => { componentFixture.autoDetectChanges(); })
.toThrow(
'Cannot call autoDetectChanges when ComponentFixtureNoNgZone is set!!');
async.done();
});
});
});
it('should instantiate a component with valid DOM',
inject(
[TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.createAsync(ChildComp).then((componentFixture) => {
expect(componentFixture.ngZone).toBeNull();
componentFixture.detectChanges();
expect(componentFixture.nativeElement).toHaveText('Original Child');
async.done(); async.done();
}); });
})); }));
it('should auto detect changes if ComponentFixtureAutoDetect is provided as true', it('should allow changing members of the component',
withProviders(() => [{provide: ComponentFixtureAutoDetect, useValue: true}])
.inject(
[TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.createAsync(AutoDetectComp).then((componentFixture) => {
expect(componentFixture.nativeElement).toHaveText('1');
let element = componentFixture.debugElement.children[0];
dispatchEvent(element.nativeElement, 'click');
expect(componentFixture.nativeElement).toHaveText('11');
async.done();
});
}));
it('should signal through whenStable when the fixture is stable (autoDetectChanges)',
inject( inject(
[TestComponentBuilder, AsyncTestCompleter], [TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => { (tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.createAsync(AsyncComp).then((componentFixture) => { tcb.createAsync(MyIfComp).then((componentFixture) => {
componentFixture.autoDetectChanges();
expect(componentFixture.nativeElement).toHaveText('1');
let element = componentFixture.debugElement.children[0];
dispatchEvent(element.nativeElement, 'click');
expect(componentFixture.nativeElement).toHaveText('1');
// Component is updated asynchronously. Wait for the fixture to become stable
// before checking for new value.
expect(componentFixture.isStable()).toBe(false);
componentFixture.whenStable().then((waited) => {
expect(waited).toBe(true);
expect(componentFixture.nativeElement).toHaveText('11');
async.done();
});
});
}));
it('should signal through isStable when the fixture is stable (no autoDetectChanges)',
inject(
[TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.createAsync(AsyncComp).then((componentFixture) => {
componentFixture.detectChanges(); componentFixture.detectChanges();
expect(componentFixture.nativeElement).toHaveText('1'); expect(componentFixture.nativeElement).toHaveText('MyIf()');
let element = componentFixture.debugElement.children[0]; componentFixture.componentInstance.showMore = true;
dispatchEvent(element.nativeElement, 'click');
expect(componentFixture.nativeElement).toHaveText('1');
// Component is updated asynchronously. Wait for the fixture to become stable
// before checking.
componentFixture.whenStable().then((waited) => {
expect(waited).toBe(true);
componentFixture.detectChanges();
expect(componentFixture.nativeElement).toHaveText('11');
async.done();
});
});
}));
it('should wait for macroTask(setTimeout) while checking for whenStable ' +
'(autoDetectChanges)',
inject(
[TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.createAsync(AsyncTimeoutComp).then((componentFixture) => {
componentFixture.autoDetectChanges();
expect(componentFixture.nativeElement).toHaveText('1');
let element = componentFixture.debugElement.children[0];
dispatchEvent(element.nativeElement, 'click');
expect(componentFixture.nativeElement).toHaveText('1');
// Component is updated asynchronously. Wait for the fixture to become
// stable before checking for new value.
expect(componentFixture.isStable()).toBe(false);
componentFixture.whenStable().then((waited) => {
expect(waited).toBe(true);
expect(componentFixture.nativeElement).toHaveText('11');
async.done();
});
});
}));
it('should wait for macroTask(setTimeout) while checking for whenStable ' +
'(no autoDetectChanges)',
inject(
[TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.createAsync(AsyncTimeoutComp).then((componentFixture) => {
componentFixture.detectChanges(); componentFixture.detectChanges();
expect(componentFixture.nativeElement).toHaveText('1'); expect(componentFixture.nativeElement).toHaveText('MyIf(More)');
let element = componentFixture.debugElement.children[0]; async.done();
dispatchEvent(element.nativeElement, 'click');
expect(componentFixture.nativeElement).toHaveText('1');
// Component is updated asynchronously. Wait for the fixture to become
// stable before checking for new value.
expect(componentFixture.isStable()).toBe(false);
componentFixture.whenStable().then((waited) => {
expect(waited).toBe(true);
componentFixture.detectChanges();
expect(componentFixture.nativeElement).toHaveText('11');
async.done();
});
}); });
})); }));
it('should wait for nested macroTasks(setTimeout) while checking for whenStable ' +
'(autoDetectChanges)',
inject(
[TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.createAsync(NestedAsyncTimeoutComp).then((componentFixture) => {
componentFixture.autoDetectChanges();
expect(componentFixture.nativeElement).toHaveText('1');
let element = componentFixture.debugElement.children[0];
dispatchEvent(element.nativeElement, 'click');
expect(componentFixture.nativeElement).toHaveText('1');
// Component is updated asynchronously. Wait for the fixture to become
// stable before checking for new value.
expect(componentFixture.isStable()).toBe(false);
componentFixture.whenStable().then((waited) => {
expect(waited).toBe(true);
expect(componentFixture.nativeElement).toHaveText('11');
async.done();
});
});
}));
it('should wait for nested macroTasks(setTimeout) while checking for whenStable ' +
'(no autoDetectChanges)',
inject(
[TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.createAsync(NestedAsyncTimeoutComp).then((componentFixture) => {
componentFixture.detectChanges();
expect(componentFixture.nativeElement).toHaveText('1');
let element = componentFixture.debugElement.children[0];
dispatchEvent(element.nativeElement, 'click');
expect(componentFixture.nativeElement).toHaveText('1');
// Component is updated asynchronously. Wait for the fixture to become
// stable before checking for new value.
expect(componentFixture.isStable()).toBe(false);
componentFixture.whenStable().then((waited) => {
expect(waited).toBe(true);
componentFixture.detectChanges();
expect(componentFixture.nativeElement).toHaveText('11');
async.done();
});
});
}));
it('should stabilize after async task in change detection (autoDetectChanges)',
inject(
[TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.createAsync(AsyncChangeComp).then((componentFixture) => {
componentFixture.autoDetectChanges();
componentFixture.whenStable().then((_) => {
expect(componentFixture.nativeElement).toHaveText('1');
let element = componentFixture.debugElement.children[0];
dispatchEvent(element.nativeElement, 'click');
componentFixture.whenStable().then((_) => {
expect(componentFixture.nativeElement).toHaveText('11');
async.done();
});
});
});
}));
it('should stabilize after async task in change detection(no autoDetectChanges)',
inject(
[TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.createAsync(AsyncChangeComp).then((componentFixture) => {
componentFixture.detectChanges();
componentFixture.whenStable().then((_) => {
// Run detectChanges again so that stabilized value is reflected in the
// DOM.
componentFixture.detectChanges();
expect(componentFixture.nativeElement).toHaveText('1');
let element = componentFixture.debugElement.children[0];
dispatchEvent(element.nativeElement, 'click');
componentFixture.detectChanges();
componentFixture.whenStable().then((_) => {
// Run detectChanges again so that stabilized value is reflected in
// the DOM.
componentFixture.detectChanges();
expect(componentFixture.nativeElement).toHaveText('11');
async.done();
});
});
});
}));
describe('No NgZone', () => {
beforeEachProviders(() => [{provide: ComponentFixtureNoNgZone, useValue: true}]);
it('calling autoDetectChanges raises an error', () => {
inject(
[TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.createAsync(ChildComp).then((componentFixture) => {
expect(() => { componentFixture.autoDetectChanges(); })
.toThrow(
'Cannot call autoDetectChanges when ComponentFixtureNoNgZone is set!!');
async.done();
});
});
});
it('should instantiate a component with valid DOM',
inject(
[TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.createAsync(ChildComp).then((componentFixture) => {
expect(componentFixture.ngZone).toBeNull();
componentFixture.detectChanges();
expect(componentFixture.nativeElement).toHaveText('Original Child');
async.done();
});
}));
it('should allow changing members of the component',
inject(
[TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.createAsync(MyIfComp).then((componentFixture) => {
componentFixture.detectChanges();
expect(componentFixture.nativeElement).toHaveText('MyIf()');
componentFixture.componentInstance.showMore = true;
componentFixture.detectChanges();
expect(componentFixture.nativeElement).toHaveText('MyIf(More)');
async.done();
});
}));
});
}); });
}
});
}); });
} }

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {fakeAsync, flushMicrotasks} from '@angular/core/testing/fake_async'; import {fakeAsync} from '@angular/core/testing/fake_async';
import {beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xit} from '@angular/core/testing/testing_internal'; import {beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xit} from '@angular/core/testing/testing_internal';
import {SyncAsyncResult} from '../src/util'; import {SyncAsyncResult} from '../src/util';
@ -20,5 +20,5 @@ export function main() {
sar.asyncResult.then((v: any) => expect(v).toBe(syncValue)); sar.asyncResult.then((v: any) => expect(v).toBe(syncValue));
})); }));
}); });
}) });
} }

View File

@ -8,10 +8,9 @@
import {beforeEach, ddescribe, describe, expect, iit, it, inject,} from '@angular/core/testing/testing_internal'; import {beforeEach, ddescribe, describe, expect, iit, it, inject,} from '@angular/core/testing/testing_internal';
import {stringify} from '../src/facade/lang'; import {stringify, isBlank} from '../src/facade/lang';
import {MockViewResolver} from '../testing'; import {MockViewResolver} from '../testing';
import {Component, ViewMetadata, Injector} from '@angular/core'; import {Component, ViewMetadata, Injector} from '@angular/core';
import {isBlank} from '../src/facade/lang';
export function main() { export function main() {
describe('MockViewResolver', () => { describe('MockViewResolver', () => {

View File

@ -6,8 +6,7 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {beforeEach, ddescribe, describe, expect, iit, inject, it,} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, beforeEach, ddescribe, describe, expect, iit, inject, it,} from '@angular/core/testing/testing_internal';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {MockXHR} from '@angular/compiler/testing/xhr_mock'; import {MockXHR} from '@angular/compiler/testing/xhr_mock';
import {PromiseWrapper} from '../src/facade/async'; import {PromiseWrapper} from '../src/facade/async';
import {isPresent} from '../src/facade/lang'; import {isPresent} from '../src/facade/lang';
@ -19,8 +18,7 @@ export function main() {
beforeEach(() => { xhr = new MockXHR(); }); beforeEach(() => { xhr = new MockXHR(); });
function expectResponse( function expectResponse(
request: Promise<string>, url: string, response: string, request: Promise<string>, url: string, response: string, done: () => void = null) {
done: any /** TODO #9100 */ = null) {
function onResponse(text: string): string { function onResponse(text: string): string {
if (response === null) { if (response === null) {
throw `Unexpected response ${url} -> ${text}`; throw `Unexpected response ${url} -> ${text}`;

View File

@ -7,7 +7,6 @@
*/ */
import {AnimationGroupPlayer} from '../../src/animation/animation_group_player'; import {AnimationGroupPlayer} from '../../src/animation/animation_group_player';
import {isPresent} from '../../src/facade/lang';
import {fakeAsync, flushMicrotasks} from '../../testing'; import {fakeAsync, flushMicrotasks} from '../../testing';
import {MockAnimationPlayer} from '../../testing/mock_animation_player'; import {MockAnimationPlayer} from '../../testing/mock_animation_player';
import {AsyncTestCompleter, beforeEach, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '../../testing/testing_internal'; import {AsyncTestCompleter, beforeEach, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '../../testing/testing_internal';
@ -32,7 +31,7 @@ export function main() {
} else { } else {
expect(actual).not.toEqual(status); expect(actual).not.toEqual(status);
} }
} };
var assertPlaying = (player: MockAnimationPlayer, isPlaying: boolean) => { var assertPlaying = (player: MockAnimationPlayer, isPlaying: boolean) => {
assertLastStatus(player, 'play', isPlaying); assertLastStatus(player, 'play', isPlaying);

View File

@ -7,7 +7,6 @@
*/ */
import {NgIf} from '@angular/common'; import {NgIf} from '@angular/common';
import {CompilerConfig} from '@angular/compiler';
import {TestComponentBuilder} from '@angular/core/testing'; import {TestComponentBuilder} from '@angular/core/testing';
import {AnimationDriver} from '@angular/platform-browser/src/dom/animation_driver'; import {AnimationDriver} from '@angular/platform-browser/src/dom/animation_driver';
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter'; import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
@ -19,20 +18,15 @@ import {DEFAULT_STATE} from '../../src/animation/animation_constants';
import {AnimationKeyframe} from '../../src/animation/animation_keyframe'; import {AnimationKeyframe} from '../../src/animation/animation_keyframe';
import {AnimationPlayer} from '../../src/animation/animation_player'; import {AnimationPlayer} from '../../src/animation/animation_player';
import {AnimationStyles} from '../../src/animation/animation_styles'; import {AnimationStyles} from '../../src/animation/animation_styles';
import {AnimationEntryMetadata, animate, group, keyframes, sequence, state, style, transition, trigger} from '../../src/animation/metadata'; import {AUTO_STYLE, AnimationEntryMetadata, animate, group, keyframes, sequence, state, style, transition, trigger} from '../../src/animation/metadata';
import {AUTO_STYLE} from '../../src/animation/metadata'; import {isArray, isPresent} from '../../src/facade/lang';
import {IS_DART, isArray, isPresent} from '../../src/facade/lang';
import {configureCompiler, configureModule, fakeAsync, flushMicrotasks, tick} from '../../testing'; import {configureCompiler, configureModule, fakeAsync, flushMicrotasks, tick} from '../../testing';
import {MockAnimationPlayer} from '../../testing/mock_animation_player'; import {MockAnimationPlayer} from '../../testing/mock_animation_player';
import {AsyncTestCompleter, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '../../testing/testing_internal'; import {AsyncTestCompleter, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '../../testing/testing_internal';
export function main() { export function main() {
if (IS_DART) { describe('jit', () => { declareTests({useJit: true}); });
declareTests({useJit: false}); describe('no jit', () => { declareTests({useJit: false}); });
} else {
describe('jit', () => { declareTests({useJit: true}); });
describe('no jit', () => { declareTests({useJit: false}); });
}
} }
function declareTests({useJit}: {useJit: boolean}) { function declareTests({useJit}: {useJit: boolean}) {
@ -254,18 +248,17 @@ function declareTests({useJit}: {useJit: boolean}) {
}))); })));
describe('groups/sequences', () => { describe('groups/sequences', () => {
var assertPlaying = var assertPlaying = (player: MockAnimationDriver, isPlaying: any /** TODO #9100 */) => {
(player: MockAnimationDriver, isPlaying: any /** TODO #9100 */) => { var method = 'play';
var method = 'play'; var lastEntry = player.log.length > 0 ? player.log[player.log.length - 1] : null;
var lastEntry = player.log.length > 0 ? player.log[player.log.length - 1] : null; if (isPresent(lastEntry)) {
if (isPresent(lastEntry)) { if (isPlaying) {
if (isPlaying) { expect(lastEntry).toEqual(method);
expect(lastEntry).toEqual(method); } else {
} else { expect(lastEntry).not.toEqual(method);
expect(lastEntry).not.toEqual(method);
}
}
} }
}
};
it('should run animations in sequence one by one if a top-level array is used', it('should run animations in sequence one by one if a top-level array is used',
inject( inject(

View File

@ -32,7 +32,7 @@ export function main() {
} else { } else {
expect(actual).not.toEqual(status); expect(actual).not.toEqual(status);
} }
} };
var assertPlaying = (player: MockAnimationPlayer, isPlaying: boolean) => { var assertPlaying = (player: MockAnimationPlayer, isPlaying: boolean) => {
assertLastStatus(player, 'play', isPlaying); assertLastStatus(player, 'play', isPlaying);

View File

@ -23,7 +23,7 @@ export function main() {
var newStyles = {background: 'red'}; var newStyles = {background: 'red'};
var flag = '*'; var flag = '*';
var result = animationUtils.prepareFinalAnimationStyles(styles, newStyles, flag); var result = animationUtils.prepareFinalAnimationStyles(styles, newStyles, flag);
expect(result).toEqual({opacity: flag, color: flag, background: 'red'}) expect(result).toEqual({opacity: flag, color: flag, background: 'red'});
}); });
it('should handle an empty set of styles', () => { it('should handle an empty set of styles', () => {
@ -43,7 +43,7 @@ export function main() {
var newStyles = {color: '*', border: '*'}; var newStyles = {color: '*', border: '*'};
var flag = '*'; var flag = '*';
var result = animationUtils.prepareFinalAnimationStyles(styles, newStyles, null); var result = animationUtils.prepareFinalAnimationStyles(styles, newStyles, null);
expect(result).toEqual({opacity: null, color: null, border: null}) expect(result).toEqual({opacity: null, color: null, border: null});
}); });
}); });

View File

@ -6,12 +6,10 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {ddescribe, describe, it, iit, xit, expect, beforeEach, afterEach, inject,} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, ddescribe, describe, it, iit, xit, expect, beforeEach, afterEach, inject,} from '@angular/core/testing/testing_internal';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {Type} from '@angular/core';
import {SpyChangeDetectorRef} from './spies'; import {SpyChangeDetectorRef} from './spies';
import {ApplicationRef_, ApplicationRef, PLATFORM_CORE_PROVIDERS, APPLICATION_CORE_PROVIDERS} from '@angular/core/src/application_ref'; import {ApplicationRef_, ApplicationRef, PLATFORM_CORE_PROVIDERS, APPLICATION_CORE_PROVIDERS} from '@angular/core/src/application_ref';
import {Injector, APP_INITIALIZER, Component, ReflectiveInjector, coreLoadAndBootstrap, PlatformRef, createPlatform, disposePlatform, ComponentResolver, ComponentFactoryResolver, ChangeDetectorRef} from '@angular/core'; import {Type, Injector, APP_INITIALIZER, Component, ReflectiveInjector, coreLoadAndBootstrap, PlatformRef, createPlatform, disposePlatform, ComponentResolver, ComponentFactoryResolver, ChangeDetectorRef} from '@angular/core';
import {Console} from '@angular/core/src/console'; import {Console} from '@angular/core/src/console';
import {BaseException} from '../src/facade/exceptions'; import {BaseException} from '../src/facade/exceptions';
import {PromiseWrapper, PromiseCompleter, TimerWrapper} from '../src/facade/async'; import {PromiseWrapper, PromiseCompleter, TimerWrapper} from '../src/facade/async';

View File

@ -17,13 +17,13 @@ import {iterableChangesAsString} from '../../change_detection/util';
class ItemWithId { class ItemWithId {
constructor(private id: string) {} constructor(private id: string) {}
toString() { return `{id: ${this.id}}` } toString() { return `{id: ${this.id}}`; }
} }
class ComplexItem { class ComplexItem {
constructor(private id: string, private color: string) {} constructor(private id: string, private color: string) {}
toString() { return `{id: ${this.id}, color: ${this.color}}` } toString() { return `{id: ${this.id}, color: ${this.color}}`; }
} }
// todo(vicb): UnmodifiableListView / frozen object when implemented // todo(vicb): UnmodifiableListView / frozen object when implemented
@ -328,7 +328,7 @@ export function main() {
var trackByItemId = (index: number, item: any): any => item.id; var trackByItemId = (index: number, item: any): any => item.id;
var buildItemList = var buildItemList =
(list: string[]) => { return list.map((val) => {return new ItemWithId(val)}) }; (list: string[]) => { return list.map((val) => { return new ItemWithId(val); }); };
beforeEach(() => { differ = new DefaultIterableDiffer(trackByItemId); }); beforeEach(() => { differ = new DefaultIterableDiffer(trackByItemId); });

View File

@ -6,13 +6,12 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {beforeEach, ddescribe, xdescribe, describe, expect, iit, inject, beforeEachProviders, it, xit,} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, beforeEach, ddescribe, xdescribe, describe, expect, iit, inject, beforeEachProviders, it, xit,} from '@angular/core/testing/testing_internal';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {TestComponentBuilder} from '@angular/core/testing'; import {TestComponentBuilder} from '@angular/core/testing';
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter'; import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
import {PromiseWrapper, EventEmitter, ObservableWrapper} from '../../src/facade/async'; import {EventEmitter} from '../../src/facade/async';
import {Injectable} from '@angular/core'; import {Injectable} from '@angular/core';
import {NgFor, NgIf} from '@angular/common'; import {NgFor, NgIf} from '@angular/common';

View File

@ -14,12 +14,14 @@ import {IS_DART} from '../../src/facade/lang';
export function main() { export function main() {
describe('Injector.NULL', () => { describe('Injector.NULL', () => {
it('should throw if no arg is given', () => {expect(() => Injector.NULL.get('someToken')) it('should throw if no arg is given', () => {
.toThrowError('No provider for someToken!')}); expect(() => Injector.NULL.get('someToken')).toThrowError('No provider for someToken!');
});
it('should throw if THROW_IF_NOT_FOUND is given', it('should throw if THROW_IF_NOT_FOUND is given', () => {
() => {expect(() => Injector.NULL.get('someToken', Injector.THROW_IF_NOT_FOUND)) expect(() => Injector.NULL.get('someToken', Injector.THROW_IF_NOT_FOUND))
.toThrowError('No provider for someToken!')}); .toThrowError('No provider for someToken!');
});
it('should return the default value', it('should return the default value',
() => { expect(Injector.NULL.get('someToken', 'notFound')).toEqual('notFound'); }); () => { expect(Injector.NULL.get('someToken', 'notFound')).toEqual('notFound'); });

View File

@ -9,8 +9,7 @@
import {AfterContentChecked, AfterContentInit, AfterViewChecked, AfterViewInit, DoCheck, OnChanges, OnInit} from '@angular/core'; import {AfterContentChecked, AfterContentInit, AfterViewChecked, AfterViewInit, DoCheck, OnChanges, OnInit} from '@angular/core';
import {Component, Directive, ViewMetadata} from '@angular/core/src/metadata'; import {Component, Directive, ViewMetadata} from '@angular/core/src/metadata';
import {TestComponentBuilder} from '@angular/core/testing'; import {TestComponentBuilder} from '@angular/core/testing';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, Log, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal';
import {Log, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal';
export function main() { export function main() {
describe('directive lifecycle integration spec', () => { describe('directive lifecycle integration spec', () => {

View File

@ -6,10 +6,9 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {beforeEach, ddescribe, describe, expect, iit, inject, it, xit} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, beforeEach, ddescribe, describe, expect, iit, inject, it, xit} from '@angular/core/testing/testing_internal';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {EventEmitter, Observable, PromiseWrapper, Subject} from '../../src/facade/async'; import {Observable} from '../../src/facade/async';
export function main() { export function main() {
describe('Observable', () => { describe('Observable', () => {

View File

@ -107,7 +107,7 @@ export function main() {
describe('timers', () => { describe('timers', () => {
it('should run queued zero duration timer on zero tick', fakeAsync(() => { it('should run queued zero duration timer on zero tick', fakeAsync(() => {
var ran = false; var ran = false;
TimerWrapper.setTimeout(() => {ran = true}, 0); TimerWrapper.setTimeout(() => { ran = true; }, 0);
expect(ran).toEqual(false); expect(ran).toEqual(false);

View File

@ -7,11 +7,9 @@
*/ */
import {NgFor} from '@angular/common'; import {NgFor} from '@angular/common';
import {Component, Directive, Inject, Query, QueryList, bind, forwardRef, provide, resolveForwardRef} from '@angular/core'; import {Component, Directive, Inject, Query, QueryList, asNativeElements, bind, forwardRef, provide, resolveForwardRef} from '@angular/core';
import {asNativeElements} from '@angular/core';
import {TestComponentBuilder} from '@angular/core/testing'; import {TestComponentBuilder} from '@angular/core/testing';
import {beforeEach, ddescribe, describe, expect, iit, inject, it, xit} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, beforeEach, ddescribe, describe, expect, iit, inject, it, xit} from '@angular/core/testing/testing_internal';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
export function main() { export function main() {
describe('forwardRef integration', function() { describe('forwardRef integration', function() {

View File

@ -1,5 +1,11 @@
import {LowerCasePipe, NgIf} from '@angular/common'; /**
import {CompilerConfig} from '@angular/compiler'; * @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {ANALYZE_FOR_PRECOMPILE, AppModule, AppModuleMetadata, Compiler, Component, ComponentFactoryResolver, ComponentRef, ComponentResolver, DebugElement, Directive, Host, Inject, Injectable, Injector, Input, OpaqueToken, Optional, Pipe, Provider, ReflectiveInjector, SelfMetadata, SkipSelf, SkipSelfMetadata, forwardRef, getDebugNode, provide} from '@angular/core'; import {ANALYZE_FOR_PRECOMPILE, AppModule, AppModuleMetadata, Compiler, Component, ComponentFactoryResolver, ComponentRef, ComponentResolver, DebugElement, Directive, Host, Inject, Injectable, Injector, Input, OpaqueToken, Optional, Pipe, Provider, ReflectiveInjector, SelfMetadata, SkipSelf, SkipSelfMetadata, forwardRef, getDebugNode, provide} from '@angular/core';
import {ComponentFixture, configureCompiler} from '@angular/core/testing'; import {ComponentFixture, configureCompiler} from '@angular/core/testing';
import {AsyncTestCompleter, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal';

View File

@ -12,8 +12,7 @@ import {TEST_COMPILER_PROVIDERS} from '@angular/compiler/test/test_bindings';
import {MockSchemaRegistry} from '@angular/compiler/testing'; import {MockSchemaRegistry} from '@angular/compiler/testing';
import {AfterContentChecked, AfterContentInit, AfterViewChecked, AfterViewInit, ChangeDetectionStrategy, ChangeDetectorRef, Component, DebugElement, Directive, DoCheck, Injectable, Input, OnChanges, OnDestroy, OnInit, Output, Pipe, PipeTransform, RenderComponentType, Renderer, RootRenderer, SimpleChange, SimpleChanges, TemplateRef, ViewContainerRef, ViewMetadata, WrappedValue, forwardRef} from '@angular/core'; import {AfterContentChecked, AfterContentInit, AfterViewChecked, AfterViewInit, ChangeDetectionStrategy, ChangeDetectorRef, Component, DebugElement, Directive, DoCheck, Injectable, Input, OnChanges, OnDestroy, OnInit, Output, Pipe, PipeTransform, RenderComponentType, Renderer, RootRenderer, SimpleChange, SimpleChanges, TemplateRef, ViewContainerRef, ViewMetadata, WrappedValue, forwardRef} from '@angular/core';
import {DebugDomRenderer} from '@angular/core/src/debug/debug_renderer'; import {DebugDomRenderer} from '@angular/core/src/debug/debug_renderer';
import {TestComponentBuilder} from '@angular/core/testing'; import {ComponentFixture, TestComponentBuilder, configureCompiler, configureModule, fakeAsync, flushMicrotasks, tick} from '@angular/core/testing';
import {ComponentFixture, configureCompiler, configureModule, fakeAsync, flushMicrotasks, tick} from '@angular/core/testing';
import {afterEach, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xit} from '@angular/core/testing/testing_internal'; import {afterEach, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xit} from '@angular/core/testing/testing_internal';
import {By} from '@angular/platform-browser/src/dom/debug/by'; import {By} from '@angular/platform-browser/src/dom/debug/by';
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter'; import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
@ -597,8 +596,9 @@ export function main() {
})); }));
it('should throw when trying to assign to a local', fakeAsync(() => { it('should throw when trying to assign to a local', fakeAsync(() => {
expect(() => {_bindSimpleProp('(event)="$event=1"')}) expect(() => {
.toThrowError(new RegExp('Cannot assign to a reference or variable!')); _bindSimpleProp('(event)="$event=1"');
}).toThrowError(new RegExp('Cannot assign to a reference or variable!'));
})); }));
it('should support short-circuiting', fakeAsync(() => { it('should support short-circuiting', fakeAsync(() => {
@ -625,7 +625,7 @@ export function main() {
describe('reading directives', () => { describe('reading directives', () => {
it('should read directive properties', fakeAsync(() => { it('should read directive properties', fakeAsync(() => {
var ctx = createCompFixture( var ctx = createCompFixture(
'<div testDirective [a]="42" ref-dir="testDirective" [someProp]="dir.a"></div>') '<div testDirective [a]="42" ref-dir="testDirective" [someProp]="dir.a"></div>');
ctx.detectChanges(false); ctx.detectChanges(false);
expect(renderLog.loggedValues).toEqual([42]); expect(renderLog.loggedValues).toEqual([42]);
})); }));
@ -1479,7 +1479,7 @@ class Address {
set zipcode(v) { this._zipcode = v; } set zipcode(v) { this._zipcode = v; }
toString(): string { return isBlank(this.city) ? '-' : this.city } toString(): string { return this.city || '-'; }
} }
@Component({selector: 'root'}) @Component({selector: 'root'})

View File

@ -6,12 +6,11 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {beforeEach, ddescribe, xdescribe, describe, expect, iit, inject, beforeEachProviders, it, xit,} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, beforeEach, ddescribe, xdescribe, describe, expect, iit, inject, beforeEachProviders, it, xit,} from '@angular/core/testing/testing_internal';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {ComponentFixture, TestComponentBuilder} from '@angular/core/testing'; import {ComponentFixture, TestComponentBuilder} from '@angular/core/testing';
import {Predicate} from '../../src/facade/collection'; import {Predicate} from '../../src/facade/collection';
import {Injector, OnDestroy, DebugElement, Type, ViewContainerRef, ViewChild} from '@angular/core'; import {Injector, DebugElement, Type, ViewContainerRef, ViewChild} from '@angular/core';
import {Component, ViewMetadata} from '@angular/core/src/metadata'; import {Component} from '@angular/core/src/metadata';
import {DynamicComponentLoader} from '@angular/core/src/linker/dynamic_component_loader'; import {DynamicComponentLoader} from '@angular/core/src/linker/dynamic_component_loader';
import {ElementRef} from '@angular/core/src/linker/element_ref'; import {ElementRef} from '@angular/core/src/linker/element_ref';
import {DOCUMENT} from '@angular/platform-browser/src/dom/dom_tokens'; import {DOCUMENT} from '@angular/platform-browser/src/dom/dom_tokens';

View File

@ -6,9 +6,8 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {beforeEach, ddescribe, xdescribe, describe, expect, iit, inject, beforeEachProviders, it, xit,} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, beforeEach, ddescribe, xdescribe, describe, expect, iit, inject, beforeEachProviders, it, xit,} from '@angular/core/testing/testing_internal';
import {fakeAsync, tick, ComponentFixture, configureCompiler, configureModule, TestComponentBuilder} from '@angular/core/testing'; import {fakeAsync, tick, ComponentFixture, configureCompiler, configureModule, TestComponentBuilder} from '@angular/core/testing';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter'; import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
import {isPresent, stringify, isBlank,} from '../../src/facade/lang'; import {isPresent, stringify, isBlank,} from '../../src/facade/lang';
import {BaseException} from '../../src/facade/exceptions'; import {BaseException} from '../../src/facade/exceptions';
@ -34,19 +33,14 @@ import {ElementRef} from '@angular/core/src/linker/element_ref';
import {TemplateRef, TemplateRef_} from '@angular/core/src/linker/template_ref'; import {TemplateRef, TemplateRef_} from '@angular/core/src/linker/template_ref';
import {Renderer} from '@angular/core/src/render'; import {Renderer} from '@angular/core/src/render';
import {IS_DART} from '../../src/facade/lang';
import {el, dispatchEvent} from '@angular/platform-browser/testing/browser_util'; import {el, dispatchEvent} from '@angular/platform-browser/testing/browser_util';
const ANCHOR_ELEMENT = /*@ts2dart_const*/ new OpaqueToken('AnchorElement'); const ANCHOR_ELEMENT = /*@ts2dart_const*/ new OpaqueToken('AnchorElement');
export function main() { export function main() {
if (IS_DART) { describe('jit', () => { declareTests({useJit: true}); });
declareTests({useJit: false});
} else {
describe('jit', () => { declareTests({useJit: true}); });
describe('no jit', () => { declareTests({useJit: false}); }); describe('no jit', () => { declareTests({useJit: false}); });
}
} }
function declareTests({useJit}: {useJit: boolean}) { function declareTests({useJit}: {useJit: boolean}) {
@ -583,18 +577,18 @@ function declareTests({useJit}: {useJit: boolean}) {
inject( inject(
[TestComponentBuilder, AsyncTestCompleter], [TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => { (tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.overrideView(MyComp, new ViewMetadata({ tcb.overrideView(MyComp, new ViewMetadata({
template: '<p><child-cmp ref-alice></child-cmp></p>', template: '<p><child-cmp ref-alice></child-cmp></p>',
directives: [ChildComp] directives: [ChildComp]
})) }))
.createAsync(MyComp)
.then((fixture) => {
expect(fixture.debugElement.children[0].children[0].references['alice'])
.toBeAnInstanceOf(ChildComp);
.createAsync(MyComp) async.done();
.then((fixture) => { });
expect(fixture.debugElement.children[0].children[0].references['alice']) }));
.toBeAnInstanceOf(ChildComp);
async.done();
})}));
it('should assign a directive to a ref-', it('should assign a directive to a ref-',
inject( inject(
@ -604,7 +598,6 @@ function declareTests({useJit}: {useJit: boolean}) {
template: '<div><div export-dir #localdir="dir"></div></div>', template: '<div><div export-dir #localdir="dir"></div></div>',
directives: [ExportDir] directives: [ExportDir]
})) }))
.createAsync(MyComp) .createAsync(MyComp)
.then((fixture) => { .then((fixture) => {
expect(fixture.debugElement.children[0].children[0].references['localdir']) expect(fixture.debugElement.children[0].children[0].references['localdir'])
@ -618,97 +611,96 @@ function declareTests({useJit}: {useJit: boolean}) {
inject( inject(
[TestComponentBuilder, AsyncTestCompleter], [TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => { (tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.overrideView( tcb.overrideView(
MyComp, new ViewMetadata({ MyComp, new ViewMetadata({
template: template:
'<template [ngIf]="true">{{alice.ctxProp}}</template>|{{alice.ctxProp}}|<child-cmp ref-alice></child-cmp>', '<template [ngIf]="true">{{alice.ctxProp}}</template>|{{alice.ctxProp}}|<child-cmp ref-alice></child-cmp>',
directives: [ChildComp, NgIf] directives: [ChildComp, NgIf]
})) }))
.createAsync(MyComp)
.then((fixture) => {
fixture.detectChanges();
.createAsync(MyComp) expect(fixture.debugElement.nativeElement).toHaveText('hello|hello|hello');
.then((fixture) => { async.done();
fixture.detectChanges(); });
}));
expect(fixture.debugElement.nativeElement).toHaveText('hello|hello|hello');
async.done();
})}));
it('should assign two component instances each with a ref-', it('should assign two component instances each with a ref-',
inject( inject(
[TestComponentBuilder, AsyncTestCompleter], [TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => { (tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.overrideView( tcb.overrideView(
MyComp, new ViewMetadata({ MyComp, new ViewMetadata({
template: template:
'<p><child-cmp ref-alice></child-cmp><child-cmp ref-bob></child-cmp></p>', '<p><child-cmp ref-alice></child-cmp><child-cmp ref-bob></child-cmp></p>',
directives: [ChildComp] directives: [ChildComp]
})) }))
.createAsync(MyComp)
.then((fixture) => {
var pEl = fixture.debugElement.children[0];
.createAsync(MyComp) var alice = pEl.children[0].references['alice'];
.then((fixture) => { var bob = pEl.children[1].references['bob'];
var pEl = fixture.debugElement.children[0]; expect(alice).toBeAnInstanceOf(ChildComp);
expect(bob).toBeAnInstanceOf(ChildComp);
expect(alice).not.toBe(bob);
var alice = pEl.children[0].references['alice']; async.done();
var bob = pEl.children[1].references['bob']; });
expect(alice).toBeAnInstanceOf(ChildComp); }));
expect(bob).toBeAnInstanceOf(ChildComp);
expect(alice).not.toBe(bob);
async.done();
})}));
it('should assign the component instance to a ref- with shorthand syntax', it('should assign the component instance to a ref- with shorthand syntax',
inject( inject(
[TestComponentBuilder, AsyncTestCompleter], [TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => { (tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.overrideView(MyComp, new ViewMetadata({ tcb.overrideView(
template: '<child-cmp #alice></child-cmp>', MyComp,
directives: [ChildComp] new ViewMetadata(
})) {template: '<child-cmp #alice></child-cmp>', directives: [ChildComp]}))
.createAsync(MyComp)
.then((fixture) => {
.createAsync(MyComp) expect(fixture.debugElement.children[0].references['alice'])
.then((fixture) => { .toBeAnInstanceOf(ChildComp);
expect(fixture.debugElement.children[0].references['alice']) async.done();
.toBeAnInstanceOf(ChildComp); });
}));
async.done();
})}));
it('should assign the element instance to a user-defined variable', it('should assign the element instance to a user-defined variable',
inject( inject(
[TestComponentBuilder, AsyncTestCompleter], [TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => { (tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.overrideView( tcb.overrideView(
MyComp, new ViewMetadata( MyComp, new ViewMetadata(
{template: '<div><div ref-alice><i>Hello</i></div></div>'})) {template: '<div><div ref-alice><i>Hello</i></div></div>'}))
.createAsync(MyComp)
.then((fixture) => {
.createAsync(MyComp) var value = fixture.debugElement.children[0].children[0].references['alice'];
.then((fixture) => { expect(value).not.toBe(null);
expect(value.tagName.toLowerCase()).toEqual('div');
var value = async.done();
fixture.debugElement.children[0].children[0].references['alice']; });
expect(value).not.toBe(null); }));
expect(value.tagName.toLowerCase()).toEqual('div');
async.done();
})}));
it('should assign the TemplateRef to a user-defined variable', it('should assign the TemplateRef to a user-defined variable',
inject( inject(
[TestComponentBuilder, AsyncTestCompleter], [TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => { (tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.overrideView( tcb.overrideView(
MyComp, new ViewMetadata({template: '<template ref-alice></template>'})) MyComp, new ViewMetadata({template: '<template ref-alice></template>'}))
.createAsync(MyComp)
.then((fixture) => {
.createAsync(MyComp) var value = fixture.debugElement.childNodes[0].references['alice'];
.then((fixture) => { expect(value).toBeAnInstanceOf(TemplateRef_);
var value = fixture.debugElement.childNodes[0].references['alice']; async.done();
expect(value).toBeAnInstanceOf(TemplateRef_); });
}));
async.done();
})}));
it('should preserve case', it('should preserve case',
inject( inject(
@ -718,7 +710,6 @@ function declareTests({useJit}: {useJit: boolean}) {
template: '<p><child-cmp ref-superAlice></child-cmp></p>', template: '<p><child-cmp ref-superAlice></child-cmp></p>',
directives: [ChildComp] directives: [ChildComp]
})) }))
.createAsync(MyComp) .createAsync(MyComp)
.then((fixture) => { .then((fixture) => {
expect(fixture.debugElement.children[0].children[0].references['superAlice']) expect(fixture.debugElement.children[0].children[0].references['superAlice'])
@ -740,7 +731,6 @@ function declareTests({useJit}: {useJit: boolean}) {
'<template ngFor [ngForOf]="[1]" let-i><child-cmp-no-template #cmp></child-cmp-no-template>{{i}}-{{cmp.ctxProp}}</template>', '<template ngFor [ngForOf]="[1]" let-i><child-cmp-no-template #cmp></child-cmp-no-template>{{i}}-{{cmp.ctxProp}}</template>',
directives: [ChildCompNoTemplate, NgFor] directives: [ChildCompNoTemplate, NgFor]
})) }))
.createAsync(MyComp) .createAsync(MyComp)
.then((fixture) => { .then((fixture) => {
fixture.detectChanges(); fixture.detectChanges();
@ -760,53 +750,53 @@ function declareTests({useJit}: {useJit: boolean}) {
[TestComponentBuilder, AsyncTestCompleter], [TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => { (tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.overrideView(MyComp, new ViewMetadata({ tcb.overrideView(MyComp, new ViewMetadata({
template: '<push-cmp-with-ref #cmp></push-cmp-with-ref>', template: '<push-cmp-with-ref #cmp></push-cmp-with-ref>',
directives: [[[PushCmpWithRef]]] directives: [[[PushCmpWithRef]]]
})) }))
.createAsync(MyComp)
.then((fixture) => {
.createAsync(MyComp) var cmp = fixture.debugElement.children[0].references['cmp'];
.then((fixture) => {
var cmp = fixture.debugElement.children[0].references['cmp']; fixture.detectChanges();
expect(cmp.numberOfChecks).toEqual(1);
fixture.detectChanges(); fixture.detectChanges();
expect(cmp.numberOfChecks).toEqual(1); expect(cmp.numberOfChecks).toEqual(1);
fixture.detectChanges(); cmp.propagate();
expect(cmp.numberOfChecks).toEqual(1);
cmp.propagate(); fixture.detectChanges();
expect(cmp.numberOfChecks).toEqual(2);
fixture.detectChanges(); async.done();
expect(cmp.numberOfChecks).toEqual(2); });
async.done(); }));
})}));
it('should be checked when its bindings got updated', it('should be checked when its bindings got updated',
inject( inject(
[TestComponentBuilder, AsyncTestCompleter], [TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => { (tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.overrideView(MyComp, new ViewMetadata({ tcb.overrideView(MyComp, new ViewMetadata({
template: '<push-cmp [prop]="ctxProp" #cmp></push-cmp>', template: '<push-cmp [prop]="ctxProp" #cmp></push-cmp>',
directives: [[[PushCmp]]] directives: [[[PushCmp]]]
})) }))
.createAsync(MyComp)
.then((fixture) => {
var cmp = fixture.debugElement.children[0].references['cmp'];
.createAsync(MyComp) fixture.debugElement.componentInstance.ctxProp = 'one';
.then((fixture) => { fixture.detectChanges();
var cmp = fixture.debugElement.children[0].references['cmp']; expect(cmp.numberOfChecks).toEqual(1);
fixture.debugElement.componentInstance.ctxProp = 'one'; fixture.debugElement.componentInstance.ctxProp = 'two';
fixture.detectChanges(); fixture.detectChanges();
expect(cmp.numberOfChecks).toEqual(1); expect(cmp.numberOfChecks).toEqual(2);
fixture.debugElement.componentInstance.ctxProp = 'two'; async.done();
fixture.detectChanges(); });
expect(cmp.numberOfChecks).toEqual(2); }));
async.done();
})}));
if (getDOM().supportsDOMEvents()) { if (getDOM().supportsDOMEvents()) {
it('should allow to destroy a component from within a host event handler', it('should allow to destroy a component from within a host event handler',
@ -835,69 +825,68 @@ function declareTests({useJit}: {useJit: boolean}) {
[TestComponentBuilder, AsyncTestCompleter], [TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => { (tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.overrideView(MyComp, new ViewMetadata({ tcb.overrideView(MyComp, new ViewMetadata({
template: '<push-cmp [prop]="ctxProp" #cmp></push-cmp>', template: '<push-cmp [prop]="ctxProp" #cmp></push-cmp>',
directives: [[[PushCmp]]] directives: [[[PushCmp]]]
})) }))
.createAsync(MyComp)
.then((fixture) => {
var cmpEl = fixture.debugElement.children[0];
var cmp = cmpEl.componentInstance;
fixture.detectChanges();
fixture.detectChanges();
expect(cmp.numberOfChecks).toEqual(1);
.createAsync(MyComp) cmpEl.children[0].triggerEventHandler('click', <Event>{});
.then((fixture) => {
var cmpEl = fixture.debugElement.children[0];
var cmp = cmpEl.componentInstance;
fixture.detectChanges();
fixture.detectChanges();
expect(cmp.numberOfChecks).toEqual(1);
cmpEl.children[0].triggerEventHandler('click', <Event>{}); // regular element
fixture.detectChanges();
fixture.detectChanges();
expect(cmp.numberOfChecks).toEqual(2);
// regular element // element inside of an *ngIf
fixture.detectChanges(); cmpEl.children[1].triggerEventHandler('click', <Event>{});
fixture.detectChanges();
expect(cmp.numberOfChecks).toEqual(2);
// element inside of an *ngIf fixture.detectChanges();
cmpEl.children[1].triggerEventHandler('click', <Event>{}); fixture.detectChanges();
expect(cmp.numberOfChecks).toEqual(3);
fixture.detectChanges(); // element inside a nested component
fixture.detectChanges(); cmpEl.children[2].children[0].triggerEventHandler('click', <Event>{});
expect(cmp.numberOfChecks).toEqual(3);
// element inside a nested component fixture.detectChanges();
cmpEl.children[2].children[0].triggerEventHandler('click', <Event>{}); fixture.detectChanges();
expect(cmp.numberOfChecks).toEqual(4);
fixture.detectChanges(); async.done();
fixture.detectChanges(); });
expect(cmp.numberOfChecks).toEqual(4); }));
async.done();
})}));
it('should not affect updating properties on the component', it('should not affect updating properties on the component',
inject( inject(
[TestComponentBuilder, AsyncTestCompleter], [TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => { (tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.overrideView( tcb.overrideView(
MyComp, new ViewMetadata({ MyComp, new ViewMetadata({
template: template: '<push-cmp-with-ref [prop]="ctxProp" #cmp></push-cmp-with-ref>',
'<push-cmp-with-ref [prop]="ctxProp" #cmp></push-cmp-with-ref>', directives: [[[PushCmpWithRef]]]
directives: [[[PushCmpWithRef]]] }))
})) .createAsync(MyComp)
.then((fixture) => {
.createAsync(MyComp) var cmp = fixture.debugElement.children[0].references['cmp'];
.then((fixture) => {
var cmp = fixture.debugElement.children[0].references['cmp']; fixture.debugElement.componentInstance.ctxProp = 'one';
fixture.detectChanges();
expect(cmp.prop).toEqual('one');
fixture.debugElement.componentInstance.ctxProp = 'one'; fixture.debugElement.componentInstance.ctxProp = 'two';
fixture.detectChanges(); fixture.detectChanges();
expect(cmp.prop).toEqual('one'); expect(cmp.prop).toEqual('two');
fixture.debugElement.componentInstance.ctxProp = 'two'; async.done();
fixture.detectChanges(); });
expect(cmp.prop).toEqual('two'); }));
async.done();
})}));
if (getDOM().supportsDOMEvents()) { if (getDOM().supportsDOMEvents()) {
it('should be checked when an async pipe requests a check', it('should be checked when an async pipe requests a check',
@ -932,27 +921,28 @@ function declareTests({useJit}: {useJit: boolean}) {
inject( inject(
[TestComponentBuilder, AsyncTestCompleter], [TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => { (tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.overrideView(MyComp, new ViewMetadata({ tcb.overrideView(MyComp, new ViewMetadata({
template: ` template: `
<some-directive> <some-directive>
<p> <p>
<cmp-with-host #child></cmp-with-host> <cmp-with-host #child></cmp-with-host>
</p> </p>
</some-directive>`, </some-directive>`,
directives: [SomeDirective, CompWithHost] directives: [SomeDirective, CompWithHost]
})) }))
.createAsync(MyComp) .createAsync(MyComp)
.then((fixture) => { .then((fixture) => {
var childComponent = fixture.debugElement.children[0] var childComponent = fixture.debugElement.children[0]
.children[0] .children[0]
.children[0] .children[0]
.references['child']; .references['child'];
expect(childComponent.myHost).toBeAnInstanceOf(SomeDirective); expect(childComponent.myHost).toBeAnInstanceOf(SomeDirective);
async.done(); async.done();
})})); });
}));
it('should create a component that injects an @Host through viewcontainer directive', it('should create a component that injects an @Host through viewcontainer directive',
inject( inject(
@ -989,7 +979,6 @@ function declareTests({useJit}: {useJit: boolean}) {
template: '<div emitter listener></div>', template: '<div emitter listener></div>',
directives: [DirectiveEmittingEvent, DirectiveListeningEvent] directives: [DirectiveEmittingEvent, DirectiveListeningEvent]
})) }))
.createAsync(MyComp) .createAsync(MyComp)
.then((fixture) => { .then((fixture) => {
@ -1026,7 +1015,6 @@ function declareTests({useJit}: {useJit: boolean}) {
template: '<template emitter listener (event)="ctxProp=$event"></template>', template: '<template emitter listener (event)="ctxProp=$event"></template>',
directives: [DirectiveEmittingEvent, DirectiveListeningEvent] directives: [DirectiveEmittingEvent, DirectiveListeningEvent]
})) }))
.createAsync(MyComp) .createAsync(MyComp)
.then((fixture) => { .then((fixture) => {
@ -1057,7 +1045,6 @@ function declareTests({useJit}: {useJit: boolean}) {
template: '<div [(control)]="ctxProp" two-way></div>', template: '<div [(control)]="ctxProp" two-way></div>',
directives: [DirectiveWithTwoWayBinding] directives: [DirectiveWithTwoWayBinding]
})) }))
.createAsync(MyComp) .createAsync(MyComp)
.then((fixture) => { .then((fixture) => {
var tc = fixture.debugElement.children[0]; var tc = fixture.debugElement.children[0];
@ -1085,7 +1072,6 @@ function declareTests({useJit}: {useJit: boolean}) {
template: '<div listener></div>', template: '<div listener></div>',
directives: [DirectiveListeningDomEvent] directives: [DirectiveListeningDomEvent]
})) }))
.createAsync(MyComp) .createAsync(MyComp)
.then((fixture) => { .then((fixture) => {
@ -1115,7 +1101,6 @@ function declareTests({useJit}: {useJit: boolean}) {
template: '<div listener></div>', template: '<div listener></div>',
directives: [DirectiveListeningDomEvent] directives: [DirectiveListeningDomEvent]
})) }))
.createAsync(MyComp) .createAsync(MyComp)
.then((fixture) => { .then((fixture) => {
var tc = fixture.debugElement.children[0]; var tc = fixture.debugElement.children[0];
@ -1144,7 +1129,6 @@ function declareTests({useJit}: {useJit: boolean}) {
template: '<div update-host-attributes></div>', template: '<div update-host-attributes></div>',
directives: [DirectiveUpdatingHostAttributes] directives: [DirectiveUpdatingHostAttributes]
})) }))
.createAsync(MyComp) .createAsync(MyComp)
.then((fixture) => { .then((fixture) => {
fixture.detectChanges(); fixture.detectChanges();
@ -1165,7 +1149,6 @@ function declareTests({useJit}: {useJit: boolean}) {
template: '<div update-host-properties></div>', template: '<div update-host-properties></div>',
directives: [DirectiveUpdatingHostProperties] directives: [DirectiveUpdatingHostProperties]
})) }))
.createAsync(MyComp) .createAsync(MyComp)
.then((fixture) => { .then((fixture) => {
var tc = fixture.debugElement.children[0]; var tc = fixture.debugElement.children[0];
@ -1195,7 +1178,6 @@ function declareTests({useJit}: {useJit: boolean}) {
DirectiveListeningDomEventPrevent, DirectiveListeningDomEventNoPrevent DirectiveListeningDomEventPrevent, DirectiveListeningDomEventNoPrevent
] ]
})) }))
.createAsync(MyComp) .createAsync(MyComp)
.then((fixture) => { .then((fixture) => {
var dispatchedEvent = getDOM().createMouseEvent('click'); var dispatchedEvent = getDOM().createMouseEvent('click');
@ -1225,7 +1207,6 @@ function declareTests({useJit}: {useJit: boolean}) {
directives: directives:
[NgIf, DirectiveListeningDomEvent, DirectiveListeningDomEventOther] [NgIf, DirectiveListeningDomEvent, DirectiveListeningDomEventOther]
})) }))
.createAsync(MyComp) .createAsync(MyComp)
.then((fixture) => { .then((fixture) => {
globalCounter = 0; globalCounter = 0;
@ -1269,7 +1250,6 @@ function declareTests({useJit}: {useJit: boolean}) {
template: '<div><dynamic-vp #dynamic></dynamic-vp></div>', template: '<div><dynamic-vp #dynamic></dynamic-vp></div>',
directives: [DynamicViewport] directives: [DynamicViewport]
})) }))
.createAsync(MyComp) .createAsync(MyComp)
.then((fixture) => { .then((fixture) => {
var tc = fixture.debugElement.children[0].children[0]; var tc = fixture.debugElement.children[0].children[0];
@ -1625,62 +1605,60 @@ function declareTests({useJit}: {useJit: boolean}) {
}))); })));
} }
if (!IS_DART) { it('should report a meaningful error when a directive is undefined',
it('should report a meaningful error when a directive is undefined', inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
var undefinedValue: any = void(0); var undefinedValue: any = void(0);
tcb = tcb.overrideView( tcb = tcb.overrideView(
MyComp, new ViewMetadata({directives: [undefinedValue], template: ''})); MyComp, new ViewMetadata({directives: [undefinedValue], template: ''}));
expect(() => tcb.createAsync(MyComp)) expect(() => tcb.createAsync(MyComp))
.toThrowError( .toThrowError(
`Unexpected directive value 'undefined' on the View of component '${stringify(MyComp)}'`); `Unexpected directive value 'undefined' on the View of component '${stringify(MyComp)}'`);
})); }));
}
it('should specify a location of an error that happened during change detection (text)', it('should specify a location of an error that happened during change detection (text)',
inject( inject(
[TestComponentBuilder, AsyncTestCompleter], [TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => { (tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.overrideView(MyComp, new ViewMetadata({template: '<div>{{a.b}}</div>'})) tcb.overrideView(MyComp, new ViewMetadata({template: '<div>{{a.b}}</div>'}))
.createAsync(MyComp)
.createAsync(MyComp) .then((fixture) => {
.then((fixture) => { expect(() => fixture.detectChanges()).toThrowError(/:0:5/);
expect(() => fixture.detectChanges()).toThrowError(/:0:5/); async.done();
async.done(); });
})})); }));
it('should specify a location of an error that happened during change detection (element property)', it('should specify a location of an error that happened during change detection (element property)',
inject( inject(
[TestComponentBuilder, AsyncTestCompleter], [TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => { (tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.overrideView(MyComp, new ViewMetadata({template: '<div [title]="a.b"></div>'})) tcb.overrideView(MyComp, new ViewMetadata({template: '<div [title]="a.b"></div>'}))
.createAsync(MyComp)
.createAsync(MyComp) .then((fixture) => {
.then((fixture) => { expect(() => fixture.detectChanges()).toThrowError(/:0:5/);
expect(() => fixture.detectChanges()).toThrowError(/:0:5/); async.done();
async.done(); });
})})); }));
it('should specify a location of an error that happened during change detection (directive property)', it('should specify a location of an error that happened during change detection (directive property)',
inject( inject(
[TestComponentBuilder, AsyncTestCompleter], [TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => { (tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.overrideView(MyComp, new ViewMetadata({ tcb.overrideView(MyComp, new ViewMetadata({
template: '<child-cmp [title]="a.b"></child-cmp>', template: '<child-cmp [title]="a.b"></child-cmp>',
directives: [ChildComp] directives: [ChildComp]
})) }))
.createAsync(MyComp)
.createAsync(MyComp) .then((fixture) => {
.then((fixture) => { expect(() => fixture.detectChanges()).toThrowError(/:0:11/);
expect(() => fixture.detectChanges()).toThrowError(/:0:11/); async.done();
async.done(); });
})})); }));
}); });
it('should support imperative views', it('should support imperative views',
@ -1725,34 +1703,32 @@ function declareTests({useJit}: {useJit: boolean}) {
})); }));
describe('Property bindings', () => { describe('Property bindings', () => {
if (!IS_DART) { it('should throw on bindings to unknown properties',
it('should throw on bindings to unknown properties', inject(
inject( [TestComponentBuilder, AsyncTestCompleter],
[TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => { tcb = tcb.overrideView(
tcb = tcb.overrideView( MyComp, new ViewMetadata({template: '<div unknown="{{ctxProp}}"></div>'}));
MyComp, new ViewMetadata({template: '<div unknown="{{ctxProp}}"></div>'}))
PromiseWrapper.catchError(tcb.createAsync(MyComp), (e) => { PromiseWrapper.catchError(tcb.createAsync(MyComp), (e) => {
expect(e.message).toEqual( expect(e.message).toEqual(
`Template parse errors:\nCan't bind to 'unknown' since it isn't a known native property ("<div [ERROR ->]unknown="{{ctxProp}}"></div>"): MyComp@0:5`); `Template parse errors:\nCan't bind to 'unknown' since it isn't a known native property ("<div [ERROR ->]unknown="{{ctxProp}}"></div>"): MyComp@0:5`);
async.done(); async.done();
return null; return null;
}); });
})); }));
it('should not throw for property binding to a non-existing property when there is a matching directive property', it('should not throw for property binding to a non-existing property when there is a matching directive property',
inject( inject(
[TestComponentBuilder, AsyncTestCompleter], [TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => { (tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.overrideView(MyComp, new ViewMetadata({ tcb.overrideView(
template: '<div my-dir [elprop]="ctxProp"></div>', MyComp,
directives: [MyDir] new ViewMetadata(
})) {template: '<div my-dir [elprop]="ctxProp"></div>', directives: [MyDir]}))
.createAsync(MyComp) .createAsync(MyComp)
.then((val) => { async.done(); }); .then((val) => { async.done(); });
})); }));
}
it('should not be created when there is a directive with the same property', it('should not be created when there is a directive with the same property',
inject( inject(
@ -1987,15 +1963,9 @@ function declareTests({useJit}: {useJit: boolean}) {
expect(getDOM().getProperty(<Element>use, 'namespaceURI')) expect(getDOM().getProperty(<Element>use, 'namespaceURI'))
.toEqual('http://www.w3.org/2000/svg'); .toEqual('http://www.w3.org/2000/svg');
if (!IS_DART) { var firstAttribute = getDOM().getProperty(<Element>use, 'attributes')[0];
var firstAttribute = getDOM().getProperty(<Element>use, 'attributes')[0]; expect(firstAttribute.name).toEqual('xlink:href');
expect(firstAttribute.name).toEqual('xlink:href'); expect(firstAttribute.namespaceURI).toEqual('http://www.w3.org/1999/xlink');
expect(firstAttribute.namespaceURI)
.toEqual('http://www.w3.org/1999/xlink');
} else {
// For Dart where '_Attr' has no instance getter 'namespaceURI'
expect(getDOM().getOuterHTML(<HTMLElement>use)).toContain('xmlns:xlink');
}
async.done(); async.done();
}); });

View File

@ -6,14 +6,11 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {beforeEach, ddescribe, xdescribe, describe, expect, iit, inject, beforeEachProviders, it, xit,} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, beforeEach, ddescribe, xdescribe, describe, expect, iit, inject, beforeEachProviders, it, xit,} from '@angular/core/testing/testing_internal';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {configureCompiler, TestComponentBuilder} from '@angular/core/testing'; import {configureCompiler, TestComponentBuilder} from '@angular/core/testing';
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter'; import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
import {OpaqueToken, ViewMetadata, Component, Directive, AfterContentInit, AfterViewInit, QueryList, ContentChildren, ViewChildren, Input} from '@angular/core'; import {Component, Directive, AfterContentInit, AfterViewInit, QueryList, ContentChildren, ViewChildren, Input} from '@angular/core';
import {NgIf} from '@angular/common'; import {NgIf} from '@angular/common';
import {CompilerConfig} from '@angular/compiler';
import {el} from '@angular/platform-browser/testing/browser_util';
export function main() { export function main() {
describe('jit', () => { declareTests({useJit: true}); }); describe('jit', () => { declareTests({useJit: true}); });

View File

@ -6,12 +6,9 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {beforeEach, ddescribe, xdescribe, describe, expect, iit, inject, beforeEachProviders, it, xit,} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, beforeEach, ddescribe, xdescribe, describe, expect, iit, inject, beforeEachProviders, it, xit,} from '@angular/core/testing/testing_internal';
import {TestComponentBuilder} from '@angular/core/testing'; import {TestComponentBuilder} from '@angular/core/testing';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal'; import {Component, ComponentFactoryResolver, NoComponentFactoryError, forwardRef, ANALYZE_FOR_PRECOMPILE} from '@angular/core';
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
import {Component, ViewChild, ViewContainerRef, ComponentFactoryResolver, NoComponentFactoryError, ComponentRef, forwardRef, ANALYZE_FOR_PRECOMPILE} from '@angular/core';
import {CompilerConfig} from '@angular/compiler';
export function main() { export function main() {
describe('jit', () => { declareTests({useJit: true}); }); describe('jit', () => { declareTests({useJit: true}); });

View File

@ -6,13 +6,12 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {beforeEach, ddescribe, xdescribe, describe, expect, iit, inject, beforeEachProviders, it, xit,} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, beforeEach, ddescribe, xdescribe, describe, expect, iit, inject, beforeEachProviders, it, xit,} from '@angular/core/testing/testing_internal';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {ComponentFixture, TestComponentBuilder} from '@angular/core/testing'; import {ComponentFixture, TestComponentBuilder} from '@angular/core/testing';
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter'; import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
import {bind, provide, forwardRef, Component, Directive, ElementRef, TemplateRef, ViewContainerRef, ViewEncapsulation, ViewMetadata} from '@angular/core'; import {forwardRef, Component, Directive, ElementRef, TemplateRef, ViewContainerRef, ViewEncapsulation, ViewMetadata} from '@angular/core';
import {By,} from '@angular/platform-browser/src/dom/debug/by'; import {By,} from '@angular/platform-browser/src/dom/debug/by';
import {getAllDebugNodes} from '@angular/core/src/debug/debug_node'; import {getAllDebugNodes} from '@angular/core/src/debug/debug_node';

View File

@ -6,16 +6,14 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {beforeEach, ddescribe, describe, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, beforeEach, ddescribe, describe, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal';
import {TestComponentBuilder} from '@angular/core/testing'; import {TestComponentBuilder} from '@angular/core/testing';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {isPresent, stringify} from '../../src/facade/lang'; import {isPresent, stringify} from '../../src/facade/lang';
import {ObservableWrapper} from '../../src/facade/async'; import {ObservableWrapper} from '../../src/facade/async';
import {Component, Directive, TemplateRef, Query, QueryList, ViewQuery, ContentChildren, ViewChildren, ContentChild, ViewChild, AfterContentInit, AfterViewInit, AfterContentChecked, AfterViewChecked} from '@angular/core'; import {asNativeElements, ViewContainerRef, Component, Directive, TemplateRef, Query, QueryList, ViewQuery, ContentChildren, ViewChildren, ContentChild, ViewChild, AfterContentInit, AfterViewInit, AfterContentChecked, AfterViewChecked} from '@angular/core';
import {NgIf, NgFor} from '@angular/common'; import {NgIf, NgFor} from '@angular/common';
import {asNativeElements, ViewContainerRef} from '@angular/core';
export function main() { export function main() {
describe('Query API', () => { describe('Query API', () => {
@ -303,9 +301,9 @@ export function main() {
expect(needsTpl.vc.createEmbeddedView(needsTpl.contentTpl).rootNodes[0]) expect(needsTpl.vc.createEmbeddedView(needsTpl.contentTpl).rootNodes[0])
.toHaveText('light'); .toHaveText('light');
expect(needsTpl.vc.createEmbeddedView(needsTpl.viewTpl).rootNodes[0]) expect(needsTpl.vc.createEmbeddedView(needsTpl.viewTpl).rootNodes[0])
.toHaveText('shadow') .toHaveText('shadow');
async.done(); async.done();
}); });
})); }));
}); });
@ -833,6 +831,7 @@ class NeedsViewChildren implements AfterViewInit {
@Component({selector: 'needs-content-child', template: ''}) @Component({selector: 'needs-content-child', template: ''})
class NeedsContentChild implements AfterContentInit, AfterContentChecked { class NeedsContentChild implements AfterContentInit, AfterContentChecked {
/** @internal */
_child: TextDirective; _child: TextDirective;
@ContentChild(TextDirective) @ContentChild(TextDirective)
@ -862,6 +861,7 @@ class NeedsViewChild implements AfterViewInit,
AfterViewChecked { AfterViewChecked {
shouldShow: boolean = true; shouldShow: boolean = true;
shouldShow2: boolean = false; shouldShow2: boolean = false;
/** @internal */
_child: TextDirective; _child: TextDirective;
@ViewChild(TextDirective) @ViewChild(TextDirective)

View File

@ -6,12 +6,10 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {Component, provide} from '@angular/core';
import {ComponentFactory} from '@angular/core/src/linker/component_factory'; import {ComponentFactory} from '@angular/core/src/linker/component_factory';
import {ComponentResolver, ReflectorComponentResolver} from '@angular/core/src/linker/component_resolver'; import {ComponentResolver, ReflectorComponentResolver} from '@angular/core/src/linker/component_resolver';
import {ReflectionInfo, reflector} from '@angular/core/src/reflection/reflection'; import {ReflectionInfo, reflector} from '@angular/core/src/reflection/reflection';
import {afterEach, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, afterEach, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {Console} from '../../src/console'; import {Console} from '../../src/console';
class DummyConsole implements Console { class DummyConsole implements Console {
@ -42,8 +40,8 @@ export function main() {
it('should throw when given a string', it('should throw when given a string',
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
compiler.resolveComponent('someString').catch((e) => { compiler.resolveComponent('someString').catch((e) => {
expect(e.message).toContain('Cannot resolve component using \'someString\'.') expect(e.message).toContain('Cannot resolve component using \'someString\'.');
async.done(); async.done();
}); });
})); }));
}); });

View File

@ -6,24 +6,16 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {beforeEach, ddescribe, xdescribe, describe, expect, iit, inject, beforeEachProviders, it, xit,} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, beforeEach, ddescribe, xdescribe, describe, expect, iit, inject, beforeEachProviders, it, xit,} from '@angular/core/testing/testing_internal';
import {configureCompiler, configureModule, TestComponentBuilder} from '@angular/core/testing'; import {configureCompiler, configureModule, TestComponentBuilder} from '@angular/core/testing';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {IS_DART} from '../../src/facade/lang'; import {Component, Pipe, PipeTransform, ViewMetadata, OpaqueToken, Injector, forwardRef} from '@angular/core';
import {Component, Pipe, PipeTransform, provide, ViewMetadata, PLATFORM_PIPES, OpaqueToken, Injector, forwardRef} from '@angular/core';
import {NgIf, NgClass} from '@angular/common'; import {NgIf, NgClass} from '@angular/common';
import {CompilerConfig} from '@angular/compiler';
export function main() { export function main() {
if (IS_DART) { describe('jit', () => { declareTests({useJit: true}); });
declareTests({useJit: false});
} else {
describe('jit', () => { declareTests({useJit: true}); });
describe('no jit', () => { declareTests({useJit: false}); }); describe('no jit', () => { declareTests({useJit: false}); });
}
} }
function declareTests({useJit}: {useJit: boolean}) { function declareTests({useJit}: {useJit: boolean}) {
@ -68,20 +60,18 @@ function declareTests({useJit}: {useJit: boolean}) {
}); });
})); }));
if (!IS_DART) { it('should evaluate conditional and unary operators with right precedence - #8235',
it('should evaluate conditional and unary operators with right precedence - #8235', inject(
inject( [TestComponentBuilder, AsyncTestCompleter],
[TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => { tcb.overrideView(MyComp1, new ViewMetadata({template: `{{!null?.length}}`}))
tcb.overrideView(MyComp1, new ViewMetadata({template: `{{!null?.length}}`})) .createAsync(MyComp1)
.createAsync(MyComp1) .then((fixture) => {
.then((fixture) => { fixture.detectChanges();
fixture.detectChanges(); expect(fixture.nativeElement).toHaveText('true');
expect(fixture.nativeElement).toHaveText('true'); async.done();
async.done(); });
}); }));
}));
}
}); });
describe('providers', () => { describe('providers', () => {

View File

@ -6,26 +6,17 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {ddescribe, describe, expect, inject, beforeEachProviders, beforeEach, afterEach, it,} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, ddescribe, describe, expect, inject, beforeEachProviders, beforeEach, afterEach, it,} from '@angular/core/testing/testing_internal';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {configureCompiler, TestComponentBuilder} from '@angular/core/testing'; import {configureCompiler, TestComponentBuilder} from '@angular/core/testing';
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter'; import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
import {provide, Injectable, OpaqueToken} from '@angular/core'; import {Component} from '@angular/core/src/metadata';
import {CompilerConfig} from '@angular/compiler';
import {Component, ViewMetadata} from '@angular/core/src/metadata';
import {IS_DART} from '../../src/facade/lang';
import {el} from '@angular/platform-browser/testing/browser_util';
import {DomSanitizationService} from '@angular/platform-browser/src/security/dom_sanitization_service'; import {DomSanitizationService} from '@angular/platform-browser/src/security/dom_sanitization_service';
export function main() { export function main() {
if (IS_DART) { describe('jit', () => { declareTests({useJit: true}); });
declareTests({useJit: false});
} else {
describe('jit', () => { declareTests({useJit: true}); });
describe('no jit', () => { declareTests({useJit: false}); }); describe('no jit', () => { declareTests({useJit: false}); });
}
} }
@Component({selector: 'my-comp', template: '', directives: []}) @Component({selector: 'my-comp', template: '', directives: []})

View File

@ -12,7 +12,7 @@ import {Reflector, ReflectionInfo} from '@angular/core/src/reflection/reflection
import {ReflectionCapabilities} from '@angular/core/src/reflection/reflection_capabilities'; import {ReflectionCapabilities} from '@angular/core/src/reflection/reflection_capabilities';
import {ClassDecorator, ParamDecorator, PropDecorator, classDecorator, paramDecorator, propDecorator, HasGetterAndSetterDecorators} from './reflector_common'; import {ClassDecorator, ParamDecorator, PropDecorator, classDecorator, paramDecorator, propDecorator, HasGetterAndSetterDecorators} from './reflector_common';
import {IS_DART} from '../../src/facade/lang'; import {IS_DART} from '../../src/facade/lang';
import {browserDetection} from '@angular/platform-browser/testing/browser_util' import {browserDetection} from '@angular/platform-browser/testing/browser_util';
class AType { class AType {
value: any /** TODO #9100 */; value: any /** TODO #9100 */;
@ -20,17 +20,17 @@ class AType {
constructor(value: any /** TODO #9100 */) { this.value = value; } constructor(value: any /** TODO #9100 */) { this.value = value; }
} }
@ClassDecorator('class') class ClassWithDecorators { @ClassDecorator('class')
class ClassWithDecorators {
@PropDecorator('p1') @PropDecorator('p2') a: any /** TODO #9100 */; @PropDecorator('p1') @PropDecorator('p2') a: any /** TODO #9100 */;
b: any /** TODO #9100 */; b: any /** TODO #9100 */;
@PropDecorator('p3') @PropDecorator('p3')
set c(value: any /** TODO #9100 */) { set c(value: any /** TODO #9100 */) {}
}
constructor(@ParamDecorator('a') a: AType, @ParamDecorator('b') b: AType) { constructor(@ParamDecorator('a') a: AType, @ParamDecorator('b') b: AType) {
this.a = a; this.a = a;
this.b = b; this.b = b;
} }
} }
@ -43,12 +43,11 @@ class TestObj {
b: any /** TODO #9100 */; b: any /** TODO #9100 */;
constructor(a: any /** TODO #9100 */, b: any /** TODO #9100 */) { constructor(a: any /** TODO #9100 */, b: any /** TODO #9100 */) {
this.a = a; this.a = a;
this.b = b; this.b = b;
} }
identity(arg: any /** TODO #9100 */) { identity(arg: any /** TODO #9100 */) { return arg; }
return arg; }
} }
class Interface {} class Interface {}
@ -74,50 +73,50 @@ class SubClassDoesNotDeclareOnInit extends SuperClassImplementingOnInit {}
export function main() { export function main() {
describe('Reflector', () => { describe('Reflector', () => {
var reflector: any /** TODO #9100 */; var reflector: any /** TODO #9100 */;
beforeEach(() => { reflector = new Reflector(new ReflectionCapabilities()); }); beforeEach(() => { reflector = new Reflector(new ReflectionCapabilities()); });
describe('usage tracking', () => { describe('usage tracking', () => {
beforeEach(() => { reflector = new Reflector(null); }); beforeEach(() => { reflector = new Reflector(null); });
it('should be disabled by default', () => { it('should be disabled by default', () => {
expect(() => reflector.listUnusedKeys()).toThrowError('Usage tracking is disabled'); expect(() => reflector.listUnusedKeys()).toThrowError('Usage tracking is disabled');
});
it('should report unused keys', () => {
reflector.trackUsage();
expect(reflector.listUnusedKeys()).toEqual([]);
reflector.registerType(AType, new ReflectionInfo(null, null, () => 'AType'));
reflector.registerType(TestObj, new ReflectionInfo(null, null, () => 'TestObj'));
expect(reflector.listUnusedKeys()).toEqual([AType, TestObj]);
reflector.factory(AType);
expect(reflector.listUnusedKeys()).toEqual([TestObj]);
reflector.factory(TestObj);
expect(reflector.listUnusedKeys()).toEqual([]);
});
}); });
it('should report unused keys', () => { describe('factory', () => {
reflector.trackUsage(); it('should create a factory for the given type', () => {
expect(reflector.listUnusedKeys()).toEqual([]); var obj = reflector.factory(TestObj)(1, 2);
reflector.registerType(AType, new ReflectionInfo(null, null, () => 'AType')); expect(obj.a).toEqual(1);
reflector.registerType(TestObj, new ReflectionInfo(null, null, () => 'TestObj')); expect(obj.b).toEqual(2);
expect(reflector.listUnusedKeys()).toEqual([AType, TestObj]); });
reflector.factory(AType); // Makes Edge to disconnect when running the full unit test campaign
expect(reflector.listUnusedKeys()).toEqual([TestObj]); // TODO: remove when issue is solved: https://github.com/angular/angular/issues/4756
if (!browserDetection.isEdge) {
it('should check args from no to max', () => {
var f = (t: any /** TODO #9100 */) => reflector.factory(t);
var checkArgs = (obj: any /** TODO #9100 */, args: any /** TODO #9100 */) =>
expect(obj.args).toEqual(args);
reflector.factory(TestObj); // clang-format off
expect(reflector.listUnusedKeys()).toEqual([]);
});
});
describe('factory', () => {
it('should create a factory for the given type', () => {
var obj = reflector.factory(TestObj)(1, 2);
expect(obj.a).toEqual(1);
expect(obj.b).toEqual(2);
});
// Makes Edge to disconnect when running the full unit test campaign
// TODO: remove when issue is solved: https://github.com/angular/angular/issues/4756
if (!browserDetection.isEdge) {
it('should check args from no to max', () => {
var f = (t: any /** TODO #9100 */) => reflector.factory(t);
var checkArgs = (obj: any /** TODO #9100 */, args: any /** TODO #9100 */) =>
expect(obj.args).toEqual(args);
// clang-format off
checkArgs(f(TestObjWith00Args)(), []); checkArgs(f(TestObjWith00Args)(), []);
checkArgs(f(TestObjWith01Args)(1), [1]); checkArgs(f(TestObjWith01Args)(1), [1]);
checkArgs(f(TestObjWith02Args)(1, 2), [1, 2]); checkArgs(f(TestObjWith02Args)(1, 2), [1, 2]);
@ -139,322 +138,326 @@ export function main() {
checkArgs(f(TestObjWith18Args)(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]); checkArgs(f(TestObjWith18Args)(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]);
checkArgs(f(TestObjWith19Args)(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]); checkArgs(f(TestObjWith19Args)(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]);
checkArgs(f(TestObjWith20Args)(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]); checkArgs(f(TestObjWith20Args)(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]);
// clang-format on // clang-format on
});
}
it('should throw when more than 20 arguments',
() => { expect(() => reflector.factory(TestObjWith21Args)).toThrowError(); });
it('should return a registered factory if available', () => {
reflector.registerType(TestObj, new ReflectionInfo(null, null, () => 'fake'));
expect(reflector.factory(TestObj)()).toEqual('fake');
}); });
}
it('should throw when more than 20 arguments',
() => { expect(() => reflector.factory(TestObjWith21Args)).toThrowError(); });
it('should return a registered factory if available', () => {
reflector.registerType(TestObj, new ReflectionInfo(null, null, () => 'fake'));
expect(reflector.factory(TestObj)()).toEqual('fake');
});
});
describe('parameters', () => {
it('should return an array of parameters for a type', () => {
var p = reflector.parameters(ClassWithDecorators);
expect(p).toEqual([[AType, paramDecorator('a')], [AType, paramDecorator('b')]]);
}); });
it('should work for a class without annotations', () => { describe('parameters', () => {
var p = reflector.parameters(ClassWithoutDecorators); it('should return an array of parameters for a type', () => {
expect(p.length).toEqual(2); var p = reflector.parameters(ClassWithDecorators);
expect(p).toEqual([[AType, paramDecorator('a')], [AType, paramDecorator('b')]]);
});
it('should work for a class without annotations', () => {
var p = reflector.parameters(ClassWithoutDecorators);
expect(p.length).toEqual(2);
});
it('should return registered parameters if available', () => {
reflector.registerType(TestObj, new ReflectionInfo(null, [[1], [2]]));
expect(reflector.parameters(TestObj)).toEqual([[1], [2]]);
});
it('should return an empty list when no parameters field in the stored type info', () => {
reflector.registerType(TestObj, new ReflectionInfo());
expect(reflector.parameters(TestObj)).toEqual([]);
});
}); });
it('should return registered parameters if available', () => { describe('propMetadata', () => {
reflector.registerType(TestObj, new ReflectionInfo(null, [[1], [2]])); it('should return a string map of prop metadata for the given class', () => {
expect(reflector.parameters(TestObj)).toEqual([[1], [2]]); var p = reflector.propMetadata(ClassWithDecorators);
expect(p['a']).toEqual([propDecorator('p1'), propDecorator('p2')]);
expect(p['c']).toEqual([propDecorator('p3')]);
});
it('should return registered meta if available', () => {
reflector.registerType(TestObj, new ReflectionInfo(null, null, null, null, {'a': [1, 2]}));
expect(reflector.propMetadata(TestObj)).toEqual({'a': [1, 2]});
});
if (IS_DART) {
it('should merge metadata from getters and setters', () => {
var p = reflector.propMetadata(HasGetterAndSetterDecorators);
expect(p['a']).toEqual([propDecorator('get'), propDecorator('set')]);
});
}
}); });
it('should return an empty list when no parameters field in the stored type info', () => { describe('annotations', () => {
reflector.registerType(TestObj, new ReflectionInfo()); it('should return an array of annotations for a type', () => {
expect(reflector.parameters(TestObj)).toEqual([]); var p = reflector.annotations(ClassWithDecorators);
}); expect(p).toEqual([classDecorator('class')]);
}); });
describe('propMetadata', () => { it('should return registered annotations if available', () => {
it('should return a string map of prop metadata for the given class', () => { reflector.registerType(TestObj, new ReflectionInfo([1, 2]));
var p = reflector.propMetadata(ClassWithDecorators); expect(reflector.annotations(TestObj)).toEqual([1, 2]);
expect(p['a']).toEqual([propDecorator('p1'), propDecorator('p2')]); });
expect(p['c']).toEqual([propDecorator('p3')]);
});
it('should return registered meta if available', () => { it('should work for a class without annotations', () => {
reflector.registerType(TestObj, new ReflectionInfo(null, null, null, null, {'a': [1, 2]})); var p = reflector.annotations(ClassWithoutDecorators);
expect(reflector.propMetadata(TestObj)).toEqual({'a': [1, 2]}); expect(p).toEqual([]);
});
}); });
if (IS_DART) { if (IS_DART) {
it('should merge metadata from getters and setters', () => { describe('interfaces', () => {
var p = reflector.propMetadata(HasGetterAndSetterDecorators); it('should return an array of interfaces for a type', () => {
expect(p['a']).toEqual([propDecorator('get'), propDecorator('set')]); var p = reflector.interfaces(ClassImplementingInterface);
expect(p).toEqual([Interface, Interface2]);
});
it('should return an empty array otherwise', () => {
var p = reflector.interfaces(ClassWithDecorators);
expect(p).toEqual([]);
});
it('should throw for undeclared lifecycle interfaces',
() => { expect(() => reflector.interfaces(ClassDoesNotDeclareOnInit)).toThrowError(); });
it('should throw for class inheriting a lifecycle impl and not declaring the interface',
() => {
expect(() => reflector.interfaces(SubClassDoesNotDeclareOnInit)).toThrowError();
});
}); });
} }
});
describe('annotations', () => { describe('getter', () => {
it('should return an array of annotations for a type', () => { it('returns a function reading a property', () => {
var p = reflector.annotations(ClassWithDecorators); var getA = reflector.getter('a');
expect(p).toEqual([classDecorator('class')]); expect(getA(new TestObj(1, 2))).toEqual(1);
});
it('should return registered annotations if available', () => {
reflector.registerType(TestObj, new ReflectionInfo([1, 2]));
expect(reflector.annotations(TestObj)).toEqual([1, 2]);
});
it('should work for a class without annotations', () => {
var p = reflector.annotations(ClassWithoutDecorators);
expect(p).toEqual([]);
});
});
if (IS_DART) {
describe('interfaces', () => {
it('should return an array of interfaces for a type', () => {
var p = reflector.interfaces(ClassImplementingInterface);
expect(p).toEqual([Interface, Interface2]);
}); });
it('should return an empty array otherwise', () => { it('should return a registered getter if available', () => {
var p = reflector.interfaces(ClassWithDecorators); reflector.registerGetters({'abc': (obj: any /** TODO #9100 */) => 'fake'});
expect(p).toEqual([]); expect(reflector.getter('abc')('anything')).toEqual('fake');
});
it('should throw for undeclared lifecycle interfaces',
() => { expect(() => reflector.interfaces(ClassDoesNotDeclareOnInit)).toThrowError(); });
it('should throw for class inheriting a lifecycle impl and not declaring the interface',
() => {
expect(() => reflector.interfaces(SubClassDoesNotDeclareOnInit)).toThrowError();
});
});
}
describe('getter', () => {
it('returns a function reading a property', () => {
var getA = reflector.getter('a');
expect(getA(new TestObj(1, 2))).toEqual(1);
});
it('should return a registered getter if available', () => {
reflector.registerGetters({'abc': (obj: any /** TODO #9100 */) => 'fake'});
expect(reflector.getter('abc')('anything')).toEqual('fake');
});
});
describe('setter', () => {
it('returns a function setting a property', () => {
var setA = reflector.setter('a');
var obj = new TestObj(1, 2);
setA(obj, 100);
expect(obj.a).toEqual(100);
});
it('should return a registered setter if available', () => {
var updateMe: any /** TODO #9100 */;
reflector.registerSetters({
'abc': (obj: any /** TODO #9100 */, value: any /** TODO #9100 */) => { updateMe = value; }
});
reflector.setter('abc')('anything', 'fake');
expect(updateMe).toEqual('fake');
});
});
describe('method', () => {
it('returns a function invoking a method', () => {
var func = reflector.method('identity');
var obj = new TestObj(1, 2);
expect(func(obj, ['value'])).toEqual('value');
});
it('should return a registered method if available', () => {
reflector.registerMethods(
{'abc': (obj: any /** TODO #9100 */, args: any /** TODO #9100 */) => args});
expect(reflector.method('abc')('anything', ['fake'])).toEqual(['fake']);
});
});
if (IS_DART) {
describe('importUri', () => {
it('should return the importUri for a type', () => {
expect(reflector.importUri(TestObjWith00Args)
.endsWith('test/core/reflection/reflector_spec.dart'))
.toBe(true);
}); });
}); });
}
describe('setter', () => {
it('returns a function setting a property', () => {
var setA = reflector.setter('a');
var obj = new TestObj(1, 2);
setA(obj, 100);
expect(obj.a).toEqual(100);
});
it('should return a registered setter if available', () => {
var updateMe: any /** TODO #9100 */;
reflector.registerSetters({
'abc': (obj: any /** TODO #9100 */, value: any /** TODO #9100 */) => { updateMe = value; }
});
reflector.setter('abc')('anything', 'fake');
expect(updateMe).toEqual('fake');
});
});
describe('method', () => {
it('returns a function invoking a method', () => {
var func = reflector.method('identity');
var obj = new TestObj(1, 2);
expect(func(obj, ['value'])).toEqual('value');
});
it('should return a registered method if available', () => {
reflector.registerMethods(
{'abc': (obj: any /** TODO #9100 */, args: any /** TODO #9100 */) => args});
expect(reflector.method('abc')('anything', ['fake'])).toEqual(['fake']);
});
});
if (IS_DART) {
describe('importUri', () => {
it('should return the importUri for a type', () => {
expect(reflector.importUri(TestObjWith00Args)
.endsWith('test/core/reflection/reflector_spec.dart'))
.toBe(true);
});
});
}
}); });
} }
class TestObjWith00Args { class TestObjWith00Args {
args: any[]; args: any[];
constructor() { constructor() { this.args = []; }
this.args = []; }
} }
class TestObjWith01Args { class TestObjWith01Args {
args: any[]; args: any[];
constructor(a1: any) { constructor(a1: any) { this.args = [a1]; }
this.args = [a1]; }
} }
class TestObjWith02Args { class TestObjWith02Args {
args: any[]; args: any[];
constructor(a1: any, a2: any) { constructor(a1: any, a2: any) { this.args = [a1, a2]; }
this.args = [a1, a2]; }
} }
class TestObjWith03Args { class TestObjWith03Args {
args: any[]; args: any[];
constructor(a1: any, a2: any, a3: any) { constructor(a1: any, a2: any, a3: any) { this.args = [a1, a2, a3]; }
this.args = [a1, a2, a3]; }
} }
class TestObjWith04Args { class TestObjWith04Args {
args: any[]; args: any[];
constructor(a1: any, a2: any, a3: any, a4: any) { constructor(a1: any, a2: any, a3: any, a4: any) { this.args = [a1, a2, a3, a4]; }
this.args = [a1, a2, a3, a4]; }
} }
class TestObjWith05Args { class TestObjWith05Args {
args: any[]; args: any[];
constructor(a1: any, a2: any, a3: any, a4: any, a5: any) { constructor(a1: any, a2: any, a3: any, a4: any, a5: any) { this.args = [a1, a2, a3, a4, a5]; }
this.args = [a1, a2, a3, a4, a5]; }
} }
class TestObjWith06Args { class TestObjWith06Args {
args: any[]; args: any[];
constructor(a1: any, a2: any, a3: any, a4: any, a5: any, a6: any) { constructor(a1: any, a2: any, a3: any, a4: any, a5: any, a6: any) {
this.args = [a1, a2, a3, a4, a5, a6]; this.args = [a1, a2, a3, a4, a5, a6];
} }
} }
class TestObjWith07Args { class TestObjWith07Args {
args: any[]; args: any[];
constructor(a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any) { constructor(a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any) {
this.args = [a1, a2, a3, a4, a5, a6, a7]; this.args = [a1, a2, a3, a4, a5, a6, a7];
} }
} }
class TestObjWith08Args { class TestObjWith08Args {
args: any[]; args: any[];
constructor(a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any) { constructor(a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any) {
this.args = [a1, a2, a3, a4, a5, a6, a7, a8]; this.args = [a1, a2, a3, a4, a5, a6, a7, a8];
} }
} }
class TestObjWith09Args { class TestObjWith09Args {
args: any[]; args: any[];
constructor(a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any) { constructor(a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any) {
this.args = [a1, a2, a3, a4, a5, a6, a7, a8, a9]; this.args = [a1, a2, a3, a4, a5, a6, a7, a8, a9];
} }
} }
class TestObjWith10Args { class TestObjWith10Args {
args: any[]; args: any[];
constructor(a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, constructor(
a10: any) { a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, a10: any) {
this.args = [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10]; this.args = [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10];
} }
} }
class TestObjWith11Args { class TestObjWith11Args {
args: any[]; args: any[];
constructor(a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, constructor(
a10: any, a11: any) { a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, a10: any,
this.args = [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11]; a11: any) {
this.args = [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11];
} }
} }
class TestObjWith12Args { class TestObjWith12Args {
args: any[]; args: any[];
constructor(a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, constructor(
a10: any, a11: any, a12: any) { a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, a10: any,
this.args = [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12]; a11: any, a12: any) {
this.args = [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12];
} }
} }
class TestObjWith13Args { class TestObjWith13Args {
args: any[]; args: any[];
constructor(a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, constructor(
a10: any, a11: any, a12: any, a13: any) { a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, a10: any,
this.args = [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13]; a11: any, a12: any, a13: any) {
this.args = [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13];
} }
} }
class TestObjWith14Args { class TestObjWith14Args {
args: any[]; args: any[];
constructor(a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, constructor(
a10: any, a11: any, a12: any, a13: any, a14: any) { a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, a10: any,
this.args = [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14]; a11: any, a12: any, a13: any, a14: any) {
this.args = [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14];
} }
} }
class TestObjWith15Args { class TestObjWith15Args {
args: any[]; args: any[];
constructor(a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, constructor(
a10: any, a11: any, a12: any, a13: any, a14: any, a15: any) { a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, a10: any,
this.args = [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15]; a11: any, a12: any, a13: any, a14: any, a15: any) {
this.args = [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15];
} }
} }
class TestObjWith16Args { class TestObjWith16Args {
args: any[]; args: any[];
constructor(a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, constructor(
a10: any, a11: any, a12: any, a13: any, a14: any, a15: any, a16: any) { a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, a10: any,
this.args = [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16]; a11: any, a12: any, a13: any, a14: any, a15: any, a16: any) {
this.args = [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16];
} }
} }
class TestObjWith17Args { class TestObjWith17Args {
args: any[]; args: any[];
constructor(a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, constructor(
a10: any, a11: any, a12: any, a13: any, a14: any, a15: any, a16: any, a17: any) { a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, a10: any,
this.args = [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17]; a11: any, a12: any, a13: any, a14: any, a15: any, a16: any, a17: any) {
this.args = [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17];
} }
} }
class TestObjWith18Args { class TestObjWith18Args {
args: any[]; args: any[];
constructor(a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, constructor(
a10: any, a11: any, a12: any, a13: any, a14: any, a15: any, a16: any, a17: any, a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, a10: any,
a18: any) { a11: any, a12: any, a13: any, a14: any, a15: any, a16: any, a17: any, a18: any) {
this.args = [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18]; this.args = [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18];
} }
} }
class TestObjWith19Args { class TestObjWith19Args {
args: any[]; args: any[];
constructor(a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, constructor(
a10: any, a11: any, a12: any, a13: any, a14: any, a15: any, a16: any, a17: any, a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, a10: any,
a18: any, a19: any) { a11: any, a12: any, a13: any, a14: any, a15: any, a16: any, a17: any, a18: any, a19: any) {
this.args = this.args =
[a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19]; [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19];
} }
} }
class TestObjWith20Args { class TestObjWith20Args {
args: any[]; args: any[];
constructor(a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, constructor(
a10: any, a11: any, a12: any, a13: any, a14: any, a15: any, a16: any, a17: any, a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, a10: any,
a18: any, a19: any, a20: any) { a11: any, a12: any, a13: any, a14: any, a15: any, a16: any, a17: any, a18: any, a19: any,
this.args = a20: any) {
[a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20]; this.args =
[a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20];
} }
} }
class TestObjWith21Args { class TestObjWith21Args {
args: any[]; args: any[];
constructor(a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, constructor(
a10: any, a11: any, a12: any, a13: any, a14: any, a15: any, a16: any, a17: any, a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, a10: any,
a18: any, a19: any, a20: any, a21: any) { a11: any, a12: any, a13: any, a14: any, a15: any, a16: any, a17: any, a18: any, a19: any,
this.args = [ a20: any, a21: any) {
a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21 this.args = [
]; a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11,
a12, a13, a14, a15, a16, a17, a18, a19, a20, a21
];
} }
} }

View File

@ -7,8 +7,7 @@
*/ */
import {Injectable} from '@angular/core/src/di'; import {Injectable} from '@angular/core/src/di';
import {inject, describe, ddescribe, it, iit, xit, xdescribe, expect, beforeEach,} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, SpyObject, inject, describe, ddescribe, it, iit, xit, xdescribe, expect, beforeEach,} from '@angular/core/testing/testing_internal';
import {AsyncTestCompleter, SpyObject} from '@angular/core/testing/testing_internal';
import {Testability} from '@angular/core/src/testability/testability'; import {Testability} from '@angular/core/src/testability/testability';
import {NgZone} from '@angular/core/src/zone/ng_zone'; import {NgZone} from '@angular/core/src/zone/ng_zone';
import {normalizeBlank, scheduleMicroTask} from '../../src/facade/lang'; import {normalizeBlank, scheduleMicroTask} from '../../src/facade/lang';
@ -17,7 +16,7 @@ import {PromiseWrapper, EventEmitter, ObservableWrapper} from '../../src/facade/
// Schedules a microtasks (using a resolved promise .then()) // Schedules a microtasks (using a resolved promise .then())
function microTask(fn: Function): void { function microTask(fn: Function): void {
scheduleMicroTask(() => { scheduleMicroTask(() => {
// We do double dispatch so that we can wait for scheduleMicrotas in the Testability when // We do double dispatch so that we can wait for scheduleMicrotask in the Testability when
// NgZone becomes stable. // NgZone becomes stable.
scheduleMicroTask(fn); scheduleMicroTask(fn);
}); });
@ -25,9 +24,11 @@ function microTask(fn: Function): void {
@Injectable() @Injectable()
class MockNgZone extends NgZone { class MockNgZone extends NgZone {
/** @internal */
_onUnstableStream: EventEmitter<any>; _onUnstableStream: EventEmitter<any>;
get onUnstable() { return this._onUnstableStream; } get onUnstable() { return this._onUnstableStream; }
/** @internal */
_onStableStream: EventEmitter<any>; _onStableStream: EventEmitter<any>;
get onStable() { return this._onStableStream; } get onStable() { return this._onStableStream; }

View File

@ -74,8 +74,7 @@ export function main() {
() => { expect(spyObj.spy('someFunc')).not.toHaveBeenCalled(); }); () => { expect(spyObj.spy('someFunc')).not.toHaveBeenCalled(); });
it('should record function calls', () => { it('should record function calls', () => {
spyObj.spy('someFunc') spyObj.spy('someFunc').andCallFake((a: any, b: any) => a + b);
.andCallFake((a: any /** TODO #9100 */, b: any /** TODO #9100 */) => {return a + b});
expect(spyObj.someFunc(1, 2)).toEqual(3); expect(spyObj.someFunc(1, 2)).toEqual(3);
expect(spyObj.spy('someFunc')).toHaveBeenCalledWith(1, 2); expect(spyObj.spy('someFunc')).toHaveBeenCalledWith(1, 2);

View File

@ -89,7 +89,7 @@ export function main() {
expect(proto.extends).toEqual(undefined); expect(proto.extends).toEqual(undefined);
expect(proto.prototype).toEqual(undefined); expect(proto.prototype).toEqual(undefined);
expect(reflector.annotations(MyClass)[0].arg).toEqual('test-works') expect(reflector.annotations(MyClass)[0].arg).toEqual('test-works');
}); });
describe('errors', () => { describe('errors', () => {
@ -108,13 +108,15 @@ export function main() {
it('should ensure that last position is function', () => { it('should ensure that last position is function', () => {
expect(() => {Class({constructor: []})}) expect(() => { Class({constructor: []}); })
.toThrowError( .toThrowError(
'Last position of Class method array must be Function in key constructor was \'undefined\''); 'Last position of Class method array must be Function in key constructor was \'undefined\'');
}); });
it('should ensure that annotation count matches parameters count', () => { it('should ensure that annotation count matches parameters count', () => {
expect(() => {Class({constructor: [String, function MyType() {}]})}) expect(() => {
Class({constructor: [String, function MyType() {}]});
})
.toThrowError( .toThrowError(
'Number of annotations (1) does not match number of arguments (0) in the function: MyType'); 'Number of annotations (1) does not match number of arguments (0) in the function: MyType');
}); });
@ -126,7 +128,7 @@ export function main() {
}); });
it('should ensure that extends is a Function', () => { it('should ensure that extends is a Function', () => {
expect(() => {(<Function>Class)({extends: 'non_type', constructor: function() {}})}) expect(() => { (<Function>Class)({extends: 'non_type', constructor: function() {}}); })
.toThrowError( .toThrowError(
'Class definition \'extends\' property must be a constructor function was: non_type'); 'Class definition \'extends\' property must be a constructor function was: non_type');
}); });

View File

@ -6,15 +6,14 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {Log, beforeEach, ddescribe, describe, expect, iit, inject, it, xdescribe, xit,} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, Log, beforeEach, ddescribe, describe, expect, iit, inject, it, xdescribe, xit,} from '@angular/core/testing/testing_internal';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {NgZone, NgZoneError} from '@angular/core/src/zone/ng_zone'; import {NgZone, NgZoneError} from '@angular/core/src/zone/ng_zone';
import {browserDetection} from '@angular/platform-browser/testing/browser_util'; import {browserDetection} from '@angular/platform-browser/testing/browser_util';
import {ObservableWrapper, PromiseCompleter, PromiseWrapper, TimerWrapper} from '../../src/facade/async'; import {ObservableWrapper, PromiseCompleter, PromiseWrapper, TimerWrapper} from '../../src/facade/async';
import {BaseException} from '../../src/facade/exceptions'; import {BaseException} from '../../src/facade/exceptions';
import {IS_DART, isPresent, scheduleMicroTask} from '../../src/facade/lang'; import {isPresent, scheduleMicroTask} from '../../src/facade/lang';
var needsLongerTimers = browserDetection.isSlow || browserDetection.isEdge; var needsLongerTimers = browserDetection.isSlow || browserDetection.isEdge;
var resultTimer = 1000; var resultTimer = 1000;
@ -443,7 +442,7 @@ function commonTests() {
macroTask(() => { macroTask(() => {
expect(_log.result()).toEqual('run'); expect(_log.result()).toEqual('run');
async.done() async.done();
}); });
}), testTimeout); }), testTimeout);

View File

@ -6,8 +6,7 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {describe, it, expect, beforeEach, ddescribe, iit, xit, inject,} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, describe, it, expect, beforeEach, ddescribe, iit, xit, inject,} from '@angular/core/testing/testing_internal';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {browserDetection} from '@angular/platform-browser/testing/browser_util'; import {browserDetection} from '@angular/platform-browser/testing/browser_util';
import {ObservableWrapper, Observable, Subject, EventEmitter, PromiseWrapper} from '../src/async'; import {ObservableWrapper, Observable, Subject, EventEmitter, PromiseWrapper} from '../src/async';

View File

@ -7,17 +7,15 @@
*/ */
import {NgFor, NgIf} from '@angular/common'; import {NgFor, NgIf} from '@angular/common';
import {Component, Directive, EventEmitter, Output} from '@angular/core'; import {Component, Directive, EventEmitter, Input, Output, forwardRef} from '@angular/core';
import {Input, Provider, forwardRef} from '@angular/core';
import {ComponentFixture, TestComponentBuilder, configureModule, fakeAsync, flushMicrotasks, tick} from '@angular/core/testing'; import {ComponentFixture, TestComponentBuilder, configureModule, fakeAsync, flushMicrotasks, tick} from '@angular/core/testing';
import {afterEach, beforeEach, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, afterEach, beforeEach, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal'; import {ControlValueAccessor, FormArray, FormControl, FormGroup, FormsModule, NG_ASYNC_VALIDATORS, NG_VALIDATORS, NgControl, NgForm, ReactiveFormsModule, Validator, Validators} from '@angular/forms';
import {ControlValueAccessor, FORM_DIRECTIVES, FORM_PROVIDERS, FormArray, FormControl, FormGroup, FormsModule, NG_ASYNC_VALIDATORS, NG_VALIDATORS, NgControl, NgForm, NgModel, REACTIVE_FORM_DIRECTIVES, ReactiveFormsModule, Validator, Validators} from '@angular/forms';
import {By} from '@angular/platform-browser/src/dom/debug/by'; import {By} from '@angular/platform-browser/src/dom/debug/by';
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter'; import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
import {dispatchEvent} from '@angular/platform-browser/testing/browser_util'; import {dispatchEvent} from '@angular/platform-browser/testing/browser_util';
import {ObservableWrapper, TimerWrapper} from '../src/facade/async'; import {ObservableWrapper} from '../src/facade/async';
import {ListWrapper} from '../src/facade/collection'; import {ListWrapper} from '../src/facade/collection';
import {PromiseWrapper} from '../src/facade/promise'; import {PromiseWrapper} from '../src/facade/promise';

View File

@ -7,12 +7,11 @@
*/ */
import {fakeAsync, flushMicrotasks, tick} from '@angular/core/testing'; import {fakeAsync, flushMicrotasks, tick} from '@angular/core/testing';
import {afterEach, beforeEach, ddescribe, describe, iit, inject, it, xit} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, afterEach, beforeEach, ddescribe, describe, iit, inject, it, xit} from '@angular/core/testing/testing_internal';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {FormArray, FormControl, FormGroup, Validators} from '@angular/forms'; import {FormArray, FormControl, FormGroup, Validators} from '@angular/forms';
import {EventEmitter, ObservableWrapper, TimerWrapper} from '../src/facade/async'; import {EventEmitter, ObservableWrapper, TimerWrapper} from '../src/facade/async';
import {IS_DART, isPresent} from '../src/facade/lang'; import {isPresent} from '../src/facade/lang';
import {PromiseWrapper} from '../src/facade/promise'; import {PromiseWrapper} from '../src/facade/promise';
export function main() { export function main() {
@ -492,17 +491,15 @@ export function main() {
})); }));
// TODO: remove the if statement after making observable delivery sync // TODO: remove the if statement after making observable delivery sync
if (!IS_DART) { it('should update set errors and status before emitting an event',
it('should update set errors and status before emitting an event', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { c.valueChanges.subscribe((value: any /** TODO #9100 */) => {
c.valueChanges.subscribe((value: any /** TODO #9100 */) => { expect(c.valid).toEqual(false);
expect(c.valid).toEqual(false); expect(c.errors).toEqual({'required': true});
expect(c.errors).toEqual({'required': true}); async.done();
async.done(); });
}); c.updateValue('');
c.updateValue(''); }));
}));
}
it('should return a cold observable', it('should return a cold observable',
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
@ -946,7 +943,7 @@ export function main() {
// rename contains into has // rename contains into has
it('should return false when the component is not included', it('should return false when the component is not included',
() => { expect(group.contains('optional')).toEqual(false); }) () => { expect(group.contains('optional')).toEqual(false); });
it('should return false when there is no component with the given name', it('should return false when there is no component with the given name',
() => { expect(group.contains('something else')).toEqual(false); }); () => { expect(group.contains('something else')).toEqual(false); });
@ -1066,11 +1063,8 @@ export function main() {
c2.updateValue('new2'); c2.updateValue('new2');
})); }));
xit('should not fire an event when an excluded control is updated', // hard to test without hacking zones
inject( // xit('should not fire an event when an excluded control is updated', () => null);
[AsyncTestCompleter], (async: AsyncTestCompleter) => {
// hard to test without hacking zones
}));
}); });
describe('statusChanges', () => { describe('statusChanges', () => {
@ -1143,7 +1137,7 @@ export function main() {
expect(g.errors).toEqual({'async': true}); expect(g.errors).toEqual({'async': true});
expect(g.find(['one']).errors).toEqual({'async': true}); expect(g.find(['one']).errors).toEqual({'async': true});
})); }));
}) });
}); });
describe('FormArray', () => { describe('FormArray', () => {
@ -1644,7 +1638,7 @@ export function main() {
expect(g.errors).toEqual({'async': true}); expect(g.errors).toEqual({'async': true});
expect(g.pending).toEqual(false); expect(g.pending).toEqual(false);
})); }));
}) });
}); });
}); });
} }

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {fakeAsync, flushMicrotasks, tick} from '@angular/core/testing'; import {fakeAsync, tick} from '@angular/core/testing';
import {afterEach, beforeEach, ddescribe, describe, expect, iit, it, xit} from '@angular/core/testing/testing_internal'; import {afterEach, beforeEach, ddescribe, describe, expect, iit, it, xit} from '@angular/core/testing/testing_internal';
import {AbstractControl, FormControl, Validators} from '@angular/forms'; import {AbstractControl, FormControl, Validators} from '@angular/forms';
import {Observable} from 'rxjs/Observable'; import {Observable} from 'rxjs/Observable';
@ -19,9 +19,9 @@ export function main() {
function validator(key: string, error: any) { function validator(key: string, error: any) {
return function(c: AbstractControl) { return function(c: AbstractControl) {
var r = {}; var r = {};
(r as any /** TODO #9100 */)[key] = error; (r as any)[key] = error;
return r; return r;
} };
} }
class AsyncValidatorDirective { class AsyncValidatorDirective {

View File

@ -6,13 +6,11 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {afterEach, beforeEach, ddescribe, describe, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, SpyObject, afterEach, beforeEach, ddescribe, describe, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal';
import {AsyncTestCompleter, SpyObject} from '@angular/core/testing/testing_internal';
import {ObservableWrapper} from '../../src/facade/async';
import {BrowserJsonp} from '../../src/backends/browser_jsonp'; import {BrowserJsonp} from '../../src/backends/browser_jsonp';
import {JSONPConnection, JSONPConnection_, JSONPBackend, JSONPBackend_} from '../../src/backends/jsonp_backend'; import {JSONPConnection, JSONPConnection_, JSONPBackend, JSONPBackend_} from '../../src/backends/jsonp_backend';
import {provide, Injector, ReflectiveInjector} from '@angular/core'; import {ReflectiveInjector} from '@angular/core';
import {isPresent, StringWrapper} from '../../src/facade/lang'; import {isPresent,} from '../../src/facade/lang';
import {TimerWrapper} from '../../src/facade/async'; import {TimerWrapper} from '../../src/facade/async';
import {Request} from '../../src/static_request'; import {Request} from '../../src/static_request';
import {Response} from '../../src/static_response'; import {Response} from '../../src/static_response';
@ -21,7 +19,6 @@ import {RequestOptions, BaseRequestOptions} from '../../src/base_request_options
import {BaseResponseOptions, ResponseOptions} from '../../src/base_response_options'; import {BaseResponseOptions, ResponseOptions} from '../../src/base_response_options';
import {ResponseType, ReadyState, RequestMethod} from '../../src/enums'; import {ResponseType, ReadyState, RequestMethod} from '../../src/enums';
var addEventListenerSpy: any;
var existingScripts: MockBrowserJsonp[] = []; var existingScripts: MockBrowserJsonp[] = [];
var unused: Response; var unused: Response;

View File

@ -6,19 +6,13 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {afterEach, beforeEach, ddescribe, describe, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, afterEach, beforeEach, ddescribe, describe, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {ObservableWrapper} from '../../src/facade/async';
import {BrowserXhr} from '../../src/backends/browser_xhr';
import {MockConnection, MockBackend} from '../../testing/mock_backend'; import {MockConnection, MockBackend} from '../../testing/mock_backend';
import {provide, Injector, ReflectiveInjector} from '@angular/core'; import {ReflectiveInjector} from '@angular/core';
import {Request} from '../../src/static_request'; import {Request} from '../../src/static_request';
import {Response} from '../../src/static_response'; import {Response} from '../../src/static_response';
import {Headers} from '../../src/headers';
import {Map} from '../../src/facade/collection';
import {RequestOptions, BaseRequestOptions} from '../../src/base_request_options'; import {RequestOptions, BaseRequestOptions} from '../../src/base_request_options';
import {BaseResponseOptions, ResponseOptions} from '../../src/base_response_options'; import {BaseResponseOptions, ResponseOptions} from '../../src/base_response_options';
import {ResponseType} from '../../src/enums';
import {ReplaySubject} from 'rxjs/ReplaySubject'; import {ReplaySubject} from 'rxjs/ReplaySubject';
export function main() { export function main() {
@ -41,10 +35,11 @@ export function main() {
sampleResponse2 = new Response(new ResponseOptions({body: 'response2'})); sampleResponse2 = new Response(new ResponseOptions({body: 'response2'}));
}); });
it('should create a new MockBackend', () => {expect(backend).toBeAnInstanceOf(MockBackend)}); it('should create a new MockBackend', () => { expect(backend).toBeAnInstanceOf(MockBackend); });
it('should create a new MockConnection', it('should create a new MockConnection', () => {
() => {expect(backend.createConnection(sampleRequest1)).toBeAnInstanceOf(MockConnection)}); expect(backend.createConnection(sampleRequest1)).toBeAnInstanceOf(MockConnection);
});
it('should create a new connection and allow subscription', () => { it('should create a new connection and allow subscription', () => {
let connection: MockConnection = backend.createConnection(sampleRequest1); let connection: MockConnection = backend.createConnection(sampleRequest1);

View File

@ -6,13 +6,12 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {afterEach, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, SpyObject, afterEach, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal';
import {AsyncTestCompleter, SpyObject} from '@angular/core/testing/testing_internal';
import {BrowserXhr} from '../../src/backends/browser_xhr'; import {BrowserXhr} from '../../src/backends/browser_xhr';
import {Json} from '../../src/facade/lang'; import {Json} from '../../src/facade/lang';
import {XSRFStrategy} from '../../src/interfaces'; import {XSRFStrategy} from '../../src/interfaces';
import {XHRConnection, XHRBackend, CookieXSRFStrategy} from '../../src/backends/xhr_backend'; import {XHRConnection, XHRBackend, CookieXSRFStrategy} from '../../src/backends/xhr_backend';
import {provide, Injector, Injectable, ReflectiveInjector} from '@angular/core'; import {Injectable,} from '@angular/core';
import {__platform_browser_private__} from '@angular/platform-browser'; import {__platform_browser_private__} from '@angular/platform-browser';
import {Request} from '../../src/static_request'; import {Request} from '../../src/static_request';
import {Response} from '../../src/static_response'; import {Response} from '../../src/static_response';
@ -146,7 +145,7 @@ export function main() {
backend.createConnection(sampleRequest); backend.createConnection(sampleRequest);
expect(sampleRequest.headers.get('X-MY-HEADER')).toBe('XSRF value'); expect(sampleRequest.headers.get('X-MY-HEADER')).toBe('XSRF value');
}); });
}) });
}); });
} }
@ -558,7 +557,7 @@ export function main() {
let responseHeaderString = `Date: Fri, 20 Nov 2015 01:45:26 GMT let responseHeaderString = `Date: Fri, 20 Nov 2015 01:45:26 GMT
Content-Type: application/json; charset=utf-8 Content-Type: application/json; charset=utf-8
Transfer-Encoding: chunked Transfer-Encoding: chunked
Connection: keep-alive` Connection: keep-alive`;
connection.response.subscribe((res: Response) => { connection.response.subscribe((res: Response) => {
expect(res.headers.get('Date')).toEqual('Fri, 20 Nov 2015 01:45:26 GMT'); expect(res.headers.get('Date')).toEqual('Fri, 20 Nov 2015 01:45:26 GMT');
@ -595,7 +594,7 @@ export function main() {
var connection = new XHRConnection( var connection = new XHRConnection(
sampleRequest, new MockBrowserXHR(), new ResponseOptions({status: statusCode})); sampleRequest, new MockBrowserXHR(), new ResponseOptions({status: statusCode}));
var responseHeaders = `X-Request-URL: http://somedomain.com var responseHeaders = `X-Request-URL: http://somedomain.com
Foo: Bar` Foo: Bar`;
connection.response.subscribe((res: Response) => { connection.response.subscribe((res: Response) => {
expect(res.url).toEqual('http://somedomain.com'); expect(res.url).toEqual('http://somedomain.com');
@ -643,7 +642,7 @@ export function main() {
var connection = var connection =
new XHRConnection(sampleRequest, mockXhr, new ResponseOptions({status: statusCode})); new XHRConnection(sampleRequest, mockXhr, new ResponseOptions({status: statusCode}));
var responseHeaders = `X-Request-URL: http://somedomain.com var responseHeaders = `X-Request-URL: http://somedomain.com
Foo: Bar` Foo: Bar`;
connection.response.subscribe((res: Response) => { connection.response.subscribe((res: Response) => {
expect(res.url).toEqual('http://somedomain.com'); expect(res.url).toEqual('http://somedomain.com');

View File

@ -6,11 +6,9 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {Injector, ReflectiveInjector, provide} from '@angular/core'; import {Injector, ReflectiveInjector} from '@angular/core';
import {afterEach, beforeEach, ddescribe, describe, expect, iit, inject, it, xit} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, afterEach, beforeEach, ddescribe, describe, expect, iit, inject, it, xit} from '@angular/core/testing/testing_internal';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {Observable} from 'rxjs/Observable'; import {Observable} from 'rxjs/Observable';
import {Subject} from 'rxjs/Subject';
import {zip} from 'rxjs/observable/zip'; import {zip} from 'rxjs/observable/zip';
import {BaseRequestOptions, ConnectionBackend, HTTP_PROVIDERS, Http, JSONPBackend, JSONP_PROVIDERS, Jsonp, Request, RequestMethod, RequestOptions, Response, ResponseContentType, ResponseOptions, URLSearchParams, XHRBackend} from '../http'; import {BaseRequestOptions, ConnectionBackend, HTTP_PROVIDERS, Http, JSONPBackend, JSONP_PROVIDERS, Jsonp, Request, RequestMethod, RequestOptions, Response, ResponseContentType, ResponseOptions, URLSearchParams, XHRBackend} from '../http';
@ -354,7 +352,7 @@ export function main() {
it('should allow case insensitive strings for method names', () => { it('should allow case insensitive strings for method names', () => {
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
backend.connections.subscribe((c: MockConnection) => { backend.connections.subscribe((c: MockConnection) => {
expect(c.request.method).toBe(RequestMethod.Post) expect(c.request.method).toBe(RequestMethod.Post);
c.mockRespond(new Response(new ResponseOptions({body: 'Thank you'}))); c.mockRespond(new Response(new ResponseOptions({body: 'Thank you'})));
async.done(); async.done();
}); });
@ -478,7 +476,7 @@ export function main() {
return stringToArrayBuffer(Json.stringify(message)); return stringToArrayBuffer(Json.stringify(message));
} }
}; };
c.mockRespond(new Response(new ResponseOptions({body: body()}))) c.mockRespond(new Response(new ResponseOptions({body: body()})));
}); });
zip(http.get( zip(http.get(

View File

@ -21,7 +21,8 @@ class FancyService {
value: string = 'real value'; value: string = 'real value';
getAsyncValue() { return Promise.resolve('async value'); } getAsyncValue() { return Promise.resolve('async value'); }
getTimeoutValue() { getTimeoutValue() {
return new Promise((resolve, reject) => { setTimeout(() => {resolve('timeout value')}, 10); }) return new Promise(
(resolve, reject) => { setTimeout(() => { resolve('timeout value'); }, 10); });
} }
} }
@ -88,8 +89,8 @@ export function main() {
var deferred = PromiseWrapper.completer(); var deferred = PromiseWrapper.completer();
originalJasmineIt = jasmine.getEnv().it; originalJasmineIt = jasmine.getEnv().it;
jasmine.getEnv().it = (description: string, fn: any /** TODO #9100 */) => { jasmine.getEnv().it = (description: string, fn: any /** TODO #9100 */) => {
var done = () => { deferred.resolve() }; var done = () => { deferred.resolve(); };
(<any>done).fail = (err: any /** TODO #9100 */) => { deferred.reject(err) }; (<any>done).fail = (err: any /** TODO #9100 */) => { deferred.reject(err); };
fn(done); fn(done);
return null; return null;
}; };

View File

@ -7,10 +7,9 @@
*/ */
import {UrlResolver, XHR} from '@angular/compiler'; import {UrlResolver, XHR} from '@angular/compiler';
import {Component, provide} from '@angular/core'; import {Component} from '@angular/core';
import {TestComponentBuilder, configureCompiler, fakeAsync, flushMicrotasks, tick} from '@angular/core/testing'; import {TestComponentBuilder, configureCompiler, fakeAsync, flushMicrotasks, tick} from '@angular/core/testing';
import {beforeEach, beforeEachProviders, ddescribe, describe, iit, inject, it, xit} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, beforeEach, beforeEachProviders, ddescribe, describe, iit, inject, it, xit} from '@angular/core/testing/testing_internal';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {expect} from '@angular/platform-browser/testing/matchers'; import {expect} from '@angular/platform-browser/testing/matchers';
import {BaseException} from '../../src/facade/exceptions'; import {BaseException} from '../../src/facade/exceptions';

View File

@ -91,6 +91,7 @@ export function main() {
} }
class FakeEventManagerPlugin extends EventManagerPlugin { class FakeEventManagerPlugin extends EventManagerPlugin {
/** @internal */
_eventHandler = new Map<string, Function>(); _eventHandler = new Map<string, Function>();
constructor(public _supports: string[]) { super(); } constructor(public _supports: string[]) { super(); }

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {AsyncTestCompleter, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal'; import {beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal';
import {el} from '@angular/platform-browser/testing/browser_util'; import {el} from '@angular/platform-browser/testing/browser_util';
import {AnimationKeyframe, AnimationStyles} from '../../core_private'; import {AnimationKeyframe, AnimationStyles} from '../../core_private';
@ -21,6 +21,7 @@ class ExtendedWebAnimationsDriver extends WebAnimationsDriver {
constructor() { super(); } constructor() { super(); }
/** @internal */
_triggerWebAnimation(elm: any, keyframes: any[], options: any): DomAnimatePlayer { _triggerWebAnimation(elm: any, keyframes: any[], options: any): DomAnimatePlayer {
this.log.push({'elm': elm, 'keyframes': keyframes, 'options': options}); this.log.push({'elm': elm, 'keyframes': keyframes, 'options': options});
return new MockDomAnimatePlayer(); return new MockDomAnimatePlayer();

View File

@ -22,6 +22,7 @@ class ExtendedWebAnimationsPlayer extends WebAnimationsPlayer {
super(element, keyframes, options); super(element, keyframes, options);
} }
/** @internal */
_triggerWebAnimation(elm: any, keyframes: any[], options: any): DomAnimatePlayer { _triggerWebAnimation(elm: any, keyframes: any[], options: any): DomAnimatePlayer {
return this.domPlayer; return this.domPlayer;
} }

View File

@ -70,7 +70,8 @@ class FancyService {
value: string = 'real value'; value: string = 'real value';
getAsyncValue() { return Promise.resolve('async value'); } getAsyncValue() { return Promise.resolve('async value'); }
getTimeoutValue() { getTimeoutValue() {
return new Promise((resolve, reject) => { setTimeout(() => {resolve('timeout value')}, 10); }) return new Promise(
(resolve, reject) => { setTimeout(() => { resolve('timeout value'); }, 10); });
} }
} }
@ -351,8 +352,8 @@ export function main() {
var deferred = PromiseWrapper.completer(); var deferred = PromiseWrapper.completer();
originalJasmineIt = jasmine.getEnv().it; originalJasmineIt = jasmine.getEnv().it;
jasmine.getEnv().it = (description: string, fn: any /** TODO #9100 */) => { jasmine.getEnv().it = (description: string, fn: any /** TODO #9100 */) => {
var done = () => { deferred.resolve() }; var done = () => { deferred.resolve(); };
(<any>done).fail = (err: any /** TODO #9100 */) => { deferred.reject(err) }; (<any>done).fail = (err: any /** TODO #9100 */) => { deferred.reject(err); };
fn(done); fn(done);
return null; return null;
}; };
@ -365,8 +366,8 @@ export function main() {
var deferred = PromiseWrapper.completer(); var deferred = PromiseWrapper.completer();
originalJasmineBeforeEach = jasmine.getEnv().beforeEach; originalJasmineBeforeEach = jasmine.getEnv().beforeEach;
jasmine.getEnv().beforeEach = (fn: any) => { jasmine.getEnv().beforeEach = (fn: any) => {
var done = () => { deferred.resolve() }; var done = () => { deferred.resolve(); };
(<any>done).fail = (err: any /** TODO #9100 */) => { deferred.reject(err) }; (<any>done).fail = (err: any /** TODO #9100 */) => { deferred.reject(err); };
fn(done); fn(done);
return null; return null;
}; };

View File

@ -6,10 +6,9 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {NgZone, provide} from '@angular/core'; import {NgZone} from '@angular/core';
import {withProviders} from '@angular/core/testing/test_bed'; import {withProviders} from '@angular/core/testing/test_bed';
import {MockNgZone, beforeEach, beforeEachProviders, describe, expect, inject, it} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, MockNgZone, beforeEach, beforeEachProviders, describe, expect, inject, it} from '@angular/core/testing/testing_internal';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {MessageBus} from '@angular/platform-browser/src/web_workers/shared/message_bus'; import {MessageBus} from '@angular/platform-browser/src/web_workers/shared/message_bus';
import {ObservableWrapper, TimerWrapper} from '../../../src/facade/async'; import {ObservableWrapper, TimerWrapper} from '../../../src/facade/async';

View File

@ -7,13 +7,12 @@
*/ */
import {NgZone} from '@angular/core/src/zone/ng_zone'; import {NgZone} from '@angular/core/src/zone/ng_zone';
import {UiArguments} from '@angular/platform-browser/src/web_workers/shared/client_message_broker'; import {ClientMessageBroker, ClientMessageBrokerFactory_, UiArguments} from '@angular/platform-browser/src/web_workers/shared/client_message_broker';
import {ClientMessageBroker, ClientMessageBrokerFactory_} from '@angular/platform-browser/src/web_workers/shared/client_message_broker';
import {MessageBus, MessageBusSink, MessageBusSource} from '@angular/platform-browser/src/web_workers/shared/message_bus'; import {MessageBus, MessageBusSink, MessageBusSource} from '@angular/platform-browser/src/web_workers/shared/message_bus';
import {PromiseWrapper} from '../../../src/facade/async'; import {PromiseWrapper} from '../../../src/facade/async';
import {ListWrapper, StringMapWrapper} from '../../../src/facade/collection'; import {ListWrapper, StringMapWrapper} from '../../../src/facade/collection';
import {BaseException, WrappedException} from '../../../src/facade/exceptions'; import {BaseException} from '../../../src/facade/exceptions';
import {Type, isPresent} from '../../../src/facade/lang'; import {Type, isPresent} from '../../../src/facade/lang';
import {SpyMessageBroker} from '../worker/spies'; import {SpyMessageBroker} from '../worker/spies';
@ -52,11 +51,11 @@ export function expectBrokerCall(
expect(args.method).toEqual(methodName); expect(args.method).toEqual(methodName);
if (isPresent(vals)) { if (isPresent(vals)) {
expect(args.args.length).toEqual(vals.length); expect(args.args.length).toEqual(vals.length);
ListWrapper.forEachWithIndex(vals, (v, i) => {expect(v).toEqual(args.args[i].value)}); ListWrapper.forEachWithIndex(vals, (v, i) => { expect(v).toEqual(args.args[i].value); });
} }
var promise: any /** TODO #9100 */ = null; var promise: any /** TODO #9100 */ = null;
if (isPresent(handler)) { if (isPresent(handler)) {
let givenValues = args.args.map((arg) => {arg.value}); let givenValues = args.args.map((arg) => arg.value);
if (givenValues.length > 0) { if (givenValues.length > 0) {
promise = handler(givenValues); promise = handler(givenValues);
} else { } else {

View File

@ -6,8 +6,7 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {beforeEach, beforeEachProviders, describe, expect, inject, it} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, beforeEach, beforeEachProviders, describe, expect, inject, it} from '@angular/core/testing/testing_internal';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {UiArguments} from '@angular/platform-browser/src/web_workers/shared/client_message_broker'; import {UiArguments} from '@angular/platform-browser/src/web_workers/shared/client_message_broker';
import {MessageBus} from '@angular/platform-browser/src/web_workers/shared/message_bus'; import {MessageBus} from '@angular/platform-browser/src/web_workers/shared/message_bus';
import {LocationType} from '@angular/platform-browser/src/web_workers/shared/serialized_types'; import {LocationType} from '@angular/platform-browser/src/web_workers/shared/serialized_types';

View File

@ -6,11 +6,10 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {inject, ddescribe, describe, it, iit, expect, beforeEach, beforeEachProviders,} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, inject, ddescribe, describe, it, iit, expect, beforeEach, beforeEachProviders,} from '@angular/core/testing/testing_internal';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {TestBed, TestComponentBuilder, configureModule} from '@angular/core/testing'; import {TestBed, TestComponentBuilder, configureModule} from '@angular/core/testing';
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter'; import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
import {provide, Injector, ViewMetadata, Component, Injectable, ComponentRef, ReflectiveInjector, getPlatform} from '@angular/core'; import {Injector, ViewMetadata, Component, Injectable, ComponentRef, ReflectiveInjector, getPlatform} from '@angular/core';
import {NgIf} from '@angular/common'; import {NgIf} from '@angular/common';
import {WebWorkerRootRenderer} from '@angular/platform-browser/src/web_workers/worker/renderer'; import {WebWorkerRootRenderer} from '@angular/platform-browser/src/web_workers/worker/renderer';
import {ClientMessageBrokerFactory, ClientMessageBrokerFactory_} from '@angular/platform-browser/src/web_workers/shared/client_message_broker'; import {ClientMessageBrokerFactory, ClientMessageBrokerFactory_} from '@angular/platform-browser/src/web_workers/shared/client_message_broker';
@ -22,10 +21,9 @@ import {RenderStore} from '@angular/platform-browser/src/web_workers/shared/rend
import {MessageBasedRenderer} from '@angular/platform-browser/src/web_workers/ui/renderer'; import {MessageBasedRenderer} from '@angular/platform-browser/src/web_workers/ui/renderer';
import {createPairedMessageBuses, PairedMessageBuses} from '../shared/web_worker_test_util'; import {createPairedMessageBuses, PairedMessageBuses} from '../shared/web_worker_test_util';
import {ServiceMessageBrokerFactory_} from '@angular/platform-browser/src/web_workers/shared/service_message_broker'; import {ServiceMessageBrokerFactory_} from '@angular/platform-browser/src/web_workers/shared/service_message_broker';
import {CompilerConfig} from '@angular/compiler';
import {dispatchEvent} from '../../../../platform-browser/testing/browser_util'; import {dispatchEvent} from '../../../../platform-browser/testing/browser_util';
import {BrowserTestModule} from '@angular/platform-browser/testing'; import {BrowserTestModule} from '@angular/platform-browser/testing';
import {browserDynamicTestPlatform} from '@angular/platform-browser-dynamic/testing' import {browserDynamicTestPlatform} from '@angular/platform-browser-dynamic/testing';
export function main() { export function main() {
function createWebWorkerBrokerFactory( function createWebWorkerBrokerFactory(
@ -58,205 +56,204 @@ export function main() {
return new DebugDomRootRenderer(workerRootRenderer); return new DebugDomRootRenderer(workerRootRenderer);
} }
describe( describe('Web Worker Renderer', () => {
'Web Worker Renderer', var uiInjector: Injector;
() => { var uiRenderStore: RenderStore;
var uiInjector: Injector; var workerRenderStore: RenderStore;
var uiRenderStore: RenderStore;
var workerRenderStore: RenderStore;
beforeEach(() => { beforeEach(() => {
uiRenderStore = new RenderStore(); uiRenderStore = new RenderStore();
var testUiInjector = new TestBed(); var testUiInjector = new TestBed();
testUiInjector.platform = browserDynamicTestPlatform(); testUiInjector.platform = browserDynamicTestPlatform();
testUiInjector.appModule = BrowserTestModule; testUiInjector.appModule = BrowserTestModule;
testUiInjector.configureModule({ testUiInjector.configureModule({
providers: [ providers: [
Serializer, {provide: RenderStore, useValue: uiRenderStore}, Serializer, {provide: RenderStore, useValue: uiRenderStore},
{provide: DomRootRenderer, useClass: DomRootRenderer_}, {provide: DomRootRenderer, useClass: DomRootRenderer_},
{provide: RootRenderer, useExisting: DomRootRenderer} {provide: RootRenderer, useExisting: DomRootRenderer}
] ]
});
testUiInjector.initTestAppModule();
var uiSerializer = testUiInjector.get(Serializer);
var domRootRenderer = testUiInjector.get(DomRootRenderer);
workerRenderStore = new RenderStore();
configureModule({
providers: [
Serializer, {provide: RenderStore, useValue: workerRenderStore}, {
provide: RootRenderer,
useFactory: (workerSerializer: Serializer) => {
return createWorkerRenderer(
workerSerializer, uiSerializer, domRootRenderer, uiRenderStore,
workerRenderStore);
},
deps: [Serializer]
}
]
});
});
function getRenderElement(workerEl: any) {
var id = workerRenderStore.serialize(workerEl);
return uiRenderStore.deserialize(id);
}
function getRenderer(componentRef: ComponentRef<any>) {
return (<any>componentRef.hostView).internalView.renderer;
}
it('should update text nodes',
inject(
[TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.overrideView(MyComp2, new ViewMetadata({template: '<div>{{ctxProp}}</div>'}))
.createAsync(MyComp2)
.then((fixture) => {
var renderEl = getRenderElement(fixture.debugElement.nativeElement);
expect(renderEl).toHaveText('');
fixture.debugElement.componentInstance.ctxProp = 'Hello World!';
fixture.detectChanges();
expect(renderEl).toHaveText('Hello World!');
async.done();
});
}));
it('should update any element property/attributes/class/style(s) independent of the compilation on the root element and other elements',
inject(
[TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.overrideView(
MyComp2, new ViewMetadata(
{template: '<input [title]="y" style="position:absolute">'}))
.createAsync(MyComp2)
.then((fixture) => {
var checkSetters =
(componentRef: any /** TODO #9100 */,
workerEl: any /** TODO #9100 */) => {
var renderer = getRenderer(componentRef);
var el = getRenderElement(workerEl);
renderer.setElementProperty(workerEl, 'tabIndex', 1);
expect((<HTMLInputElement>el).tabIndex).toEqual(1);
renderer.setElementClass(workerEl, 'a', true);
expect(getDOM().hasClass(el, 'a')).toBe(true);
renderer.setElementClass(workerEl, 'a', false);
expect(getDOM().hasClass(el, 'a')).toBe(false);
renderer.setElementStyle(workerEl, 'width', '10px');
expect(getDOM().getStyle(el, 'width')).toEqual('10px');
renderer.setElementStyle(workerEl, 'width', null);
expect(getDOM().getStyle(el, 'width')).toEqual('');
renderer.setElementAttribute(workerEl, 'someattr', 'someValue');
expect(getDOM().getAttribute(el, 'someattr')).toEqual('someValue');
};
// root element
checkSetters(fixture.componentRef, fixture.debugElement.nativeElement);
// nested elements
checkSetters(
fixture.componentRef, fixture.debugElement.children[0].nativeElement);
async.done();
});
}));
it('should update any template comment property/attributes',
inject(
[TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
var tpl = '<template [ngIf]="ctxBoolProp"></template>';
tcb.overrideView(MyComp2, new ViewMetadata({template: tpl, directives: [NgIf]}))
.createAsync(MyComp2)
.then((fixture) => {
(<MyComp2>fixture.debugElement.componentInstance).ctxBoolProp = true;
fixture.detectChanges();
var el = getRenderElement(fixture.debugElement.nativeElement);
expect(getDOM().getInnerHTML(el)).toContain('"ng-reflect-ng-if": "true"');
async.done();
});
}));
it('should add and remove fragments',
inject(
[TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.overrideView(MyComp2, new ViewMetadata({
template: '<template [ngIf]="ctxBoolProp">hello</template>',
directives: [NgIf]
}))
.createAsync(MyComp2)
.then((fixture) => {
var rootEl = getRenderElement(fixture.debugElement.nativeElement);
expect(rootEl).toHaveText('');
fixture.debugElement.componentInstance.ctxBoolProp = true;
fixture.detectChanges();
expect(rootEl).toHaveText('hello');
fixture.debugElement.componentInstance.ctxBoolProp = false;
fixture.detectChanges();
expect(rootEl).toHaveText('');
async.done();
});
}));
if (getDOM().supportsDOMEvents()) {
it('should call actions on the element',
inject(
[TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.overrideView(MyComp2, new ViewMetadata({template: '<input [title]="y">'}))
.createAsync(MyComp2)
.then((fixture) => {
var el = fixture.debugElement.children[0];
getRenderer(fixture.componentRef)
.invokeElementMethod(el.nativeElement, 'setAttribute', ['a', 'b']);
expect(getDOM().getAttribute(getRenderElement(el.nativeElement), 'a'))
.toEqual('b');
async.done();
});
}));
it('should listen to events',
inject(
[TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.overrideView(
MyComp2,
new ViewMetadata({template: '<input (change)="ctxNumProp = 1">'}))
.createAsync(MyComp2)
.then((fixture) => {
var el = fixture.debugElement.children[0];
dispatchEvent(getRenderElement(el.nativeElement), 'change');
expect(fixture.componentInstance.ctxNumProp).toBe(1);
fixture.destroy();
async.done();
});
}));
}
}); });
testUiInjector.initTestAppModule();
var uiSerializer = testUiInjector.get(Serializer);
var domRootRenderer = testUiInjector.get(DomRootRenderer);
workerRenderStore = new RenderStore();
configureModule({
providers: [
Serializer, {provide: RenderStore, useValue: workerRenderStore}, {
provide: RootRenderer,
useFactory: (workerSerializer: Serializer) => {
return createWorkerRenderer(
workerSerializer, uiSerializer, domRootRenderer, uiRenderStore,
workerRenderStore);
},
deps: [Serializer]
}
]
});
});
function getRenderElement(workerEl: any) {
var id = workerRenderStore.serialize(workerEl);
return uiRenderStore.deserialize(id);
}
function getRenderer(componentRef: ComponentRef<any>) {
return (<any>componentRef.hostView).internalView.renderer;
}
it('should update text nodes',
inject(
[TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.overrideView(MyComp2, new ViewMetadata({template: '<div>{{ctxProp}}</div>'}))
.createAsync(MyComp2)
.then((fixture) => {
var renderEl = getRenderElement(fixture.debugElement.nativeElement);
expect(renderEl).toHaveText('');
fixture.debugElement.componentInstance.ctxProp = 'Hello World!';
fixture.detectChanges();
expect(renderEl).toHaveText('Hello World!');
async.done();
});
}));
it('should update any element property/attributes/class/style(s) independent of the compilation on the root element and other elements',
inject(
[TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.overrideView(
MyComp2,
new ViewMetadata({template: '<input [title]="y" style="position:absolute">'}))
.createAsync(MyComp2)
.then((fixture) => {
var checkSetters =
(componentRef: any /** TODO #9100 */, workerEl: any /** TODO #9100 */) => {
var renderer = getRenderer(componentRef);
var el = getRenderElement(workerEl);
renderer.setElementProperty(workerEl, 'tabIndex', 1);
expect((<HTMLInputElement>el).tabIndex).toEqual(1);
renderer.setElementClass(workerEl, 'a', true);
expect(getDOM().hasClass(el, 'a')).toBe(true);
renderer.setElementClass(workerEl, 'a', false);
expect(getDOM().hasClass(el, 'a')).toBe(false);
renderer.setElementStyle(workerEl, 'width', '10px');
expect(getDOM().getStyle(el, 'width')).toEqual('10px');
renderer.setElementStyle(workerEl, 'width', null);
expect(getDOM().getStyle(el, 'width')).toEqual('');
renderer.setElementAttribute(workerEl, 'someattr', 'someValue');
expect(getDOM().getAttribute(el, 'someattr')).toEqual('someValue');
};
// root element
checkSetters(fixture.componentRef, fixture.debugElement.nativeElement);
// nested elements
checkSetters(
fixture.componentRef, fixture.debugElement.children[0].nativeElement);
async.done();
});
}));
it('should update any template comment property/attributes',
inject(
[TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
var tpl = '<template [ngIf]="ctxBoolProp"></template>';
tcb.overrideView(MyComp2, new ViewMetadata({template: tpl, directives: [NgIf]}))
.createAsync(MyComp2)
.then((fixture) => {
(<MyComp2>fixture.debugElement.componentInstance).ctxBoolProp = true;
fixture.detectChanges();
var el = getRenderElement(fixture.debugElement.nativeElement);
expect(getDOM().getInnerHTML(el)).toContain('"ng-reflect-ng-if": "true"');
async.done();
});
}));
it('should add and remove fragments',
inject(
[TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.overrideView(MyComp2, new ViewMetadata({
template: '<template [ngIf]="ctxBoolProp">hello</template>',
directives: [NgIf]
}))
.createAsync(MyComp2)
.then((fixture) => {
var rootEl = getRenderElement(fixture.debugElement.nativeElement);
expect(rootEl).toHaveText('');
fixture.debugElement.componentInstance.ctxBoolProp = true;
fixture.detectChanges();
expect(rootEl).toHaveText('hello');
fixture.debugElement.componentInstance.ctxBoolProp = false;
fixture.detectChanges();
expect(rootEl).toHaveText('');
async.done();
});
}));
if (getDOM().supportsDOMEvents()) {
it('should call actions on the element',
inject(
[TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.overrideView(MyComp2, new ViewMetadata({template: '<input [title]="y">'}))
.createAsync(MyComp2)
.then((fixture) => {
var el = fixture.debugElement.children[0];
getRenderer(fixture.componentRef)
.invokeElementMethod(el.nativeElement, 'setAttribute', ['a', 'b']);
expect(getDOM().getAttribute(getRenderElement(el.nativeElement), 'a'))
.toEqual('b');
async.done();
});
}));
it('should listen to events',
inject(
[TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.overrideView(
MyComp2, new ViewMetadata({template: '<input (change)="ctxNumProp = 1">'}))
.createAsync(MyComp2)
.then((fixture) => {
var el = fixture.debugElement.children[0];
dispatchEvent(getRenderElement(el.nativeElement), 'change');
expect(fixture.componentInstance.ctxNumProp).toBe(1);
fixture.destroy();
async.done();
});
}));
}
});
} }
@Component( @Component({selector: 'my-comp', directives: []})
{selector: 'my-comp', @Injectable()
directives: []}) @Injectable() class MyComp2 { class MyComp2 {
ctxProp: string; ctxNumProp: any /** TODO #9100 */; ctxBoolProp: boolean; constructor() { ctxProp: string;
ctxNumProp: any /** TODO #9100 */;
ctxBoolProp: boolean;
constructor() {
this.ctxProp = 'initial value'; this.ctxProp = 'initial value';
this.ctxNumProp = 0; this.ctxNumProp = 0;
this.ctxBoolProp = false; this.ctxBoolProp = false;
} }
throwError() { throw 'boom';} throwError() { throw 'boom'; }
} }

View File

@ -6,12 +6,11 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {beforeEach, ddescribe, xdescribe, describe, expect, iit, inject, beforeEachProviders, it, xit,} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, beforeEach, ddescribe, xdescribe, describe, expect, iit, inject, beforeEachProviders, it, xit,} from '@angular/core/testing/testing_internal';
import {TestComponentBuilder} from '@angular/core/testing'; import {TestComponentBuilder} from '@angular/core/testing';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {SpyRouter, SpyLocation} from '../spies'; import {SpyRouter, SpyLocation} from '../spies';
import {provide, Component} from '@angular/core'; import {Component} from '@angular/core';
import {Location} from '@angular/common'; import {Location} from '@angular/common';
import {Router, RouteRegistry, RouterLink, RouterOutlet, Route, RouteParams, ComponentInstruction} from '@angular/router-deprecated'; import {Router, RouteRegistry, RouterLink, RouterOutlet, Route, RouteParams, ComponentInstruction} from '@angular/router-deprecated';
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter'; import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';

View File

@ -13,8 +13,7 @@ import {ApplicationRef} from '@angular/core/src/application_ref';
import {Console} from '@angular/core/src/console'; import {Console} from '@angular/core/src/console';
import {Component} from '@angular/core/src/metadata'; import {Component} from '@angular/core/src/metadata';
import {TestComponentBuilder} from '@angular/core/testing'; import {TestComponentBuilder} from '@angular/core/testing';
import {MockApplicationRef, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, MockApplicationRef, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {bootstrap} from '@angular/platform-browser-dynamic'; import {bootstrap} from '@angular/platform-browser-dynamic';
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter'; import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
import {DOCUMENT} from '@angular/platform-browser/src/dom/dom_tokens'; import {DOCUMENT} from '@angular/platform-browser/src/dom/dom_tokens';

View File

@ -6,9 +6,8 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {beforeEach, beforeEachProviders, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, beforeEach, beforeEachProviders, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal';
import {ComponentFixture, TestComponentBuilder} from '@angular/core/testing'; import {ComponentFixture, TestComponentBuilder} from '@angular/core/testing';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {Location} from '@angular/common'; import {Location} from '@angular/common';
@ -40,7 +39,7 @@ function asyncRoutesWithoutChildrenWithRouteData() {
it('should inject route data into the component', it('should inject route data into the component',
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
compile(tcb) compile(tcb)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new AsyncRoute( .then((_) => rtr.config([new AsyncRoute(
{path: '/route-data', loader: asyncRouteDataCmp, data: {isAdmin: true}})])) {path: '/route-data', loader: asyncRouteDataCmp, data: {isAdmin: true}})]))
.then((_) => rtr.navigateByUrl('/route-data')) .then((_) => rtr.navigateByUrl('/route-data'))
@ -54,7 +53,7 @@ function asyncRoutesWithoutChildrenWithRouteData() {
it('should inject empty object if the route has no data property', it('should inject empty object if the route has no data property',
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
compile(tcb) compile(tcb)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new AsyncRoute( .then((_) => rtr.config([new AsyncRoute(
{path: '/route-data-default', loader: asyncRouteDataCmp})])) {path: '/route-data-default', loader: asyncRouteDataCmp})]))
.then((_) => rtr.navigateByUrl('/route-data-default')) .then((_) => rtr.navigateByUrl('/route-data-default'))
@ -82,7 +81,7 @@ function asyncRoutesWithoutChildrenWithoutParams() {
it('should navigate by URL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { it('should navigate by URL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
compile(tcb) compile(tcb)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new AsyncRoute( .then((_) => rtr.config([new AsyncRoute(
{path: '/test', loader: helloCmpLoader, name: 'Hello'})])) {path: '/test', loader: helloCmpLoader, name: 'Hello'})]))
.then((_) => rtr.navigateByUrl('/test')) .then((_) => rtr.navigateByUrl('/test'))
@ -95,7 +94,7 @@ function asyncRoutesWithoutChildrenWithoutParams() {
it('should navigate by link DSL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { it('should navigate by link DSL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
compile(tcb) compile(tcb)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new AsyncRoute( .then((_) => rtr.config([new AsyncRoute(
{path: '/test', loader: helloCmpLoader, name: 'Hello'})])) {path: '/test', loader: helloCmpLoader, name: 'Hello'})]))
.then((_) => rtr.navigate(['/Hello'])) .then((_) => rtr.navigate(['/Hello']))
@ -108,7 +107,7 @@ function asyncRoutesWithoutChildrenWithoutParams() {
it('should generate a link URL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { it('should generate a link URL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
compile(tcb, `<a [routerLink]="['Hello']">go to hello</a> | <router-outlet></router-outlet>`) compile(tcb, `<a [routerLink]="['Hello']">go to hello</a> | <router-outlet></router-outlet>`)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new AsyncRoute( .then((_) => rtr.config([new AsyncRoute(
{path: '/test', loader: helloCmpLoader, name: 'Hello'})])) {path: '/test', loader: helloCmpLoader, name: 'Hello'})]))
.then((_) => { .then((_) => {
@ -124,7 +123,7 @@ function asyncRoutesWithoutChildrenWithoutParams() {
(async: AsyncTestCompleter, location: any /** TODO #9100 */) => { (async: AsyncTestCompleter, location: any /** TODO #9100 */) => {
compile( compile(
tcb, `<a [routerLink]="['Hello']">go to hello</a> | <router-outlet></router-outlet>`) tcb, `<a [routerLink]="['Hello']">go to hello</a> | <router-outlet></router-outlet>`)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new AsyncRoute( .then((_) => rtr.config([new AsyncRoute(
{path: '/test', loader: helloCmpLoader, name: 'Hello'})])) {path: '/test', loader: helloCmpLoader, name: 'Hello'})]))
.then((_) => { .then((_) => {
@ -160,7 +159,7 @@ function asyncRoutesWithoutChildrenWithParams() {
it('should navigate by URL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { it('should navigate by URL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
compile(tcb) compile(tcb)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new AsyncRoute( .then((_) => rtr.config([new AsyncRoute(
{path: '/user/:name', loader: userCmpLoader, name: 'User'})])) {path: '/user/:name', loader: userCmpLoader, name: 'User'})]))
.then((_) => rtr.navigateByUrl('/user/igor')) .then((_) => rtr.navigateByUrl('/user/igor'))
@ -173,7 +172,7 @@ function asyncRoutesWithoutChildrenWithParams() {
it('should navigate by link DSL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { it('should navigate by link DSL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
compile(tcb) compile(tcb)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then( .then(
(_) => (_) =>
rtr.config([new Route({path: '/user/:name', component: UserCmp, name: 'User'})])) rtr.config([new Route({path: '/user/:name', component: UserCmp, name: 'User'})]))
@ -189,7 +188,7 @@ function asyncRoutesWithoutChildrenWithParams() {
compile( compile(
tcb, tcb,
`<a [routerLink]="['User', {name: 'naomi'}]">greet naomi</a> | <router-outlet></router-outlet>`) `<a [routerLink]="['User', {name: 'naomi'}]">greet naomi</a> | <router-outlet></router-outlet>`)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new AsyncRoute( .then((_) => rtr.config([new AsyncRoute(
{path: '/user/:name', loader: userCmpLoader, name: 'User'})])) {path: '/user/:name', loader: userCmpLoader, name: 'User'})]))
.then((_) => { .then((_) => {
@ -206,7 +205,7 @@ function asyncRoutesWithoutChildrenWithParams() {
compile( compile(
tcb, tcb,
`<a [routerLink]="['User', {name: 'naomi'}]">greet naomi</a> | <router-outlet></router-outlet>`) `<a [routerLink]="['User', {name: 'naomi'}]">greet naomi</a> | <router-outlet></router-outlet>`)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new AsyncRoute( .then((_) => rtr.config([new AsyncRoute(
{path: '/user/:name', loader: userCmpLoader, name: 'User'})])) {path: '/user/:name', loader: userCmpLoader, name: 'User'})]))
.then((_) => { .then((_) => {
@ -228,7 +227,7 @@ function asyncRoutesWithoutChildrenWithParams() {
it('should navigate between components with different parameters', it('should navigate between components with different parameters',
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
compile(tcb) compile(tcb)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new AsyncRoute( .then((_) => rtr.config([new AsyncRoute(
{path: '/user/:name', loader: userCmpLoader, name: 'User'})])) {path: '/user/:name', loader: userCmpLoader, name: 'User'})]))
.then((_) => rtr.navigateByUrl('/user/brian')) .then((_) => rtr.navigateByUrl('/user/brian'))
@ -262,7 +261,7 @@ function asyncRoutesWithSyncChildrenWithoutDefaultRoutes() {
it('should navigate by URL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { it('should navigate by URL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
compile(tcb, `outer [ <router-outlet></router-outlet> ]`) compile(tcb, `outer [ <router-outlet></router-outlet> ]`)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new AsyncRoute( .then((_) => rtr.config([new AsyncRoute(
{path: '/a/...', loader: parentCmpLoader, name: 'Parent'})])) {path: '/a/...', loader: parentCmpLoader, name: 'Parent'})]))
.then((_) => rtr.navigateByUrl('/a/b')) .then((_) => rtr.navigateByUrl('/a/b'))
@ -275,7 +274,7 @@ function asyncRoutesWithSyncChildrenWithoutDefaultRoutes() {
it('should navigate by link DSL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { it('should navigate by link DSL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
compile(tcb, `outer [ <router-outlet></router-outlet> ]`) compile(tcb, `outer [ <router-outlet></router-outlet> ]`)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new AsyncRoute( .then((_) => rtr.config([new AsyncRoute(
{path: '/a/...', loader: parentCmpLoader, name: 'Parent'})])) {path: '/a/...', loader: parentCmpLoader, name: 'Parent'})]))
.then((_) => rtr.navigate(['/Parent', 'Child'])) .then((_) => rtr.navigate(['/Parent', 'Child']))
@ -290,7 +289,7 @@ function asyncRoutesWithSyncChildrenWithoutDefaultRoutes() {
compile( compile(
tcb, tcb,
`<a [routerLink]="['Parent']">nav to child</a> | outer [ <router-outlet></router-outlet> ]`) `<a [routerLink]="['Parent']">nav to child</a> | outer [ <router-outlet></router-outlet> ]`)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new AsyncRoute( .then((_) => rtr.config([new AsyncRoute(
{path: '/a/...', loader: parentCmpLoader, name: 'Parent'})])) {path: '/a/...', loader: parentCmpLoader, name: 'Parent'})]))
.then((_) => { .then((_) => {
@ -307,7 +306,7 @@ function asyncRoutesWithSyncChildrenWithoutDefaultRoutes() {
compile( compile(
tcb, tcb,
`<a [routerLink]="['Parent', 'Child']">nav to child</a> | outer [ <router-outlet></router-outlet> ]`) `<a [routerLink]="['Parent', 'Child']">nav to child</a> | outer [ <router-outlet></router-outlet> ]`)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new AsyncRoute( .then((_) => rtr.config([new AsyncRoute(
{path: '/a/...', loader: parentCmpLoader, name: 'Parent'})])) {path: '/a/...', loader: parentCmpLoader, name: 'Parent'})]))
.then((_) => { .then((_) => {
@ -344,7 +343,7 @@ function asyncRoutesWithSyncChildrenWithDefaultRoutes() {
it('should navigate by URL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { it('should navigate by URL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
compile(tcb, `outer [ <router-outlet></router-outlet> ]`) compile(tcb, `outer [ <router-outlet></router-outlet> ]`)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new AsyncRoute( .then((_) => rtr.config([new AsyncRoute(
{path: '/a/...', loader: parentWithDefaultCmpLoader, name: 'Parent'})])) {path: '/a/...', loader: parentWithDefaultCmpLoader, name: 'Parent'})]))
.then((_) => rtr.navigateByUrl('/a')) .then((_) => rtr.navigateByUrl('/a'))
@ -357,7 +356,7 @@ function asyncRoutesWithSyncChildrenWithDefaultRoutes() {
it('should navigate by link DSL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { it('should navigate by link DSL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
compile(tcb, `outer [ <router-outlet></router-outlet> ]`) compile(tcb, `outer [ <router-outlet></router-outlet> ]`)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new AsyncRoute( .then((_) => rtr.config([new AsyncRoute(
{path: '/a/...', loader: parentWithDefaultCmpLoader, name: 'Parent'})])) {path: '/a/...', loader: parentWithDefaultCmpLoader, name: 'Parent'})]))
.then((_) => rtr.navigate(['/Parent'])) .then((_) => rtr.navigate(['/Parent']))
@ -372,7 +371,7 @@ function asyncRoutesWithSyncChildrenWithDefaultRoutes() {
compile( compile(
tcb, tcb,
`<a [routerLink]="['/Parent']">link to inner</a> | outer [ <router-outlet></router-outlet> ]`) `<a [routerLink]="['/Parent']">link to inner</a> | outer [ <router-outlet></router-outlet> ]`)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new AsyncRoute( .then((_) => rtr.config([new AsyncRoute(
{path: '/a/...', loader: parentWithDefaultCmpLoader, name: 'Parent'})])) {path: '/a/...', loader: parentWithDefaultCmpLoader, name: 'Parent'})]))
.then((_) => { .then((_) => {
@ -389,7 +388,7 @@ function asyncRoutesWithSyncChildrenWithDefaultRoutes() {
compile( compile(
tcb, tcb,
`<a [routerLink]="['/Parent']">link to inner</a> | outer [ <router-outlet></router-outlet> ]`) `<a [routerLink]="['/Parent']">link to inner</a> | outer [ <router-outlet></router-outlet> ]`)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new AsyncRoute( .then((_) => rtr.config([new AsyncRoute(
{path: '/a/...', loader: parentWithDefaultCmpLoader, name: 'Parent'})])) {path: '/a/...', loader: parentWithDefaultCmpLoader, name: 'Parent'})]))
.then((_) => { .then((_) => {
@ -427,7 +426,7 @@ function asyncRoutesWithAsyncChildrenWithoutParamsWithoutDefaultRoutes() {
it('should navigate by URL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { it('should navigate by URL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
compile(tcb, `outer [ <router-outlet></router-outlet> ]`) compile(tcb, `outer [ <router-outlet></router-outlet> ]`)
.then((rtc) => {rootTC = rtc}) .then((rtc) => { rootTC = rtc; })
.then((_) => rtr.config([new AsyncRoute( .then((_) => rtr.config([new AsyncRoute(
{path: '/a/...', loader: asyncParentCmpLoader, name: 'Parent'})])) {path: '/a/...', loader: asyncParentCmpLoader, name: 'Parent'})]))
.then((_) => rtr.navigateByUrl('/a/b')) .then((_) => rtr.navigateByUrl('/a/b'))
@ -440,7 +439,7 @@ function asyncRoutesWithAsyncChildrenWithoutParamsWithoutDefaultRoutes() {
it('should navigate by link DSL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { it('should navigate by link DSL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
compile(tcb, `outer [ <router-outlet></router-outlet> ]`) compile(tcb, `outer [ <router-outlet></router-outlet> ]`)
.then((rtc) => {rootTC = rtc}) .then((rtc) => { rootTC = rtc; })
.then((_) => rtr.config([new AsyncRoute( .then((_) => rtr.config([new AsyncRoute(
{path: '/a/...', loader: asyncParentCmpLoader, name: 'Parent'})])) {path: '/a/...', loader: asyncParentCmpLoader, name: 'Parent'})]))
.then((_) => rtr.navigate(['/Parent', 'Child'])) .then((_) => rtr.navigate(['/Parent', 'Child']))
@ -455,7 +454,7 @@ function asyncRoutesWithAsyncChildrenWithoutParamsWithoutDefaultRoutes() {
compile( compile(
tcb, tcb,
`<a [routerLink]="['Parent', 'Child']">nav to child</a> | outer [ <router-outlet></router-outlet> ]`) `<a [routerLink]="['Parent', 'Child']">nav to child</a> | outer [ <router-outlet></router-outlet> ]`)
.then((rtc) => {rootTC = rtc}) .then((rtc) => { rootTC = rtc; })
.then((_) => rtr.config([new AsyncRoute( .then((_) => rtr.config([new AsyncRoute(
{path: '/a/...', loader: asyncParentCmpLoader, name: 'Parent'})])) {path: '/a/...', loader: asyncParentCmpLoader, name: 'Parent'})]))
.then((_) => { .then((_) => {
@ -472,7 +471,7 @@ function asyncRoutesWithAsyncChildrenWithoutParamsWithoutDefaultRoutes() {
compile( compile(
tcb, tcb,
`<a [routerLink]="['Parent', 'Child']">nav to child</a> | outer [ <router-outlet></router-outlet> ]`) `<a [routerLink]="['Parent', 'Child']">nav to child</a> | outer [ <router-outlet></router-outlet> ]`)
.then((rtc) => {rootTC = rtc}) .then((rtc) => { rootTC = rtc; })
.then((_) => rtr.config([new AsyncRoute( .then((_) => rtr.config([new AsyncRoute(
{path: '/a/...', loader: asyncParentCmpLoader, name: 'Parent'})])) {path: '/a/...', loader: asyncParentCmpLoader, name: 'Parent'})]))
.then((_) => { .then((_) => {
@ -509,7 +508,7 @@ function asyncRoutesWithAsyncChildrenWithoutParamsWithDefaultRoutes() {
it('should navigate by URL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { it('should navigate by URL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
compile(tcb, `outer [ <router-outlet></router-outlet> ]`) compile(tcb, `outer [ <router-outlet></router-outlet> ]`)
.then((rtc) => {rootTC = rtc}) .then((rtc) => { rootTC = rtc; })
.then((_) => rtr.config([new AsyncRoute( .then((_) => rtr.config([new AsyncRoute(
{path: '/a/...', loader: asyncDefaultParentCmpLoader, name: 'Parent'})])) {path: '/a/...', loader: asyncDefaultParentCmpLoader, name: 'Parent'})]))
.then((_) => rtr.navigateByUrl('/a')) .then((_) => rtr.navigateByUrl('/a'))
@ -522,7 +521,7 @@ function asyncRoutesWithAsyncChildrenWithoutParamsWithDefaultRoutes() {
it('should navigate by link DSL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { it('should navigate by link DSL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
compile(tcb, `outer [ <router-outlet></router-outlet> ]`) compile(tcb, `outer [ <router-outlet></router-outlet> ]`)
.then((rtc) => {rootTC = rtc}) .then((rtc) => { rootTC = rtc; })
.then((_) => rtr.config([new AsyncRoute( .then((_) => rtr.config([new AsyncRoute(
{path: '/a/...', loader: asyncDefaultParentCmpLoader, name: 'Parent'})])) {path: '/a/...', loader: asyncDefaultParentCmpLoader, name: 'Parent'})]))
.then((_) => rtr.navigate(['/Parent'])) .then((_) => rtr.navigate(['/Parent']))
@ -537,7 +536,7 @@ function asyncRoutesWithAsyncChildrenWithoutParamsWithDefaultRoutes() {
compile( compile(
tcb, tcb,
`<a [routerLink]="['Parent']">nav to child</a> | outer [ <router-outlet></router-outlet> ]`) `<a [routerLink]="['Parent']">nav to child</a> | outer [ <router-outlet></router-outlet> ]`)
.then((rtc) => {rootTC = rtc}) .then((rtc) => { rootTC = rtc; })
.then((_) => rtr.config([new AsyncRoute( .then((_) => rtr.config([new AsyncRoute(
{path: '/a/...', loader: asyncDefaultParentCmpLoader, name: 'Parent'})])) {path: '/a/...', loader: asyncDefaultParentCmpLoader, name: 'Parent'})]))
.then((_) => { .then((_) => {
@ -554,7 +553,7 @@ function asyncRoutesWithAsyncChildrenWithoutParamsWithDefaultRoutes() {
compile( compile(
tcb, tcb,
`<a [routerLink]="['Parent']">nav to child</a> | outer [ <router-outlet></router-outlet> ]`) `<a [routerLink]="['Parent']">nav to child</a> | outer [ <router-outlet></router-outlet> ]`)
.then((rtc) => {rootTC = rtc}) .then((rtc) => { rootTC = rtc; })
.then((_) => rtr.config([new AsyncRoute( .then((_) => rtr.config([new AsyncRoute(
{path: '/a/...', loader: asyncDefaultParentCmpLoader, name: 'Parent'})])) {path: '/a/...', loader: asyncDefaultParentCmpLoader, name: 'Parent'})]))
.then((_) => { .then((_) => {
@ -591,7 +590,7 @@ function asyncRoutesWithAsyncChildrenWithParamsWithoutDefaultRoutes() {
it('should navigate by URL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { it('should navigate by URL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
compile(tcb, `[ <router-outlet></router-outlet> ]`) compile(tcb, `[ <router-outlet></router-outlet> ]`)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new AsyncRoute( .then((_) => rtr.config([new AsyncRoute(
{path: '/team/:id/...', loader: asyncTeamLoader, name: 'Team'})])) {path: '/team/:id/...', loader: asyncTeamLoader, name: 'Team'})]))
.then((_) => rtr.navigateByUrl('/team/angular/user/matias')) .then((_) => rtr.navigateByUrl('/team/angular/user/matias'))
@ -605,7 +604,7 @@ function asyncRoutesWithAsyncChildrenWithParamsWithoutDefaultRoutes() {
it('should navigate by link DSL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { it('should navigate by link DSL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
compile(tcb, `[ <router-outlet></router-outlet> ]`) compile(tcb, `[ <router-outlet></router-outlet> ]`)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new AsyncRoute( .then((_) => rtr.config([new AsyncRoute(
{path: '/team/:id/...', loader: asyncTeamLoader, name: 'Team'})])) {path: '/team/:id/...', loader: asyncTeamLoader, name: 'Team'})]))
.then((_) => rtr.navigate(['/Team', {id: 'angular'}, 'User', {name: 'matias'}])) .then((_) => rtr.navigate(['/Team', {id: 'angular'}, 'User', {name: 'matias'}]))
@ -621,7 +620,7 @@ function asyncRoutesWithAsyncChildrenWithParamsWithoutDefaultRoutes() {
compile( compile(
tcb, tcb,
`<a [routerLink]="['/Team', {id: 'angular'}, 'User', {name: 'matias'}]">nav to matias</a> [ <router-outlet></router-outlet> ]`) `<a [routerLink]="['/Team', {id: 'angular'}, 'User', {name: 'matias'}]">nav to matias</a> [ <router-outlet></router-outlet> ]`)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new AsyncRoute( .then((_) => rtr.config([new AsyncRoute(
{path: '/team/:id/...', loader: asyncTeamLoader, name: 'Team'})])) {path: '/team/:id/...', loader: asyncTeamLoader, name: 'Team'})]))
.then((_) => { .then((_) => {
@ -638,7 +637,7 @@ function asyncRoutesWithAsyncChildrenWithParamsWithoutDefaultRoutes() {
compile( compile(
tcb, tcb,
`<a [routerLink]="['/Team', {id: 'angular'}, 'User', {name: 'matias'}]">nav to matias</a> [ <router-outlet></router-outlet> ]`) `<a [routerLink]="['/Team', {id: 'angular'}, 'User', {name: 'matias'}]">nav to matias</a> [ <router-outlet></router-outlet> ]`)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new AsyncRoute( .then((_) => rtr.config([new AsyncRoute(
{path: '/team/:id/...', loader: asyncTeamLoader, name: 'Team'})])) {path: '/team/:id/...', loader: asyncTeamLoader, name: 'Team'})]))
.then((_) => { .then((_) => {

View File

@ -9,8 +9,7 @@
import {Location} from '@angular/common'; import {Location} from '@angular/common';
import {Component} from '@angular/core'; import {Component} from '@angular/core';
import {ComponentFixture, TestComponentBuilder} from '@angular/core/testing'; import {ComponentFixture, TestComponentBuilder} from '@angular/core/testing';
import {beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {By} from '@angular/platform-browser/src/dom/debug/by'; import {By} from '@angular/platform-browser/src/dom/debug/by';
import {AuxRoute, ROUTER_DIRECTIVES, Route, RouteConfig, Router} from '@angular/router-deprecated'; import {AuxRoute, ROUTER_DIRECTIVES, Route, RouteConfig, Router} from '@angular/router-deprecated';
@ -38,7 +37,7 @@ function auxRoutes() {
compile( compile(
tcb, tcb,
`main [<router-outlet></router-outlet>] | aux [<router-outlet name="modal"></router-outlet>]`) `main [<router-outlet></router-outlet>] | aux [<router-outlet name="modal"></router-outlet>]`)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([ .then((_) => rtr.config([
new Route({path: '/hello', component: HelloCmp, name: 'Hello'}), new Route({path: '/hello', component: HelloCmp, name: 'Hello'}),
new AuxRoute({path: '/modal', component: ModalCmp, name: 'Aux'}) new AuxRoute({path: '/modal', component: ModalCmp, name: 'Aux'})
@ -56,7 +55,7 @@ function auxRoutes() {
compile( compile(
tcb, tcb,
`main [<router-outlet></router-outlet>] | aux [<router-outlet name="modal"></router-outlet>]`) `main [<router-outlet></router-outlet>] | aux [<router-outlet name="modal"></router-outlet>]`)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([ .then((_) => rtr.config([
new Route({path: '/hello', component: HelloCmp, name: 'Hello'}), new Route({path: '/hello', component: HelloCmp, name: 'Hello'}),
new AuxRoute({path: '/modal', component: ModalCmp, name: 'Modal'}) new AuxRoute({path: '/modal', component: ModalCmp, name: 'Modal'})
@ -73,7 +72,7 @@ function auxRoutes() {
compile( compile(
tcb, tcb,
`<a [routerLink]="['/', ['Modal']]">open modal</a> | main [<router-outlet></router-outlet>] | aux [<router-outlet name="modal"></router-outlet>]`) `<a [routerLink]="['/', ['Modal']]">open modal</a> | main [<router-outlet></router-outlet>] | aux [<router-outlet name="modal"></router-outlet>]`)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([ .then((_) => rtr.config([
new Route({path: '/hello', component: HelloCmp, name: 'Hello'}), new Route({path: '/hello', component: HelloCmp, name: 'Hello'}),
new AuxRoute({path: '/modal', component: ModalCmp, name: 'Modal'}) new AuxRoute({path: '/modal', component: ModalCmp, name: 'Modal'})
@ -92,7 +91,7 @@ function auxRoutes() {
compile( compile(
tcb, tcb,
`<a [routerLink]="['/', ['Modal']]">open modal</a> | <a [routerLink]="['/Hello']">hello</a> | main [<router-outlet></router-outlet>] | aux [<router-outlet name="modal"></router-outlet>]`) `<a [routerLink]="['/', ['Modal']]">open modal</a> | <a [routerLink]="['/Hello']">hello</a> | main [<router-outlet></router-outlet>] | aux [<router-outlet name="modal"></router-outlet>]`)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([ .then((_) => rtr.config([
new Route({path: '/hello', component: HelloCmp, name: 'Hello'}), new Route({path: '/hello', component: HelloCmp, name: 'Hello'}),
new AuxRoute({path: '/modal', component: ModalCmp, name: 'Modal'}) new AuxRoute({path: '/modal', component: ModalCmp, name: 'Modal'})
@ -151,7 +150,7 @@ function auxRoutesWithAPrimaryRoute() {
compile( compile(
tcb, tcb,
`main [<router-outlet></router-outlet>] | aux [<router-outlet name="modal"></router-outlet>]`) `main [<router-outlet></router-outlet>] | aux [<router-outlet name="modal"></router-outlet>]`)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([ .then((_) => rtr.config([
new Route({path: '/hello', component: HelloCmp, name: 'Hello'}), new Route({path: '/hello', component: HelloCmp, name: 'Hello'}),
new AuxRoute({path: '/modal', component: ModalCmp, name: 'Aux'}) new AuxRoute({path: '/modal', component: ModalCmp, name: 'Aux'})
@ -169,7 +168,7 @@ function auxRoutesWithAPrimaryRoute() {
compile( compile(
tcb, tcb,
`main [<router-outlet></router-outlet>] | aux [<router-outlet name="modal"></router-outlet>]`) `main [<router-outlet></router-outlet>] | aux [<router-outlet name="modal"></router-outlet>]`)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([ .then((_) => rtr.config([
new Route({path: '/hello', component: HelloCmp, name: 'Hello'}), new Route({path: '/hello', component: HelloCmp, name: 'Hello'}),
new AuxRoute({path: '/modal', component: ModalCmp, name: 'Modal'}) new AuxRoute({path: '/modal', component: ModalCmp, name: 'Modal'})
@ -186,7 +185,7 @@ function auxRoutesWithAPrimaryRoute() {
compile( compile(
tcb, tcb,
`<a [routerLink]="['/Hello', ['Modal']]">open modal</a> | main [<router-outlet></router-outlet>] | aux [<router-outlet name="modal"></router-outlet>]`) `<a [routerLink]="['/Hello', ['Modal']]">open modal</a> | main [<router-outlet></router-outlet>] | aux [<router-outlet name="modal"></router-outlet>]`)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([ .then((_) => rtr.config([
new Route({path: '/hello', component: HelloCmp, name: 'Hello'}), new Route({path: '/hello', component: HelloCmp, name: 'Hello'}),
new AuxRoute({path: '/modal', component: ModalCmp, name: 'Modal'}) new AuxRoute({path: '/modal', component: ModalCmp, name: 'Modal'})
@ -205,7 +204,7 @@ function auxRoutesWithAPrimaryRoute() {
compile( compile(
tcb, tcb,
`<a [routerLink]="['/Hello', ['Modal']]">open modal</a> | main [<router-outlet></router-outlet>] | aux [<router-outlet name="modal"></router-outlet>]`) `<a [routerLink]="['/Hello', ['Modal']]">open modal</a> | main [<router-outlet></router-outlet>] | aux [<router-outlet name="modal"></router-outlet>]`)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([ .then((_) => rtr.config([
new Route({path: '/hello', component: HelloCmp, name: 'Hello'}), new Route({path: '/hello', component: HelloCmp, name: 'Hello'}),
new AuxRoute({path: '/modal', component: ModalCmp, name: 'Modal'}) new AuxRoute({path: '/modal', component: ModalCmp, name: 'Modal'})

View File

@ -6,8 +6,7 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {beforeEach, beforeEachProviders, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, beforeEach, beforeEachProviders, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {ComponentFixture, TestComponentBuilder} from '@angular/core/testing'; import {ComponentFixture, TestComponentBuilder} from '@angular/core/testing';
import {specs, compile, TEST_ROUTER_PROVIDERS, clickOnElement, getHref} from '../util'; import {specs, compile, TEST_ROUTER_PROVIDERS, clickOnElement, getHref} from '../util';
@ -38,7 +37,7 @@ function syncRoutesWithoutChildrenWithoutParams() {
it('should navigate by URL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { it('should navigate by URL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
compile(tcb) compile(tcb)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then( .then(
(_) => rtr.config([new Route({path: '/test', component: HelloCmp, name: 'Hello'})])) (_) => rtr.config([new Route({path: '/test', component: HelloCmp, name: 'Hello'})]))
.then((_) => rtr.navigateByUrl('/test')) .then((_) => rtr.navigateByUrl('/test'))
@ -51,7 +50,7 @@ function syncRoutesWithoutChildrenWithoutParams() {
it('should navigate by link DSL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { it('should navigate by link DSL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
compile(tcb) compile(tcb)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then( .then(
(_) => rtr.config([new Route({path: '/test', component: HelloCmp, name: 'Hello'})])) (_) => rtr.config([new Route({path: '/test', component: HelloCmp, name: 'Hello'})]))
.then((_) => rtr.navigate(['/Hello'])) .then((_) => rtr.navigate(['/Hello']))
@ -64,7 +63,7 @@ function syncRoutesWithoutChildrenWithoutParams() {
it('should generate a link URL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { it('should generate a link URL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
compile(tcb, `<a [routerLink]="['Hello']">go to hello</a> | <router-outlet></router-outlet>`) compile(tcb, `<a [routerLink]="['Hello']">go to hello</a> | <router-outlet></router-outlet>`)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then( .then(
(_) => rtr.config([new Route({path: '/test', component: HelloCmp, name: 'Hello'})])) (_) => rtr.config([new Route({path: '/test', component: HelloCmp, name: 'Hello'})]))
.then((_) => { .then((_) => {
@ -80,7 +79,7 @@ function syncRoutesWithoutChildrenWithoutParams() {
(async: AsyncTestCompleter, location: any /** TODO #9100 */) => { (async: AsyncTestCompleter, location: any /** TODO #9100 */) => {
compile( compile(
tcb, `<a [routerLink]="['Hello']">go to hello</a> | <router-outlet></router-outlet>`) tcb, `<a [routerLink]="['Hello']">go to hello</a> | <router-outlet></router-outlet>`)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then( .then(
(_) => (_) =>
rtr.config([new Route({path: '/test', component: HelloCmp, name: 'Hello'})])) rtr.config([new Route({path: '/test', component: HelloCmp, name: 'Hello'})]))
@ -117,7 +116,7 @@ function syncRoutesWithoutChildrenWithParams() {
it('should navigate by URL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { it('should navigate by URL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
compile(tcb) compile(tcb)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then( .then(
(_) => (_) =>
rtr.config([new Route({path: '/user/:name', component: UserCmp, name: 'User'})])) rtr.config([new Route({path: '/user/:name', component: UserCmp, name: 'User'})]))
@ -131,7 +130,7 @@ function syncRoutesWithoutChildrenWithParams() {
it('should navigate by link DSL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { it('should navigate by link DSL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
compile(tcb) compile(tcb)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then( .then(
(_) => (_) =>
rtr.config([new Route({path: '/user/:name', component: UserCmp, name: 'User'})])) rtr.config([new Route({path: '/user/:name', component: UserCmp, name: 'User'})]))
@ -147,7 +146,7 @@ function syncRoutesWithoutChildrenWithParams() {
compile( compile(
tcb, tcb,
`<a [routerLink]="['User', {name: 'naomi'}]">greet naomi</a> | <router-outlet></router-outlet>`) `<a [routerLink]="['User', {name: 'naomi'}]">greet naomi</a> | <router-outlet></router-outlet>`)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then( .then(
(_) => (_) =>
rtr.config([new Route({path: '/user/:name', component: UserCmp, name: 'User'})])) rtr.config([new Route({path: '/user/:name', component: UserCmp, name: 'User'})]))
@ -165,7 +164,7 @@ function syncRoutesWithoutChildrenWithParams() {
compile( compile(
tcb, tcb,
`<a [routerLink]="['User', {name: 'naomi'}]">greet naomi</a> | <router-outlet></router-outlet>`) `<a [routerLink]="['User', {name: 'naomi'}]">greet naomi</a> | <router-outlet></router-outlet>`)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new Route( .then((_) => rtr.config([new Route(
{path: '/user/:name', component: UserCmp, name: 'User'})])) {path: '/user/:name', component: UserCmp, name: 'User'})]))
.then((_) => { .then((_) => {
@ -187,7 +186,7 @@ function syncRoutesWithoutChildrenWithParams() {
it('should navigate between components with different parameters', it('should navigate between components with different parameters',
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
compile(tcb) compile(tcb)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then( .then(
(_) => (_) =>
rtr.config([new Route({path: '/user/:name', component: UserCmp, name: 'User'})])) rtr.config([new Route({path: '/user/:name', component: UserCmp, name: 'User'})]))
@ -222,7 +221,7 @@ function syncRoutesWithSyncChildrenWithoutDefaultRoutesWithoutParams() {
it('should navigate by URL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { it('should navigate by URL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
compile(tcb, `outer [ <router-outlet></router-outlet> ]`) compile(tcb, `outer [ <router-outlet></router-outlet> ]`)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then( .then(
(_) => (_) =>
rtr.config([new Route({path: '/a/...', component: ParentCmp, name: 'Parent'})])) rtr.config([new Route({path: '/a/...', component: ParentCmp, name: 'Parent'})]))
@ -236,7 +235,7 @@ function syncRoutesWithSyncChildrenWithoutDefaultRoutesWithoutParams() {
it('should navigate by link DSL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { it('should navigate by link DSL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
compile(tcb, `outer [ <router-outlet></router-outlet> ]`) compile(tcb, `outer [ <router-outlet></router-outlet> ]`)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then( .then(
(_) => (_) =>
rtr.config([new Route({path: '/a/...', component: ParentCmp, name: 'Parent'})])) rtr.config([new Route({path: '/a/...', component: ParentCmp, name: 'Parent'})]))
@ -252,7 +251,7 @@ function syncRoutesWithSyncChildrenWithoutDefaultRoutesWithoutParams() {
compile( compile(
tcb, tcb,
`<a [routerLink]="['Parent', 'Child']">nav to child</a> | outer [ <router-outlet></router-outlet> ]`) `<a [routerLink]="['Parent', 'Child']">nav to child</a> | outer [ <router-outlet></router-outlet> ]`)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then( .then(
(_) => (_) =>
rtr.config([new Route({path: '/a/...', component: ParentCmp, name: 'Parent'})])) rtr.config([new Route({path: '/a/...', component: ParentCmp, name: 'Parent'})]))
@ -270,7 +269,7 @@ function syncRoutesWithSyncChildrenWithoutDefaultRoutesWithoutParams() {
compile( compile(
tcb, tcb,
`<a [routerLink]="['Parent', 'Child']">nav to child</a> | outer [ <router-outlet></router-outlet> ]`) `<a [routerLink]="['Parent', 'Child']">nav to child</a> | outer [ <router-outlet></router-outlet> ]`)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new Route( .then((_) => rtr.config([new Route(
{path: '/a/...', component: ParentCmp, name: 'Parent'})])) {path: '/a/...', component: ParentCmp, name: 'Parent'})]))
.then((_) => { .then((_) => {
@ -307,7 +306,7 @@ function syncRoutesWithSyncChildrenWithoutDefaultRoutesWithParams() {
it('should navigate by URL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { it('should navigate by URL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
compile(tcb, `[ <router-outlet></router-outlet> ]`) compile(tcb, `[ <router-outlet></router-outlet> ]`)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new Route( .then((_) => rtr.config([new Route(
{path: '/team/:id/...', component: TeamCmp, name: 'Team'})])) {path: '/team/:id/...', component: TeamCmp, name: 'Team'})]))
.then((_) => rtr.navigateByUrl('/team/angular/user/matias')) .then((_) => rtr.navigateByUrl('/team/angular/user/matias'))
@ -321,7 +320,7 @@ function syncRoutesWithSyncChildrenWithoutDefaultRoutesWithParams() {
it('should navigate by link DSL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { it('should navigate by link DSL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
compile(tcb, `[ <router-outlet></router-outlet> ]`) compile(tcb, `[ <router-outlet></router-outlet> ]`)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new Route( .then((_) => rtr.config([new Route(
{path: '/team/:id/...', component: TeamCmp, name: 'Team'})])) {path: '/team/:id/...', component: TeamCmp, name: 'Team'})]))
.then((_) => rtr.navigate(['/Team', {id: 'angular'}, 'User', {name: 'matias'}])) .then((_) => rtr.navigate(['/Team', {id: 'angular'}, 'User', {name: 'matias'}]))
@ -337,7 +336,7 @@ function syncRoutesWithSyncChildrenWithoutDefaultRoutesWithParams() {
compile( compile(
tcb, tcb,
`<a [routerLink]="['/Team', {id: 'angular'}, 'User', {name: 'matias'}]">nav to matias</a> [ <router-outlet></router-outlet> ]`) `<a [routerLink]="['/Team', {id: 'angular'}, 'User', {name: 'matias'}]">nav to matias</a> [ <router-outlet></router-outlet> ]`)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new Route( .then((_) => rtr.config([new Route(
{path: '/team/:id/...', component: TeamCmp, name: 'Team'})])) {path: '/team/:id/...', component: TeamCmp, name: 'Team'})]))
.then((_) => { .then((_) => {
@ -354,7 +353,7 @@ function syncRoutesWithSyncChildrenWithoutDefaultRoutesWithParams() {
compile( compile(
tcb, tcb,
`<a [routerLink]="['/Team', {id: 'angular'}, 'User', {name: 'matias'}]">nav to matias</a> [ <router-outlet></router-outlet> ]`) `<a [routerLink]="['/Team', {id: 'angular'}, 'User', {name: 'matias'}]">nav to matias</a> [ <router-outlet></router-outlet> ]`)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new Route( .then((_) => rtr.config([new Route(
{path: '/team/:id/...', component: TeamCmp, name: 'Team'})])) {path: '/team/:id/...', component: TeamCmp, name: 'Team'})]))
.then((_) => { .then((_) => {
@ -391,7 +390,7 @@ function syncRoutesWithSyncChildrenWithDefaultRoutesWithoutParams() {
it('should navigate by URL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { it('should navigate by URL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
compile(tcb, `outer [ <router-outlet></router-outlet> ]`) compile(tcb, `outer [ <router-outlet></router-outlet> ]`)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new Route( .then((_) => rtr.config([new Route(
{path: '/a/...', component: ParentWithDefaultCmp, name: 'Parent'})])) {path: '/a/...', component: ParentWithDefaultCmp, name: 'Parent'})]))
.then((_) => rtr.navigateByUrl('/a')) .then((_) => rtr.navigateByUrl('/a'))
@ -404,7 +403,7 @@ function syncRoutesWithSyncChildrenWithDefaultRoutesWithoutParams() {
it('should navigate by link DSL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { it('should navigate by link DSL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
compile(tcb, `outer [ <router-outlet></router-outlet> ]`) compile(tcb, `outer [ <router-outlet></router-outlet> ]`)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new Route( .then((_) => rtr.config([new Route(
{path: '/a/...', component: ParentWithDefaultCmp, name: 'Parent'})])) {path: '/a/...', component: ParentWithDefaultCmp, name: 'Parent'})]))
.then((_) => rtr.navigate(['/Parent'])) .then((_) => rtr.navigate(['/Parent']))
@ -419,7 +418,7 @@ function syncRoutesWithSyncChildrenWithDefaultRoutesWithoutParams() {
compile( compile(
tcb, tcb,
`<a [routerLink]="['/Parent']">link to inner</a> | outer [ <router-outlet></router-outlet> ]`) `<a [routerLink]="['/Parent']">link to inner</a> | outer [ <router-outlet></router-outlet> ]`)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new Route( .then((_) => rtr.config([new Route(
{path: '/a/...', component: ParentWithDefaultCmp, name: 'Parent'})])) {path: '/a/...', component: ParentWithDefaultCmp, name: 'Parent'})]))
.then((_) => { .then((_) => {
@ -436,7 +435,7 @@ function syncRoutesWithSyncChildrenWithDefaultRoutesWithoutParams() {
compile( compile(
tcb, tcb,
`<a [routerLink]="['/Parent']">link to inner</a> | outer [ <router-outlet></router-outlet> ]`) `<a [routerLink]="['/Parent']">link to inner</a> | outer [ <router-outlet></router-outlet> ]`)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new Route( .then((_) => rtr.config([new Route(
{path: '/a/...', component: ParentWithDefaultCmp, name: 'Parent'})])) {path: '/a/...', component: ParentWithDefaultCmp, name: 'Parent'})]))
.then((_) => { .then((_) => {
@ -472,40 +471,38 @@ function syncRoutesWithDynamicComponents() {
})); }));
it('should work', it('should work', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
inject( tcb.createAsync(DynamicLoaderCmp)
[AsyncTestCompleter], .then((rtc) => { fixture = rtc; })
(async: AsyncTestCompleter) => { .then((_) => rtr.config([new Route({path: '/', component: HelloCmp})]))
tcb.createAsync(DynamicLoaderCmp) .then((_) => {
.then((rtc) => {fixture = rtc}) fixture.detectChanges();
.then((_) => rtr.config([new Route({path: '/', component: HelloCmp})])) expect(fixture.debugElement.nativeElement).toHaveText('[ ]');
.then((_) => { return fixture.componentInstance.onSomeAction();
fixture.detectChanges(); })
expect(fixture.debugElement.nativeElement).toHaveText('[ ]'); .then((_) => {
return fixture.componentInstance.onSomeAction(); fixture.detectChanges();
}) return rtr.navigateByUrl('/');
.then((_) => { })
fixture.detectChanges(); .then((_) => {
return rtr.navigateByUrl('/'); fixture.detectChanges();
}) expect(fixture.debugElement.nativeElement).toHaveText('[ hello ]');
.then((_) => {
fixture.detectChanges();
expect(fixture.debugElement.nativeElement).toHaveText('[ hello ]');
return fixture.componentInstance.onSomeAction(); return fixture.componentInstance.onSomeAction();
}) })
.then((_) => { .then((_) => {
// TODO(i): This should be rewritten to use NgZone#onStable or // TODO(i): This should be rewritten to use NgZone#onStable or
// something // something
// similar basically the assertion needs to run when the world is // similar basically the assertion needs to run when the world is
// stable and we don't know when that is, only zones know. // stable and we don't know when that is, only zones know.
PromiseWrapper.resolve(null).then((_) => { PromiseWrapper.resolve(null).then((_) => {
fixture.detectChanges(); fixture.detectChanges();
expect(fixture.debugElement.nativeElement).toHaveText('[ hello ]'); expect(fixture.debugElement.nativeElement).toHaveText('[ hello ]');
async.done(); async.done();
}); });
})})); });
}));
} }

View File

@ -6,10 +6,9 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {Component, Inject, Injector, provide} from '@angular/core'; import {Component,} from '@angular/core';
import {ComponentFixture, TestComponentBuilder} from '@angular/core/testing'; import {ComponentFixture, TestComponentBuilder} from '@angular/core/testing';
import {beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {RouteParams, Router, RouterLink, RouterOutlet} from '@angular/router-deprecated'; import {RouteParams, Router, RouterLink, RouterOutlet} from '@angular/router-deprecated';
import {EventEmitter, ObservableWrapper, PromiseCompleter, PromiseWrapper} from '../../src/facade/async'; import {EventEmitter, ObservableWrapper, PromiseCompleter, PromiseWrapper} from '../../src/facade/async';
@ -19,7 +18,7 @@ import {CanDeactivate, CanReuse, OnActivate, OnDeactivate, OnReuse} from '../../
import {CanActivate} from '../../src/lifecycle/lifecycle_annotations'; import {CanActivate} from '../../src/lifecycle/lifecycle_annotations';
import {AsyncRoute, AuxRoute, Redirect, Route, RouteConfig} from '../../src/route_config/route_config_decorator'; import {AsyncRoute, AuxRoute, Redirect, Route, RouteConfig} from '../../src/route_config/route_config_decorator';
import {RootCmp, TEST_ROUTER_PROVIDERS, compile} from './util'; import {TEST_ROUTER_PROVIDERS, compile} from './util';
var cmpInstanceCount: any /** TODO #9100 */; var cmpInstanceCount: any /** TODO #9100 */;
var log: string[]; var log: string[];
@ -47,7 +46,7 @@ export function main() {
it('should call the routerOnActivate hook', it('should call the routerOnActivate hook',
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
compile(tcb) compile(tcb)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})])) .then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})]))
.then((_) => rtr.navigateByUrl('/on-activate')) .then((_) => rtr.navigateByUrl('/on-activate'))
.then((_) => { .then((_) => {
@ -61,7 +60,7 @@ export function main() {
it('should wait for a parent component\'s routerOnActivate hook to resolve before calling its child\'s', it('should wait for a parent component\'s routerOnActivate hook to resolve before calling its child\'s',
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
compile(tcb) compile(tcb)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})])) .then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})]))
.then((_) => { .then((_) => {
ObservableWrapper.subscribe<string>(eventBus, (ev) => { ObservableWrapper.subscribe<string>(eventBus, (ev) => {
@ -83,7 +82,7 @@ export function main() {
it('should call the routerOnDeactivate hook', it('should call the routerOnDeactivate hook',
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
compile(tcb) compile(tcb)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})])) .then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})]))
.then((_) => rtr.navigateByUrl('/on-deactivate')) .then((_) => rtr.navigateByUrl('/on-deactivate'))
.then((_) => rtr.navigateByUrl('/a')) .then((_) => rtr.navigateByUrl('/a'))
@ -98,7 +97,7 @@ export function main() {
it('should wait for a child component\'s routerOnDeactivate hook to resolve before calling its parent\'s', it('should wait for a child component\'s routerOnDeactivate hook to resolve before calling its parent\'s',
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
compile(tcb) compile(tcb)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})])) .then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})]))
.then((_) => rtr.navigateByUrl('/parent-deactivate/child-deactivate')) .then((_) => rtr.navigateByUrl('/parent-deactivate/child-deactivate'))
.then((_) => { .then((_) => {
@ -124,7 +123,7 @@ export function main() {
it('should reuse a component when the routerCanReuse hook returns true', it('should reuse a component when the routerCanReuse hook returns true',
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
compile(tcb) compile(tcb)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})])) .then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})]))
.then((_) => rtr.navigateByUrl('/on-reuse/1/a')) .then((_) => rtr.navigateByUrl('/on-reuse/1/a'))
.then((_) => { .then((_) => {
@ -147,7 +146,7 @@ export function main() {
it('should not reuse a component when the routerCanReuse hook returns false', it('should not reuse a component when the routerCanReuse hook returns false',
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
compile(tcb) compile(tcb)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})])) .then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})]))
.then((_) => rtr.navigateByUrl('/never-reuse/1/a')) .then((_) => rtr.navigateByUrl('/never-reuse/1/a'))
.then((_) => { .then((_) => {
@ -170,7 +169,7 @@ export function main() {
it('should navigate when routerCanActivate returns true', it('should navigate when routerCanActivate returns true',
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
compile(tcb) compile(tcb)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})])) .then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})]))
.then((_) => { .then((_) => {
ObservableWrapper.subscribe<string>(eventBus, (ev) => { ObservableWrapper.subscribe<string>(eventBus, (ev) => {
@ -190,7 +189,7 @@ export function main() {
it('should not navigate when routerCanActivate returns false', it('should not navigate when routerCanActivate returns false',
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
compile(tcb) compile(tcb)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})])) .then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})]))
.then((_) => { .then((_) => {
ObservableWrapper.subscribe<string>(eventBus, (ev) => { ObservableWrapper.subscribe<string>(eventBus, (ev) => {
@ -210,7 +209,7 @@ export function main() {
it('should navigate away when routerCanDeactivate returns true', it('should navigate away when routerCanDeactivate returns true',
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
compile(tcb) compile(tcb)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})])) .then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})]))
.then((_) => rtr.navigateByUrl('/can-deactivate/a')) .then((_) => rtr.navigateByUrl('/can-deactivate/a'))
.then((_) => { .then((_) => {
@ -236,7 +235,7 @@ export function main() {
it('should not navigate away when routerCanDeactivate returns false', it('should not navigate away when routerCanDeactivate returns false',
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
compile(tcb) compile(tcb)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})])) .then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})]))
.then((_) => rtr.navigateByUrl('/can-deactivate/a')) .then((_) => rtr.navigateByUrl('/can-deactivate/a'))
.then((_) => { .then((_) => {
@ -263,7 +262,7 @@ export function main() {
it('should run activation and deactivation hooks in the correct order', it('should run activation and deactivation hooks in the correct order',
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
compile(tcb) compile(tcb)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})])) .then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})]))
.then((_) => rtr.navigateByUrl('/activation-hooks/child')) .then((_) => rtr.navigateByUrl('/activation-hooks/child'))
.then((_) => { .then((_) => {
@ -291,7 +290,7 @@ export function main() {
it('should only run reuse hooks when reusing', it('should only run reuse hooks when reusing',
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
compile(tcb) compile(tcb)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})])) .then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})]))
.then((_) => rtr.navigateByUrl('/reuse-hooks/1')) .then((_) => rtr.navigateByUrl('/reuse-hooks/1'))
.then((_) => { .then((_) => {

View File

@ -9,8 +9,7 @@
import {Location} from '@angular/common'; import {Location} from '@angular/common';
import {Component, Inject, Injector, provide} from '@angular/core'; import {Component, Inject, Injector, provide} from '@angular/core';
import {ComponentFixture, TestComponentBuilder} from '@angular/core/testing'; import {ComponentFixture, TestComponentBuilder} from '@angular/core/testing';
import {beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {RouteData, RouteParams, Router, RouterLink, RouterOutlet} from '@angular/router-deprecated'; import {RouteData, RouteParams, Router, RouterLink, RouterOutlet} from '@angular/router-deprecated';
import {PromiseWrapper, TimerWrapper} from '../../src/facade/async'; import {PromiseWrapper, TimerWrapper} from '../../src/facade/async';
@ -41,7 +40,7 @@ export function main() {
it('should work in a simple case', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { it('should work in a simple case', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
compile(tcb) compile(tcb)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new Route({path: '/test', component: HelloCmp})])) .then((_) => rtr.config([new Route({path: '/test', component: HelloCmp})]))
.then((_) => rtr.navigateByUrl('/test')) .then((_) => rtr.navigateByUrl('/test'))
.then((_) => { .then((_) => {
@ -55,7 +54,7 @@ export function main() {
it('should navigate between components with different parameters', it('should navigate between components with different parameters',
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
compile(tcb) compile(tcb)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new Route({path: '/user/:name', component: UserCmp})])) .then((_) => rtr.config([new Route({path: '/user/:name', component: UserCmp})]))
.then((_) => rtr.navigateByUrl('/user/brian')) .then((_) => rtr.navigateByUrl('/user/brian'))
.then((_) => { .then((_) => {
@ -73,7 +72,7 @@ export function main() {
it('should navigate to child routes', it('should navigate to child routes',
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
compile(tcb, 'outer [ <router-outlet></router-outlet> ]') compile(tcb, 'outer [ <router-outlet></router-outlet> ]')
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new Route({path: '/a/...', component: ParentCmp})])) .then((_) => rtr.config([new Route({path: '/a/...', component: ParentCmp})]))
.then((_) => rtr.navigateByUrl('/a/b')) .then((_) => rtr.navigateByUrl('/a/b'))
.then((_) => { .then((_) => {
@ -87,7 +86,7 @@ export function main() {
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
compile(tcb, 'outer [ <router-outlet></router-outlet> ]') compile(tcb, 'outer [ <router-outlet></router-outlet> ]')
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new Route({path: '/a/...', component: ParentCmp})])) .then((_) => rtr.config([new Route({path: '/a/...', component: ParentCmp})]))
.then((_) => rtr.navigateByUrl('/a')) .then((_) => rtr.navigateByUrl('/a'))
.then((_) => { .then((_) => {
@ -102,7 +101,7 @@ export function main() {
[AsyncTestCompleter, Location], [AsyncTestCompleter, Location],
(async: AsyncTestCompleter, location: any /** TODO #9100 */) => { (async: AsyncTestCompleter, location: any /** TODO #9100 */) => {
compile(tcb, 'outer [ <router-outlet></router-outlet> ]') compile(tcb, 'outer [ <router-outlet></router-outlet> ]')
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new Route({path: '/...', component: ParentCmp})])) .then((_) => rtr.config([new Route({path: '/...', component: ParentCmp})]))
.then((_) => rtr.navigateByUrl('/b')) .then((_) => rtr.navigateByUrl('/b'))
.then((_) => { .then((_) => {
@ -117,7 +116,7 @@ export function main() {
it('should navigate to child routes of async routes', it('should navigate to child routes of async routes',
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
compile(tcb, 'outer [ <router-outlet></router-outlet> ]') compile(tcb, 'outer [ <router-outlet></router-outlet> ]')
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new AsyncRoute({path: '/a/...', loader: parentLoader})])) .then((_) => rtr.config([new AsyncRoute({path: '/a/...', loader: parentLoader})]))
.then((_) => rtr.navigateByUrl('/a/b')) .then((_) => rtr.navigateByUrl('/a/b'))
.then((_) => { .then((_) => {
@ -133,7 +132,7 @@ export function main() {
[AsyncTestCompleter, Location], [AsyncTestCompleter, Location],
(async: AsyncTestCompleter, location: any /** TODO #9100 */) => { (async: AsyncTestCompleter, location: any /** TODO #9100 */) => {
compile(tcb) compile(tcb)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => location.setInitialPath('/test/')) .then((_) => location.setInitialPath('/test/'))
.then((_) => rtr.config([new Route({path: '/test', component: HelloCmp})])) .then((_) => rtr.config([new Route({path: '/test', component: HelloCmp})]))
.then((_) => rtr.navigateByUrl('/test')) .then((_) => rtr.navigateByUrl('/test'))
@ -148,7 +147,7 @@ export function main() {
it('should reuse common parent components', it('should reuse common parent components',
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
compile(tcb) compile(tcb)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new Route({path: '/team/:id/...', component: TeamCmp})])) .then((_) => rtr.config([new Route({path: '/team/:id/...', component: TeamCmp})]))
.then((_) => rtr.navigateByUrl('/team/angular/user/rado')) .then((_) => rtr.navigateByUrl('/team/angular/user/rado'))
.then((_) => { .then((_) => {
@ -169,7 +168,7 @@ export function main() {
it('should not reuse children when parent components change', it('should not reuse children when parent components change',
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
compile(tcb) compile(tcb)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new Route({path: '/team/:id/...', component: TeamCmp})])) .then((_) => rtr.config([new Route({path: '/team/:id/...', component: TeamCmp})]))
.then((_) => rtr.navigateByUrl('/team/angular/user/rado')) .then((_) => rtr.navigateByUrl('/team/angular/user/rado'))
.then((_) => { .then((_) => {
@ -191,7 +190,7 @@ export function main() {
it('should inject route data into component', it('should inject route data into component',
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
compile(tcb) compile(tcb)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new Route( .then((_) => rtr.config([new Route(
{path: '/route-data', component: RouteDataCmp, data: {isAdmin: true}})])) {path: '/route-data', component: RouteDataCmp, data: {isAdmin: true}})]))
.then((_) => rtr.navigateByUrl('/route-data')) .then((_) => rtr.navigateByUrl('/route-data'))
@ -205,7 +204,7 @@ export function main() {
it('should inject route data into component with AsyncRoute', it('should inject route data into component with AsyncRoute',
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
compile(tcb) compile(tcb)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new AsyncRoute( .then((_) => rtr.config([new AsyncRoute(
{path: '/route-data', loader: asyncRouteDataCmp, data: {isAdmin: true}})])) {path: '/route-data', loader: asyncRouteDataCmp, data: {isAdmin: true}})]))
.then((_) => rtr.navigateByUrl('/route-data')) .then((_) => rtr.navigateByUrl('/route-data'))
@ -219,7 +218,7 @@ export function main() {
it('should inject empty object if the route has no data property', it('should inject empty object if the route has no data property',
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
compile(tcb) compile(tcb)
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new Route( .then((_) => rtr.config([new Route(
{path: '/route-data-default', component: RouteDataCmp})])) {path: '/route-data-default', component: RouteDataCmp})]))
.then((_) => rtr.navigateByUrl('/route-data-default')) .then((_) => rtr.navigateByUrl('/route-data-default'))
@ -233,7 +232,7 @@ export function main() {
it('should fire an event for each activated component', it('should fire an event for each activated component',
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
compile(tcb, '<router-outlet (activate)="activatedCmp = $event"></router-outlet>') compile(tcb, '<router-outlet (activate)="activatedCmp = $event"></router-outlet>')
.then((rtc) => {fixture = rtc}) .then((rtc) => { fixture = rtc; })
.then((_) => rtr.config([new Route({path: '/test', component: HelloCmp})])) .then((_) => rtr.config([new Route({path: '/test', component: HelloCmp})]))
.then((_) => rtr.navigateByUrl('/test')) .then((_) => rtr.navigateByUrl('/test'))
.then((_) => { .then((_) => {

View File

@ -8,8 +8,7 @@
import {Location} from '@angular/common'; import {Location} from '@angular/common';
import {ComponentFixture, TestComponentBuilder} from '@angular/core/testing'; import {ComponentFixture, TestComponentBuilder} from '@angular/core/testing';
import {beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {RouteData, RouteParams, Router, RouterLink, RouterOutlet} from '@angular/router-deprecated'; import {RouteData, RouteParams, Router, RouterLink, RouterOutlet} from '@angular/router-deprecated';
import {AsyncRoute, AuxRoute, Redirect, Route, RouteConfig} from '../../src/route_config/route_config_decorator'; import {AsyncRoute, AuxRoute, Redirect, Route, RouteConfig} from '../../src/route_config/route_config_decorator';
@ -44,7 +43,7 @@ export function main() {
[AsyncTestCompleter, Location], [AsyncTestCompleter, Location],
(async: AsyncTestCompleter, location: any /** TODO #9100 */) => { (async: AsyncTestCompleter, location: any /** TODO #9100 */) => {
compile(tcb) compile(tcb)
.then((rtc) => {rootTC = rtc}) .then((rtc) => { rootTC = rtc; })
.then((_) => rtr.config([ .then((_) => rtr.config([
new Redirect({path: '/original', redirectTo: ['Hello']}), new Redirect({path: '/original', redirectTo: ['Hello']}),
new Route({path: '/redirected', component: HelloCmp, name: 'Hello'}) new Route({path: '/redirected', component: HelloCmp, name: 'Hello'})
@ -64,7 +63,7 @@ export function main() {
[AsyncTestCompleter, Location], [AsyncTestCompleter, Location],
(async: AsyncTestCompleter, location: any /** TODO #9100 */) => { (async: AsyncTestCompleter, location: any /** TODO #9100 */) => {
compile(tcb) compile(tcb)
.then((rtc) => {rootTC = rtc}) .then((rtc) => { rootTC = rtc; })
.then((_) => rtr.config([ .then((_) => rtr.config([
new Redirect({path: '/original', redirectTo: ['/Hello']}), new Redirect({path: '/original', redirectTo: ['/Hello']}),
new Route({path: '/redirected', component: HelloCmp, name: 'Hello'}) new Route({path: '/redirected', component: HelloCmp, name: 'Hello'})
@ -84,7 +83,7 @@ export function main() {
[AsyncTestCompleter, Location], [AsyncTestCompleter, Location],
(async: AsyncTestCompleter, location: any /** TODO #9100 */) => { (async: AsyncTestCompleter, location: any /** TODO #9100 */) => {
compile(tcb) compile(tcb)
.then((rtc) => {rootTC = rtc}) .then((rtc) => { rootTC = rtc; })
.then((_) => rtr.config([ .then((_) => rtr.config([
new Redirect({path: '/original', redirectTo: ['./Hello']}), new Redirect({path: '/original', redirectTo: ['./Hello']}),
new Route({path: '/redirected', component: HelloCmp, name: 'Hello'}) new Route({path: '/redirected', component: HelloCmp, name: 'Hello'})
@ -104,7 +103,7 @@ export function main() {
[AsyncTestCompleter, Location], [AsyncTestCompleter, Location],
(async: AsyncTestCompleter, location: any /** TODO #9100 */) => { (async: AsyncTestCompleter, location: any /** TODO #9100 */) => {
compile(tcb) compile(tcb)
.then((rtc) => {rootTC = rtc}) .then((rtc) => { rootTC = rtc; })
.then((_) => rtr.config([ .then((_) => rtr.config([
new Route({path: '/original/...', component: RedirectToParentCmp}), new Route({path: '/original/...', component: RedirectToParentCmp}),
new Route({path: '/redirected', component: HelloCmp, name: 'HelloSib'}) new Route({path: '/redirected', component: HelloCmp, name: 'HelloSib'})
@ -124,7 +123,7 @@ export function main() {
[AsyncTestCompleter, Location], [AsyncTestCompleter, Location],
(async: AsyncTestCompleter, location: any /** TODO #9100 */) => { (async: AsyncTestCompleter, location: any /** TODO #9100 */) => {
compile(tcb) compile(tcb)
.then((rtc) => {rootTC = rtc}) .then((rtc) => { rootTC = rtc; })
.then((_) => rtr.config([ .then((_) => rtr.config([
new Route({path: '/foo', component: HelloCmp, name: 'Hello'}), new Route({path: '/foo', component: HelloCmp, name: 'Hello'}),
new Route({path: '/:param', component: GoodbyeCmp, name: 'Goodbye'}), new Route({path: '/:param', component: GoodbyeCmp, name: 'Goodbye'}),

View File

@ -6,8 +6,7 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {beforeEach, ddescribe, xdescribe, describe, expect, iit, inject, beforeEachProviders, it, xit,} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, beforeEach, ddescribe, xdescribe, describe, expect, iit, inject, beforeEachProviders, it, xit,} from '@angular/core/testing/testing_internal';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {ComponentFixture, TestComponentBuilder} from '@angular/core/testing'; import {ComponentFixture, TestComponentBuilder} from '@angular/core/testing';
import {Location} from '@angular/common'; import {Location} from '@angular/common';
import {NumberWrapper, escapeRegExp} from '../../src/facade/lang'; import {NumberWrapper, escapeRegExp} from '../../src/facade/lang';

View File

@ -6,11 +6,10 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {describe, it, iit, ddescribe, expect, inject, beforeEach, beforeEachProviders,} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, describe, it, iit, ddescribe, expect, inject, beforeEach, beforeEachProviders,} from '@angular/core/testing/testing_internal';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {Injector, provide, ReflectiveInjector} from '@angular/core'; import {ReflectiveInjector} from '@angular/core';
import {Location, LocationStrategy, APP_BASE_HREF} from '@angular/common'; import {Location, LocationStrategy} from '@angular/common';
import {MockLocationStrategy} from '@angular/common/testing/mock_location_strategy'; import {MockLocationStrategy} from '@angular/common/testing/mock_location_strategy';
export function main() { export function main() {

View File

@ -6,18 +6,16 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {beforeEach, ddescribe, describe, expect, iit, inject, it, xdescribe, xit,} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, beforeEach, ddescribe, describe, expect, iit, inject, it, xdescribe, xit,} from '@angular/core/testing/testing_internal';
import {bootstrap} from '@angular/platform-browser-dynamic'; import {bootstrap} from '@angular/platform-browser-dynamic';
import {APP_BASE_HREF, LocationStrategy} from '@angular/common'; import {LocationStrategy} from '@angular/common';
import {Component, Directive} from '@angular/core/src/metadata'; import {Component, Directive} from '@angular/core/src/metadata';
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter'; import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
import {Console} from '@angular/core/src/console'; import {Console} from '@angular/core/src/console';
import {provide, disposePlatform} from '@angular/core'; import {ExceptionHandler, disposePlatform} from '@angular/core';
import {DOCUMENT} from '@angular/platform-browser/src/dom/dom_tokens'; import {DOCUMENT} from '@angular/platform-browser/src/dom/dom_tokens';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {ROUTER_PROVIDERS, Router, RouteConfig, ROUTER_DIRECTIVES} from '@angular/router-deprecated'; import {ROUTER_PROVIDERS, Router, RouteConfig, ROUTER_DIRECTIVES} from '@angular/router-deprecated';
import {ExceptionHandler} from '@angular/core';
import {MockLocationStrategy} from '@angular/common/testing/mock_location_strategy'; import {MockLocationStrategy} from '@angular/common/testing/mock_location_strategy';
class _ArrayLogger { class _ArrayLogger {
@ -138,38 +136,37 @@ export function main() {
})); }));
it('should throw if a config is missing a target', it('should throw if a config is missing a target',
inject( inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
[AsyncTestCompleter], bootstrap(WrongConfigCmp, testBindings).catch((e) => {
(async: AsyncTestCompleter) => {bootstrap(WrongConfigCmp, testBindings).catch((e) => { expect(e.originalException)
expect(e.originalException) .toContainError(
.toContainError( 'Route config should contain exactly one "component", "loader", or "redirectTo" property.');
'Route config should contain exactly one "component", "loader", or "redirectTo" property.'); async.done();
async.done(); return null;
return null; });
})})); }));
it('should throw if a config has an invalid component type', it('should throw if a config has an invalid component type',
inject( inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
[AsyncTestCompleter], bootstrap(WrongComponentTypeCmp, testBindings).catch((e) => {
(async: expect(e.originalException)
AsyncTestCompleter) => {bootstrap(WrongComponentTypeCmp, testBindings).catch((e) => { .toContainError(
expect(e.originalException) 'Invalid component type "intentionallyWrongComponentType". Valid types are "constructor" and "loader".');
.toContainError( async.done();
'Invalid component type "intentionallyWrongComponentType". Valid types are "constructor" and "loader".'); return null;
async.done(); });
return null; }));
})}));
it('should throw if a config has an invalid alias name', it('should throw if a config has an invalid alias name',
inject( inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
[AsyncTestCompleter], bootstrap(BadAliasNameCmp, testBindings).catch((e) => {
(async: AsyncTestCompleter) => {bootstrap(BadAliasNameCmp, testBindings).catch((e) => { expect(e.originalException)
expect(e.originalException) .toContainError(
.toContainError( `Route "/child" with name "child" does not begin with an uppercase letter. Route names should be PascalCase like "Child".`);
`Route "/child" with name "child" does not begin with an uppercase letter. Route names should be PascalCase like "Child".`); async.done();
async.done(); return null;
return null; });
})})); }));
}); });
} }

View File

@ -6,8 +6,7 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {describe, it, iit, ddescribe, expect, inject, beforeEach,} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, describe, it, iit, ddescribe, expect, inject, beforeEach,} from '@angular/core/testing/testing_internal';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {PromiseWrapper} from '../src/facade/async'; import {PromiseWrapper} from '../src/facade/async';
import {Type, IS_DART} from '../src/facade/lang'; import {Type, IS_DART} from '../src/facade/lang';

View File

@ -9,8 +9,7 @@
import {Location} from '@angular/common'; import {Location} from '@angular/common';
import {SpyLocation} from '@angular/common/testing'; import {SpyLocation} from '@angular/common/testing';
import {provide} from '@angular/core'; import {provide} from '@angular/core';
import {beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xit} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xit} from '@angular/core/testing/testing_internal';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {RouterOutlet} from '../src/directives/router_outlet'; import {RouterOutlet} from '../src/directives/router_outlet';
import {ObservableWrapper, PromiseWrapper} from '../src/facade/async'; import {ObservableWrapper, PromiseWrapper} from '../src/facade/async';

View File

@ -10,7 +10,7 @@ import {describe, it, iit, ddescribe, expect, inject, beforeEach,} from '@angula
import {GeneratedUrl} from '../../../src/rules/route_paths/route_path'; import {GeneratedUrl} from '../../../src/rules/route_paths/route_path';
import {RegexRoutePath} from '../../../src/rules/route_paths/regex_route_path'; import {RegexRoutePath} from '../../../src/rules/route_paths/regex_route_path';
import {parser, Url} from '../../../src/url_parser'; import {parser} from '../../../src/url_parser';
function emptySerializer(params: any /** TODO #9100 */) { function emptySerializer(params: any /** TODO #9100 */) {
return new GeneratedUrl('', {}); return new GeneratedUrl('', {});
@ -47,10 +47,9 @@ export function main() {
}); });
it('should raise an error when the number of parameters doesnt match', () => { it('should raise an error when the number of parameters doesnt match', () => {
expect( expect(() => {
() => {new RegexRoutePath( new RegexRoutePath('^a-([0-9]+)-b-([0-9]+)$', emptySerializer, ['complete_match', 'a']);
'^a-([0-9]+)-b-([0-9]+)$', emptySerializer, ['complete_match', 'a'])}) }).toThrowError(`Regex group names [complete_match,a] must contain names for each matching \
.toThrowError(`Regex group names [complete_match,a] must contain names for each matching \
group and a name for the complete match as its first element of regex '^a-([0-9]+)-b-([0-9]+)$'. \ group and a name for the complete match as its first element of regex '^a-([0-9]+)-b-([0-9]+)$'. \
3 group names are expected.`); 3 group names are expected.`);
}); });

View File

@ -6,8 +6,7 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {describe, it, iit, ddescribe, expect, inject, beforeEach,} from '@angular/core/testing/testing_internal'; import {AsyncTestCompleter, describe, it, iit, ddescribe, expect, inject, beforeEach,} from '@angular/core/testing/testing_internal';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {RouteMatch, PathMatch, RedirectMatch} from '../../src/rules/rules'; import {RouteMatch, PathMatch, RedirectMatch} from '../../src/rules/rules';
import {RuleSet} from '../../src/rules/rule_set'; import {RuleSet} from '../../src/rules/rule_set';
import {GeneratedUrl} from '../../src/rules/route_paths/route_path'; import {GeneratedUrl} from '../../src/rules/route_paths/route_path';

View File

@ -1,3 +1,11 @@
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {Observable} from 'rxjs/Observable'; import {Observable} from 'rxjs/Observable';
import {of } from 'rxjs/observable/of'; import {of } from 'rxjs/observable/of';

View File

@ -1,3 +1,11 @@
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {validateConfig} from '../src/config'; import {validateConfig} from '../src/config';
describe('config', () => { describe('config', () => {

View File

@ -1,3 +1,11 @@
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {Routes} from '../src/config'; import {Routes} from '../src/config';
import {createRouterState} from '../src/create_router_state'; import {createRouterState} from '../src/create_router_state';
import {recognize} from '../src/recognize'; import {recognize} from '../src/recognize';

View File

@ -1,3 +1,11 @@
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {BehaviorSubject} from 'rxjs/BehaviorSubject'; import {BehaviorSubject} from 'rxjs/BehaviorSubject';
import {createUrlTree} from '../src/create_url_tree'; import {createUrlTree} from '../src/create_url_tree';

View File

@ -1,3 +1,11 @@
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {Routes} from '../src/config'; import {Routes} from '../src/config';
import {recognize} from '../src/recognize'; import {recognize} from '../src/recognize';
import {ActivatedRouteSnapshot, RouterStateSnapshot} from '../src/router_state'; import {ActivatedRouteSnapshot, RouterStateSnapshot} from '../src/router_state';

View File

@ -1,3 +1,11 @@
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {Routes} from '../src/config'; import {Routes} from '../src/config';
import {recognize} from '../src/recognize'; import {recognize} from '../src/recognize';
import {resolve} from '../src/resolve'; import {resolve} from '../src/resolve';

Some files were not shown because too many files have changed in this diff Show More