From 00aa7a76b66b3c65522dc9eea26ed927d6788f5a Mon Sep 17 00:00:00 2001 From: Victor Berchet Date: Thu, 21 Jul 2016 17:12:00 -0700 Subject: [PATCH] chore(tests): enable lint, make it green. (#10224) --- gulpfile.js | 2 +- .../common/test/directives/ng_class_spec.ts | 2 +- .../common/test/directives/ng_for_spec.ts | 5 +- .../common/test/directives/ng_if_spec.ts | 3 +- .../common/test/directives/ng_plural_spec.ts | 3 +- .../common/test/directives/ng_style_spec.ts | 5 +- .../common/test/directives/ng_switch_spec.ts | 4 +- .../directives/ng_template_outlet_spec.ts | 3 +- .../test/directives/non_bindable_spec.ts | 5 +- .../test/forms-deprecated/integration_spec.ts | 8 +- .../test/forms-deprecated/model_spec.ts | 9 +- .../test/forms-deprecated/validators_spec.ts | 4 +- .../common/test/pipes/async_pipe_spec.ts | 23 +- .../common/test/pipes/json_pipe_spec.ts | 3 +- .../common/test/pipes/replace_pipe_spec.ts | 1 - .../common/test/pipes/slice_pipe_spec.ts | 3 +- modules/@angular/compiler-cli/test/mocks.ts | 4 +- .../compiler-cli/test/reflector_host_spec.ts | 15 +- .../test/animation/animation_parser_spec.ts | 2 +- .../compiler/test/compile_metadata_spec.ts | 2 +- .../compiler/test/css_visitor_spec.ts | 3 + .../test/directive_normalizer_spec.ts | 15 +- .../test/expression_parser/parser_spec.ts | 4 +- .../test/expression_parser/validator.ts | 8 + .../@angular/compiler/test/html_lexer_spec.ts | 15 +- .../test/output/output_emitter_spec.ts | 304 +++++----- .../compiler/test/runtime_compiler_spec.ts | 8 + .../@angular/compiler/test/selector_spec.ts | 3 +- .../compiler/test/template_parser_spec.ts | 8 +- .../test/test_component_builder_spec.ts | 532 +++++++++--------- modules/@angular/compiler/test/util_spec.ts | 4 +- .../compiler/test/view_resolver_mock_spec.ts | 3 +- .../@angular/compiler/test/xhr_mock_spec.ts | 6 +- .../animation/animation_group_player_spec.ts | 3 +- .../animation/animation_integration_spec.ts | 35 +- .../animation_sequence_player_spec.ts | 2 +- .../animation/animation_style_util_spec.ts | 4 +- .../core/test/application_ref_spec.ts | 6 +- .../differs/default_iterable_differ_spec.ts | 6 +- .../core/test/debug/debug_node_spec.ts | 5 +- .../@angular/core/test/di/injector_spec.ts | 12 +- .../directive_lifecycle_integration_spec.ts | 3 +- .../core/test/facade/observable_spec.ts | 5 +- modules/@angular/core/test/fake_async_spec.ts | 2 +- .../core/test/forward_ref_integration_spec.ts | 6 +- .../linker/app_module_integration_spec.ts | 10 +- .../change_detection_integration_spec.ts | 12 +- .../linker/dynamic_component_loader_spec.ts | 7 +- .../core/test/linker/integration_spec.ts | 486 ++++++++-------- .../linker/ng_container_integration_spec.ts | 7 +- .../linker/precompile_integration_spec.ts | 7 +- .../linker/projection_integration_spec.ts | 5 +- .../test/linker/query_integration_spec.ts | 12 +- .../reflector_component_resolver_spec.ts | 8 +- .../linker/regression_integration_spec.ts | 42 +- .../test/linker/security_integration_spec.ts | 17 +- .../core/test/reflection/reflector_spec.ts | 473 ++++++++-------- .../core/test/testability/testability_spec.ts | 7 +- .../core/test/testing_internal_spec.ts | 3 +- .../core/test/util/decorators_spec.ts | 10 +- .../@angular/core/test/zone/ng_zone_spec.ts | 7 +- modules/@angular/facade/test/async_spec.ts | 3 +- .../@angular/forms/test/integration_spec.ts | 10 +- modules/@angular/forms/test/model_spec.ts | 38 +- .../@angular/forms/test/validators_spec.ts | 6 +- .../http/test/backends/jsonp_backend_spec.ts | 9 +- .../http/test/backends/mock_backend_spec.ts | 17 +- .../http/test/backends/xhr_backend_spec.ts | 13 +- modules/@angular/http/test/http_spec.ts | 10 +- .../test/testing_public_browser_spec.ts | 7 +- .../test/xhr/xhr_cache_spec.ts | 5 +- .../test/dom/events/event_manager_spec.ts | 1 + .../test/dom/web_animations_driver_spec.ts | 3 +- .../test/dom/web_animations_player_spec.ts | 1 + .../test/testing_public_spec.ts | 11 +- .../web_workers/shared/message_bus_spec.ts | 5 +- .../shared/web_worker_test_util.ts | 9 +- .../worker/platform_location_spec.ts | 3 +- .../worker/renderer_integration_spec.ts | 389 +++++++------ .../test/directives/router_link_spec.ts | 5 +- .../test/integration/bootstrap_spec.ts | 3 +- .../integration/impl/async_route_spec_impl.ts | 65 ++- .../integration/impl/aux_route_spec_impl.ts | 19 +- .../integration/impl/sync_route_spec_impl.ts | 107 ++-- .../test/integration/lifecycle_hook_spec.ts | 31 +- .../test/integration/navigation_spec.ts | 29 +- .../test/integration/redirect_route_spec.ts | 13 +- .../test/integration/router_link_spec.ts | 3 +- .../test/location/location_spec.ts | 7 +- .../test/route_config/route_config_spec.ts | 63 +-- .../test/route_registry_spec.ts | 3 +- .../router-deprecated/test/router_spec.ts | 3 +- .../route_paths/regex_route_param_spec.ts | 9 +- .../test/rules/rule_set_spec.ts | 3 +- .../router/test/apply_redirects.spec.ts | 8 + modules/@angular/router/test/config.spec.ts | 8 + .../router/test/create_router_state.spec.ts | 8 + .../router/test/create_url_tree.spec.ts | 8 + .../@angular/router/test/recognize.spec.ts | 8 + modules/@angular/router/test/resolve.spec.ts | 8 + modules/@angular/router/test/router.spec.ts | 13 +- .../router/test/url_serializer.spec.ts | 8 + modules/@angular/router/test/url_tree.spec.ts | 8 + .../@angular/router/test/utils/tree.spec.ts | 8 + .../@angular/upgrade/test/metadata_spec.ts | 2 +- modules/@angular/upgrade/test/upgrade_spec.ts | 22 +- 106 files changed, 1599 insertions(+), 1634 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 39ff771d92..ecc3c0e986 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -97,7 +97,7 @@ gulp.task('lint', ['format:enforce', 'tools:build'], () => { // Built-in rules are at // https://github.com/palantir/tslint#supported-rules const tslintConfig = require('./tslint.json'); - return gulp.src(['modules/@angular/**/*.ts', '!modules/@angular/*/test/**']) + return gulp.src(['modules/@angular/**/*.ts']) .pipe(tslint({ tslint: require('tslint').default, configuration: tslintConfig, diff --git a/modules/@angular/common/test/directives/ng_class_spec.ts b/modules/@angular/common/test/directives/ng_class_spec.ts index 2fa14fe0ed..4d4d7237c0 100644 --- a/modules/@angular/common/test/directives/ng_class_spec.ts +++ b/modules/@angular/common/test/directives/ng_class_spec.ts @@ -581,7 +581,7 @@ export function main() { })); }); - }) + }); } @Component({selector: 'test-cmp', directives: [NgClass, NgFor], template: ''}) diff --git a/modules/@angular/common/test/directives/ng_for_spec.ts b/modules/@angular/common/test/directives/ng_for_spec.ts index 1664b8c33b..8e02457e69 100644 --- a/modules/@angular/common/test/directives/ng_for_spec.ts +++ b/modules/@angular/common/test/directives/ng_for_spec.ts @@ -6,8 +6,7 @@ * 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} from '@angular/core/testing/testing_internal'; +import {AsyncTestCompleter, beforeEach, beforeEachProviders, ddescribe, describe, iit, inject, it, xit,} from '@angular/core/testing/testing_internal'; import {TestComponentBuilder} from '@angular/core/testing'; import {ListWrapper} from '../../src/facade/collection'; import {IS_DART} from '../../src/facade/lang'; @@ -182,7 +181,7 @@ export function main() { .then((fixture) => { fixture.debugElement.componentInstance.items = 'whaaa'; try { - fixture.detectChanges() + fixture.detectChanges(); } catch (e) { expect(e.message).toContain( `Cannot find a differ supporting object 'whaaa' of type 'string'. NgFor only supports binding to Iterables such as Arrays.`); diff --git a/modules/@angular/common/test/directives/ng_if_spec.ts b/modules/@angular/common/test/directives/ng_if_spec.ts index c9f79d8e10..4a64bb4246 100644 --- a/modules/@angular/common/test/directives/ng_if_spec.ts +++ b/modules/@angular/common/test/directives/ng_if_spec.ts @@ -6,9 +6,8 @@ * 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 {AsyncTestCompleter} from '@angular/core/testing/testing_internal'; import {expect} from '@angular/platform-browser/testing/matchers'; import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter'; diff --git a/modules/@angular/common/test/directives/ng_plural_spec.ts b/modules/@angular/common/test/directives/ng_plural_spec.ts index 38b9f7f33c..b243dad874 100644 --- a/modules/@angular/common/test/directives/ng_plural_spec.ts +++ b/modules/@angular/common/test/directives/ng_plural_spec.ts @@ -6,8 +6,7 @@ * 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} from '@angular/core/testing/testing_internal'; +import {AsyncTestCompleter, beforeEachProviders, beforeEach, ddescribe, describe, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal'; import {TestComponentBuilder} from '@angular/core/testing'; import {Component, Injectable} from '@angular/core'; diff --git a/modules/@angular/common/test/directives/ng_style_spec.ts b/modules/@angular/common/test/directives/ng_style_spec.ts index 78e2557524..f4503b1ded 100644 --- a/modules/@angular/common/test/directives/ng_style_spec.ts +++ b/modules/@angular/common/test/directives/ng_style_spec.ts @@ -6,9 +6,8 @@ * 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 {AsyncTestCompleter} from '@angular/core/testing/testing_internal'; import {StringMapWrapper} from '../../src/facade/collection'; @@ -191,7 +190,7 @@ export function main() { async.done(); }); })); - }) + }); } @Component({selector: 'test-cmp', directives: [NgStyle], template: ''}) diff --git a/modules/@angular/common/test/directives/ng_switch_spec.ts b/modules/@angular/common/test/directives/ng_switch_spec.ts index d3d331b8a7..3e836c32ef 100644 --- a/modules/@angular/common/test/directives/ng_switch_spec.ts +++ b/modules/@angular/common/test/directives/ng_switch_spec.ts @@ -6,8 +6,8 @@ * 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} from '@angular/core/testing/testing_internal'; +import {AsyncTestCompleter, beforeEach, ddescribe, describe, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal'; + import {Component} from '@angular/core'; import {TestComponentBuilder} from '@angular/core/testing'; diff --git a/modules/@angular/common/test/directives/ng_template_outlet_spec.ts b/modules/@angular/common/test/directives/ng_template_outlet_spec.ts index fad6beb8cd..c7192c2d6f 100644 --- a/modules/@angular/common/test/directives/ng_template_outlet_spec.ts +++ b/modules/@angular/common/test/directives/ng_template_outlet_spec.ts @@ -6,9 +6,8 @@ * 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 {AsyncTestCompleter} from '@angular/core/testing/testing_internal'; import {Component, Directive, TemplateRef, ContentChildren, QueryList} from '@angular/core'; import {NgTemplateOutlet} from '@angular/common'; diff --git a/modules/@angular/common/test/directives/non_bindable_spec.ts b/modules/@angular/common/test/directives/non_bindable_spec.ts index adf7f3668d..6815494589 100644 --- a/modules/@angular/common/test/directives/non_bindable_spec.ts +++ b/modules/@angular/common/test/directives/non_bindable_spec.ts @@ -6,12 +6,11 @@ * 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 {getDOM} from '@angular/platform-browser/src/dom/dom_adapter'; import {Component, Directive} from '@angular/core'; import {ElementRef} from '@angular/core/src/linker/element_ref'; -import {AsyncTestCompleter} from '@angular/core/testing/testing_internal'; export function main() { describe('non-bindable', () => { @@ -61,7 +60,7 @@ export function main() { async.done(); }); })); - }) + }); } @Directive({selector: '[test-dec]'}) diff --git a/modules/@angular/common/test/forms-deprecated/integration_spec.ts b/modules/@angular/common/test/forms-deprecated/integration_spec.ts index c63898fcd2..56979f0f34 100644 --- a/modules/@angular/common/test/forms-deprecated/integration_spec.ts +++ b/modules/@angular/common/test/forms-deprecated/integration_spec.ts @@ -8,11 +8,9 @@ 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 {Component, Directive, EventEmitter, Output} from '@angular/core'; -import {Input, Provider, forwardRef} from '@angular/core'; +import {Component, Directive, EventEmitter, Input, Output, Provider, forwardRef} from '@angular/core'; 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} from '@angular/core/testing/testing_internal'; +import {AsyncTestCompleter, afterEach, beforeEach, ddescribe, describe, expect, iit, inject, it, xit} from '@angular/core/testing/testing_internal'; import {By} from '@angular/platform-browser/src/dom/debug/by'; import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter'; import {dispatchEvent} from '@angular/platform-browser/testing/browser_util'; @@ -24,7 +22,7 @@ import {PromiseWrapper} from '../../src/facade/promise'; export function main() { describe('integration tests', () => { - beforeEach(() => {configureModule({modules: [DeprecatedFormsModule]})}); + beforeEach(() => { configureModule({modules: [DeprecatedFormsModule]}); }); it('should initialize DOM elements with the given form object', inject( diff --git a/modules/@angular/common/test/forms-deprecated/model_spec.ts b/modules/@angular/common/test/forms-deprecated/model_spec.ts index 71c76adf07..0a1462ee7b 100644 --- a/modules/@angular/common/test/forms-deprecated/model_spec.ts +++ b/modules/@angular/common/test/forms-deprecated/model_spec.ts @@ -6,9 +6,8 @@ * 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 {AsyncTestCompleter} from '@angular/core/testing/testing_internal'; import {ControlGroup, Control, ControlArray, Validators} from '@angular/common/src/forms-deprecated'; import {IS_DART, isPresent} from '../../src/facade/lang'; import {PromiseWrapper} from '../../src/facade/promise'; @@ -430,7 +429,7 @@ export function main() { // rename contains into has 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', () => { expect(group.contains('something else')).toEqual(false); }); @@ -605,7 +604,7 @@ export function main() { expect(g.errors).toEqual({'async': true}); expect(g.find(['one']).errors).toEqual({'async': true}); })); - }) + }); }); describe('ControlArray', () => { @@ -829,7 +828,7 @@ export function main() { expect(g.errors).toEqual({'async': true}); expect(g.pending).toEqual(false); })); - }) + }); }); }); } diff --git a/modules/@angular/common/test/forms-deprecated/validators_spec.ts b/modules/@angular/common/test/forms-deprecated/validators_spec.ts index 0c1404a2af..00ec51a75c 100644 --- a/modules/@angular/common/test/forms-deprecated/validators_spec.ts +++ b/modules/@angular/common/test/forms-deprecated/validators_spec.ts @@ -19,9 +19,9 @@ export function main() { function validator(key: string, error: any) { return function(c: AbstractControl) { var r = {}; - (r as any /** TODO #9100 */)[key] = error; + (r as any)[key] = error; return r; - } + }; } class AsyncValidatorDirective { diff --git a/modules/@angular/common/test/pipes/async_pipe_spec.ts b/modules/@angular/common/test/pipes/async_pipe_spec.ts index 63e8846ac8..90f6d1d8bb 100644 --- a/modules/@angular/common/test/pipes/async_pipe_spec.ts +++ b/modules/@angular/common/test/pipes/async_pipe_spec.ts @@ -6,8 +6,7 @@ * 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} from '@angular/core/testing/testing_internal'; +import {AsyncTestCompleter, ddescribe, describe, it, iit, xit, expect, beforeEach, afterEach, inject,} from '@angular/core/testing/testing_internal'; import {SpyChangeDetectorRef} from '../spies'; import {isBlank} from '../../src/facade/lang'; import {AsyncPipe} from '@angular/common'; @@ -45,7 +44,7 @@ export function main() { TimerWrapper.setTimeout(() => { expect(pipe.transform(emitter)).toEqual(new WrappedValue(message)); async.done(); - }, 0) + }, 0); })); @@ -58,7 +57,7 @@ export function main() { pipe.transform(emitter); expect(pipe.transform(emitter)).toBe(message); async.done(); - }, 0) + }, 0); })); it('should dispose of the existing subscription when subscribing to a new observable', @@ -74,7 +73,7 @@ export function main() { TimerWrapper.setTimeout(() => { expect(pipe.transform(newEmitter)).toBe(null); async.done(); - }, 0) + }, 0); })); it('should request a change detection check upon receiving a new value', @@ -85,7 +84,7 @@ export function main() { TimerWrapper.setTimeout(() => { expect(ref.spy('markForCheck')).toHaveBeenCalled(); async.done(); - }, 10) + }, 10); })); }); @@ -103,7 +102,7 @@ export function main() { TimerWrapper.setTimeout(() => { expect(pipe.transform(emitter)).toBe(null); async.done(); - }, 0) + }, 0); })); }); }); @@ -135,7 +134,7 @@ export function main() { TimerWrapper.setTimeout(() => { expect(pipe.transform(completer.promise)).toEqual(new WrappedValue(message)); async.done(); - }, timer) + }, timer); })); it('should return unwrapped value when nothing has changed since the last call', @@ -147,7 +146,7 @@ export function main() { pipe.transform(completer.promise); expect(pipe.transform(completer.promise)).toBe(message); async.done(); - }, timer) + }, timer); })); it('should dispose of the existing subscription when subscribing to a new promise', @@ -163,7 +162,7 @@ export function main() { TimerWrapper.setTimeout(() => { expect(pipe.transform(newCompleter.promise)).toBe(null); async.done(); - }, timer) + }, timer); })); it('should request a change detection check upon receiving a new value', @@ -175,7 +174,7 @@ export function main() { TimerWrapper.setTimeout(() => { expect(markForCheck).toHaveBeenCalled(); async.done(); - }, timer) + }, timer); })); describe('ngOnDestroy', () => { @@ -186,7 +185,7 @@ export function main() { inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { pipe.transform(completer.promise); expect(pipe.transform(completer.promise)).toBe(null); - completer.resolve(message) + completer.resolve(message); TimerWrapper.setTimeout(() => { diff --git a/modules/@angular/common/test/pipes/json_pipe_spec.ts b/modules/@angular/common/test/pipes/json_pipe_spec.ts index d863047cae..df4b839163 100644 --- a/modules/@angular/common/test/pipes/json_pipe_spec.ts +++ b/modules/@angular/common/test/pipes/json_pipe_spec.ts @@ -6,8 +6,7 @@ * 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} 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 {Json, StringWrapper} from '../../src/facade/lang'; diff --git a/modules/@angular/common/test/pipes/replace_pipe_spec.ts b/modules/@angular/common/test/pipes/replace_pipe_spec.ts index d0a98fab11..61069b315a 100644 --- a/modules/@angular/common/test/pipes/replace_pipe_spec.ts +++ b/modules/@angular/common/test/pipes/replace_pipe_spec.ts @@ -7,7 +7,6 @@ */ 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 {RegExpWrapper, StringJoiner} from '../../src/facade/lang'; diff --git a/modules/@angular/common/test/pipes/slice_pipe_spec.ts b/modules/@angular/common/test/pipes/slice_pipe_spec.ts index b01806a246..cc00ab6f7d 100644 --- a/modules/@angular/common/test/pipes/slice_pipe_spec.ts +++ b/modules/@angular/common/test/pipes/slice_pipe_spec.ts @@ -6,9 +6,8 @@ * 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 {AsyncTestCompleter} from '@angular/core/testing/testing_internal'; import {browserDetection} from '@angular/platform-browser/testing/browser_util'; import {Component} from '@angular/core'; diff --git a/modules/@angular/compiler-cli/test/mocks.ts b/modules/@angular/compiler-cli/test/mocks.ts index 4c2e42861c..49f9d87630 100644 --- a/modules/@angular/compiler-cli/test/mocks.ts +++ b/modules/@angular/compiler-cli/test/mocks.ts @@ -8,7 +8,7 @@ import * as ts from 'typescript'; -import {ReflectorHost, ReflectorHostContext} from '../src/reflector_host'; +import {ReflectorHostContext} from '../src/reflector_host'; export type Entry = string | Directory; @@ -19,7 +19,7 @@ export class MockContext implements ReflectorHostContext { 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 { let data = this.getEntry(fileName); diff --git a/modules/@angular/compiler-cli/test/reflector_host_spec.ts b/modules/@angular/compiler-cli/test/reflector_host_spec.ts index 9b19b7b480..ee6ee3dfab 100644 --- a/modules/@angular/compiler-cli/test/reflector_host_spec.ts +++ b/modules/@angular/compiler-cli/test/reflector_host_spec.ts @@ -21,7 +21,7 @@ describe('reflector_host', () => { beforeEach(() => { context = new MockContext('/tmp/src', clone(FILES)); - host = new MockCompilerHost(context) + host = new MockCompilerHost(context); program = ts.createProgram( ['main.ts'], { module: ts.ModuleKind.CommonJS, @@ -93,10 +93,10 @@ describe('reflector_host', () => { expect(reflectorHost.getStaticSymbol('angularjs', 'SomeAngularSymbol')).toBeDefined(); }); - it('should be able to read a metadata file', - () => { - expect(reflectorHost.getMetadataFor('node_modules/@angular/core.d.ts')) - .toEqual({__symbolic: 'module', version: 1, metadata: {foo: {__symbolic: 'class'}}})}); + it('should be able to read a metadata file', () => { + expect(reflectorHost.getMetadataFor('node_modules/@angular/core.d.ts')) + .toEqual({__symbolic: 'module', version: 1, metadata: {foo: {__symbolic: 'class'}}}); + }); it('should be able to read metadata from an otherwise unused .d.ts file ', () => { 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 = { 'tmp': { 'src': { @@ -134,7 +135,7 @@ const FILES: Entry = { } } } -} +}; function clone(entry: Entry): Entry { if (typeof entry === 'string') { diff --git a/modules/@angular/compiler/test/animation/animation_parser_spec.ts b/modules/@angular/compiler/test/animation/animation_parser_spec.ts index 705ff17a4d..ae2a087e6c 100644 --- a/modules/@angular/compiler/test/animation/animation_parser_spec.ts +++ b/modules/@angular/compiler/test/animation/animation_parser_spec.ts @@ -51,7 +51,7 @@ export function main() { }; var getAnimationAstFromEntryAst = - (ast: AnimationEntryAst) => { return ast.stateTransitions[0].animation; } + (ast: AnimationEntryAst) => { return ast.stateTransitions[0].animation; }; var parseAnimationAst = (data: AnimationMetadata[]) => { return getAnimationAstFromEntryAst(parseAnimation(data).ast); diff --git a/modules/@angular/compiler/test/compile_metadata_spec.ts b/modules/@angular/compiler/test/compile_metadata_spec.ts index 14b87cefa7..883bdccdb2 100644 --- a/modules/@angular/compiler/test/compile_metadata_spec.ts +++ b/modules/@angular/compiler/test/compile_metadata_spec.ts @@ -176,7 +176,7 @@ export function main() { describe('CompileAnimationAnimateMetadata', () => { it('should serialize with full data', () => { 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); }); diff --git a/modules/@angular/compiler/test/css_visitor_spec.ts b/modules/@angular/compiler/test/css_visitor_spec.ts index f2b630e71b..75e2ad6b76 100644 --- a/modules/@angular/compiler/test/css_visitor_spec.ts +++ b/modules/@angular/compiler/test/css_visitor_spec.ts @@ -22,6 +22,9 @@ function _assertTokens(tokens: CssToken[], valuesArr: string[]): void { class MyVisitor implements CssAstVisitor { captures: {[key: string]: any[]} = {}; + /** + * @internal + */ _capture(method: string, ast: CssAst, context: any) { this.captures[method] = isPresent(this.captures[method]) ? this.captures[method] : []; this.captures[method].push([ast, context]); diff --git a/modules/@angular/compiler/test/directive_normalizer_spec.ts b/modules/@angular/compiler/test/directive_normalizer_spec.ts index 1e1c41fa9c..50c771f10c 100644 --- a/modules/@angular/compiler/test/directive_normalizer_spec.ts +++ b/modules/@angular/compiler/test/directive_normalizer_spec.ts @@ -13,8 +13,7 @@ import {XHR} from '@angular/compiler/src/xhr'; import {MockXHR} from '@angular/compiler/testing/xhr_mock'; import {ViewEncapsulation} from '@angular/core/src/metadata/view'; import {configureCompiler} from '@angular/core/testing'; -import {beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xit} from '@angular/core/testing/testing_internal'; -import {AsyncTestCompleter} from '@angular/core/testing/testing_internal'; +import {AsyncTestCompleter, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xit} from '@angular/core/testing/testing_internal'; import {SpyXHR} from './spies'; import {TEST_COMPILER_PROVIDERS} from './test_bindings'; @@ -53,7 +52,7 @@ export function main() { templateUrl: null, styles: [], styleUrls: [] - })) + })); expect(template.template).toEqual('a'); expect(template.templateUrl).toEqual('package:some/module/a.js'); })); @@ -66,7 +65,7 @@ export function main() { templateUrl: null, styles: [], styleUrls: ['test.css'] - })) + })); expect(template.styleUrls).toEqual(['package:some/module/test.css']); })); @@ -79,7 +78,7 @@ export function main() { templateUrl: null, styles: [], styleUrls: [] - })) + })); expect(template.styleUrls).toEqual(['package:some/module/test.css']); })); @@ -91,7 +90,7 @@ export function main() { templateUrl: null, styles: [], styleUrls: ['test.css'] - })) + })); expect(template.encapsulation).toEqual(ViewEncapsulation.Emulated); })); @@ -107,7 +106,7 @@ export function main() { templateUrl: null, styles: [], styleUrls: ['test.css'] - })) + })); expect(template.encapsulation).toEqual(ViewEncapsulation.None); })); }); @@ -277,7 +276,7 @@ export function main() { dirType, new CompileTemplateMetadata({encapsulation: null, styles: [], styleUrls: []}), 'a', 'package:some/module/'); - expect(template.template).toEqual('a') + expect(template.template).toEqual('a'); })); it('should collect ngContent', diff --git a/modules/@angular/compiler/test/expression_parser/parser_spec.ts b/modules/@angular/compiler/test/expression_parser/parser_spec.ts index efc8481019..9634f73f9e 100644 --- a/modules/@angular/compiler/test/expression_parser/parser_spec.ts +++ b/modules/@angular/compiler/test/expression_parser/parser_spec.ts @@ -312,7 +312,7 @@ export function main() { if (binding.keyIsVar) { return 'let ' + binding.key + (isBlank(binding.name) ? '=null' : '=' + binding.name); } 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 selector', () => recover('a.')); it('should be able to recover from a missing selector in a array literal', - () => recover('[[a.], b, c]')) + () => recover('[[a.], b, c]')); }); }); } diff --git a/modules/@angular/compiler/test/expression_parser/validator.ts b/modules/@angular/compiler/test/expression_parser/validator.ts index 91791eff52..e6e916db6b 100644 --- a/modules/@angular/compiler/test/expression_parser/validator.ts +++ b/modules/@angular/compiler/test/expression_parser/validator.ts @@ -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 {unparse} from './unparser'; diff --git a/modules/@angular/compiler/test/html_lexer_spec.ts b/modules/@angular/compiler/test/html_lexer_spec.ts index d8429dcfb6..a0c754fd8a 100644 --- a/modules/@angular/compiler/test/html_lexer_spec.ts +++ b/modules/@angular/compiler/test/html_lexer_spec.ts @@ -65,13 +65,14 @@ export function main() { ]); }); - it('should store the locations', - () => {expect(tokenizeAndHumanizeSourceSpans('')).toEqual([ - [HtmlTokenType.COMMENT_START, ''], - [HtmlTokenType.EOF, ''], - ])}); + it('should store the locations', () => { + expect(tokenizeAndHumanizeSourceSpans('')).toEqual([ + [HtmlTokenType.COMMENT_START, ''], + [HtmlTokenType.EOF, ''], + ]); + }); it('should report { expect(tokenizeAndHumanizeErrors(' interpretStatements(codegenStmts, 'getExpressions'), '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'}); - } if (!IS_DART) { + } else { // Our generator only works on node.js and Dart... if (!getDOM().supportsDOMEvents()) { outputDefs.push({'getExpressions': () => untyped.getExpressions, 'name': 'untyped'}); @@ -40,166 +39,155 @@ export function main() { }); } - describe( - 'output emitter', - () => { - outputDefs.forEach((outputDef) => { - describe(`${outputDef['name']}`, () => { - var expressions: any /** TODO #9100 */; - beforeEach(() => { expressions = outputDef['getExpressions']()(); }); + describe('output emitter', () => { + outputDefs.forEach((outputDef) => { + describe(`${outputDef['name']}`, () => { + var expressions: any /** TODO #9100 */; + beforeEach(() => { expressions = outputDef['getExpressions']()(); }); - it('should support literals', () => { - expect(expressions['stringLiteral']).toEqual('Hello World!'); - expect(expressions['intLiteral']).toEqual(42); - expect(expressions['boolLiteral']).toEqual(true); - expect(expressions['arrayLiteral']).toEqual([0]); - expect(expressions['mapLiteral']).toEqual({'key0': 0}); - }); + it('should support literals', () => { + expect(expressions['stringLiteral']).toEqual('Hello World!'); + expect(expressions['intLiteral']).toEqual(42); + expect(expressions['boolLiteral']).toEqual(true); + expect(expressions['arrayLiteral']).toEqual([0]); + expect(expressions['mapLiteral']).toEqual({'key0': 0}); + }); - it('should support reading vars/keys/props', () => { - expect(expressions['readVar']).toEqual('someValue'); - expect(expressions['readKey']).toEqual('someValue'); - expect(expressions['readPropExternalInstance']).toEqual('someValue'); - expect(expressions['readPropDynamicInstance']).toEqual('dynamicValue'); - expect(expressions['readGetterDynamicInstance']) - .toEqual({'data': 'someValue', 'dynamicProp': 'dynamicValue'}); - }); + it('should support reading vars/keys/props', () => { + expect(expressions['readVar']).toEqual('someValue'); + expect(expressions['readKey']).toEqual('someValue'); + expect(expressions['readPropExternalInstance']).toEqual('someValue'); + expect(expressions['readPropDynamicInstance']).toEqual('dynamicValue'); + expect(expressions['readGetterDynamicInstance']) + .toEqual({'data': 'someValue', 'dynamicProp': 'dynamicValue'}); + }); - it('should support writing to vars / keys / props', () => { - expect(expressions['changedVar']).toEqual('changedValue'); - expect(expressions['changedKey']).toEqual('changedValue'); - expect(expressions['changedPropExternalInstance']).toEqual('changedValue'); - expect(expressions['changedPropDynamicInstance']).toEqual('changedValue'); - }); + it('should support writing to vars / keys / props', () => { + expect(expressions['changedVar']).toEqual('changedValue'); + expect(expressions['changedKey']).toEqual('changedValue'); + expect(expressions['changedPropExternalInstance']).toEqual('changedValue'); + expect(expressions['changedPropDynamicInstance']).toEqual('changedValue'); + }); - it('should support declaring functions with parameters and return', () => { - expect(expressions['fn']('someParam')).toEqual({'param': 'someParam'}); - expect(expressions['closureInDynamicInstance']('someParam')).toEqual({ - 'param': 'someParam', - 'data': 'someValue', - 'dynamicProp': 'dynamicValue' - }); - }); + it('should support declaring functions with parameters and return', () => { + expect(expressions['fn']('someParam')).toEqual({'param': 'someParam'}); + expect(expressions['closureInDynamicInstance']('someParam')) + .toEqual({'param': 'someParam', 'data': 'someValue', 'dynamicProp': 'dynamicValue'}); + }); - it('should support invoking functions and methods', () => { - expect(expressions['invokeFn']).toEqual({'param': 'someParam'}); - expect(expressions['concatedArray']).toEqual([0, 1]); - expect(expressions['invokeMethodExternalInstance']) - .toEqual({'data': 'someValue', 'param': 'someParam'}); - expect(expressions['invokeMethodExternalInstanceViaBind']) - .toEqual({'data': 'someValue', 'param': 'someParam'}); - expect(expressions['invokeMethodDynamicInstance']).toEqual({ - 'data': 'someValue', - 'dynamicProp': 'dynamicValue', - 'param': 'someParam' - }); - expect(expressions['invokeMethodDynamicInstanceViaBind']).toEqual({ - 'data': 'someValue', - 'dynamicProp': 'dynamicValue', - 'param': 'someParam' - }); - }); + it('should support invoking functions and methods', () => { + expect(expressions['invokeFn']).toEqual({'param': 'someParam'}); + expect(expressions['concatedArray']).toEqual([0, 1]); + expect(expressions['invokeMethodExternalInstance']) + .toEqual({'data': 'someValue', 'param': 'someParam'}); + expect(expressions['invokeMethodExternalInstanceViaBind']) + .toEqual({'data': 'someValue', 'param': 'someParam'}); + expect(expressions['invokeMethodDynamicInstance']) + .toEqual({'data': 'someValue', 'dynamicProp': 'dynamicValue', 'param': 'someParam'}); + expect(expressions['invokeMethodDynamicInstanceViaBind']) + .toEqual({'data': 'someValue', 'dynamicProp': 'dynamicValue', 'param': 'someParam'}); + }); - it('should support conditionals', () => { - expect(expressions['conditionalTrue']).toEqual('true'); - expect(expressions['conditionalFalse']).toEqual('false'); - }); + it('should support conditionals', () => { + expect(expressions['conditionalTrue']).toEqual('true'); + 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', () => { - expect(expressions['externalTestIdentifier']).toBe(ExternalClass); - expect(expressions['externalSrcIdentifier']).toBe(EventEmitter); - expect(expressions['externalEnumIdentifier']).toBe(ViewType.HOST); - }); + it('should support reading external identifiers', () => { + expect(expressions['externalTestIdentifier']).toBe(ExternalClass); + expect(expressions['externalSrcIdentifier']).toBe(EventEmitter); + expect(expressions['externalEnumIdentifier']).toBe(ViewType.HOST); + }); - it('should support instantiating classes', () => { - expect(expressions['externalInstance']).toBeAnInstanceOf(ExternalClass); - // Note: toBeAnInstanceOf does not check super classes in Dart... - expect(expressions['dynamicInstance'] instanceof ExternalClass).toBe(true); - }); + it('should support instantiating classes', () => { + expect(expressions['externalInstance']).toBeAnInstanceOf(ExternalClass); + // Note: toBeAnInstanceOf does not check super classes in Dart... + expect(expressions['dynamicInstance'] instanceof ExternalClass).toBe(true); + }); - describe('operators', () => { - var ops: any /** TODO #9100 */; - var aObj: any /** TODO #9100 */, bObj: any /** TODO #9100 */; - beforeEach(() => { - ops = expressions['operators']; - aObj = new Object(); - bObj = new Object(); - }); - it('should support ==', () => { - expect(ops['=='](aObj, aObj)).toBe(true); - expect(ops['=='](aObj, bObj)).toBe(false); - expect(ops['=='](1, 1)).toBe(true); - expect(ops['=='](0, 1)).toBe(false); - expect(ops['==']('a', 'a')).toBe(true); - expect(ops['==']('a', 'b')).toBe(false); - }); - it('should support !=', () => { - expect(ops['!='](aObj, aObj)).toBe(false); - expect(ops['!='](aObj, bObj)).toBe(true); - expect(ops['!='](1, 1)).toBe(false); - expect(ops['!='](0, 1)).toBe(true); - expect(ops['!=']('a', 'a')).toBe(false); - expect(ops['!=']('a', 'b')).toBe(true); - }); - it('should support ===', () => { - expect(ops['==='](aObj, aObj)).toBe(true); - expect(ops['==='](aObj, bObj)).toBe(false); - expect(ops['==='](1, 1)).toBe(true); - expect(ops['==='](0, 1)).toBe(false); - }); - it('should support !==', () => { - expect(ops['!=='](aObj, aObj)).toBe(false); - expect(ops['!=='](aObj, bObj)).toBe(true); - expect(ops['!=='](1, 1)).toBe(false); - expect(ops['!=='](0, 1)).toBe(true); - }); - it('should support -', () => { expect(ops['-'](3, 2)).toEqual(1); }); - it('should support +', () => { expect(ops['+'](1, 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['%'](3, 2)).toEqual(1); }); - it('should support &&', () => { - expect(ops['&&'](true, true)).toBe(true); - expect(ops['&&'](true, false)).toBe(false); - }); - it('should support ||', () => { - expect(ops['||'](true, false)).toBe(true); - expect(ops['||'](false, false)).toBe(false); - }); - it('should support <', () => { - expect(ops['<'](1, 2)).toBe(true); - expect(ops['<'](1, 1)).toBe(false); - }); - it('should support <=', () => { - expect(ops['<='](1, 2)).toBe(true); - expect(ops['<='](1, 1)).toBe(true); - }); - it('should support >', () => { - expect(ops['>'](2, 1)).toBe(true); - expect(ops['>'](1, 1)).toBe(false); - }); - it('should support >=', () => { - expect(ops['>='](2, 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'); - } - }); + describe('operators', () => { + var ops: any /** TODO #9100 */; + var aObj: any /** TODO #9100 */, bObj: any /** TODO #9100 */; + beforeEach(() => { + ops = expressions['operators']; + aObj = new Object(); + bObj = new Object(); + }); + it('should support ==', () => { + expect(ops['=='](aObj, aObj)).toBe(true); + expect(ops['=='](aObj, bObj)).toBe(false); + expect(ops['=='](1, 1)).toBe(true); + expect(ops['=='](0, 1)).toBe(false); + expect(ops['==']('a', 'a')).toBe(true); + expect(ops['==']('a', 'b')).toBe(false); + }); + it('should support !=', () => { + expect(ops['!='](aObj, aObj)).toBe(false); + expect(ops['!='](aObj, bObj)).toBe(true); + expect(ops['!='](1, 1)).toBe(false); + expect(ops['!='](0, 1)).toBe(true); + expect(ops['!=']('a', 'a')).toBe(false); + expect(ops['!=']('a', 'b')).toBe(true); + }); + it('should support ===', () => { + expect(ops['==='](aObj, aObj)).toBe(true); + expect(ops['==='](aObj, bObj)).toBe(false); + expect(ops['==='](1, 1)).toBe(true); + expect(ops['==='](0, 1)).toBe(false); + }); + it('should support !==', () => { + expect(ops['!=='](aObj, aObj)).toBe(false); + expect(ops['!=='](aObj, bObj)).toBe(true); + expect(ops['!=='](1, 1)).toBe(false); + expect(ops['!=='](0, 1)).toBe(true); + }); + it('should support -', () => { expect(ops['-'](3, 2)).toEqual(1); }); + it('should support +', () => { expect(ops['+'](1, 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['%'](3, 2)).toEqual(1); }); + it('should support &&', () => { + expect(ops['&&'](true, true)).toBe(true); + expect(ops['&&'](true, false)).toBe(false); + }); + it('should support ||', () => { + expect(ops['||'](true, false)).toBe(true); + expect(ops['||'](false, false)).toBe(false); + }); + it('should support <', () => { + expect(ops['<'](1, 2)).toBe(true); + expect(ops['<'](1, 1)).toBe(false); + }); + it('should support <=', () => { + expect(ops['<='](1, 2)).toBe(true); + expect(ops['<='](1, 1)).toBe(true); + }); + it('should support >', () => { + expect(ops['>'](2, 1)).toBe(true); + expect(ops['>'](1, 1)).toBe(false); + }); + it('should support >=', () => { + expect(ops['>='](2, 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'); + } + }); }); + }); + }); } diff --git a/modules/@angular/compiler/test/runtime_compiler_spec.ts b/modules/@angular/compiler/test/runtime_compiler_spec.ts index 39fb831094..cf69f57249 100644 --- a/modules/@angular/compiler/test/runtime_compiler_spec.ts +++ b/modules/@angular/compiler/test/runtime_compiler_spec.ts @@ -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 {Injectable, Component, Input, ViewMetadata, Compiler, ComponentFactory, Injector, AppModule, AppModuleMetadata, AppModuleFactory} from '@angular/core'; import {ConcreteType, stringify} from '../src/facade/lang'; diff --git a/modules/@angular/compiler/test/selector_spec.ts b/modules/@angular/compiler/test/selector_spec.ts index e8136cb5a8..20eb0cb25b 100644 --- a/modules/@angular/compiler/test/selector_spec.ts +++ b/modules/@angular/compiler/test/selector_spec.ts @@ -6,8 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {SelectorMatcher} from '@angular/compiler/src/selector'; -import {CssSelector} from '@angular/compiler/src/selector'; +import {CssSelector, SelectorMatcher} from '@angular/compiler/src/selector'; import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter'; import {el} from '@angular/platform-browser/testing/browser_util'; diff --git a/modules/@angular/compiler/test/template_parser_spec.ts b/modules/@angular/compiler/test/template_parser_spec.ts index 09acd6097f..1c5332cf5c 100644 --- a/modules/@angular/compiler/test/template_parser_spec.ts +++ b/modules/@angular/compiler/test/template_parser_spec.ts @@ -1065,15 +1065,15 @@ Reference "#a" is defined several times ("
]#a>
type: new CompileTypeMetadata({moduleUrl: someModuleUrl, name: `SomeComp${compCounter++}`}), template: new CompileTemplateMetadata({ngContentSelectors: ngContentSelectors}) - }) + }); } function createDir(selector: string): CompileDirectiveMetadata { return CompileDirectiveMetadata.create({ selector: selector, - type: - new CompileTypeMetadata({moduleUrl: someModuleUrl, name: `SomeDir${compCounter++}`}) - }) + type: new CompileTypeMetadata( + {moduleUrl: someModuleUrl, name: `SomeDir${compCounter++}`}) + }); } describe('project text nodes', () => { diff --git a/modules/@angular/compiler/test/test_component_builder_spec.ts b/modules/@angular/compiler/test/test_component_builder_spec.ts index 7002c50c42..43528478bc 100644 --- a/modules/@angular/compiler/test/test_component_builder_spec.ts +++ b/modules/@angular/compiler/test/test_component_builder_spec.ts @@ -6,13 +6,11 @@ * 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 {AsyncTestCompleter} from '@angular/core/testing/testing_internal'; import {Injectable, Component, Input, ViewMetadata} from '@angular/core'; import {NgIf} from '@angular/common'; import {TimerWrapper} from '../src/facade/async'; -import {IS_DART} from '../src/facade/lang'; import {PromiseWrapper} from '../src/facade/promise'; import {dispatchEvent} from '@angular/platform-browser/testing/browser_util'; @@ -328,291 +326,289 @@ export function main() { expect(componentFixture.nativeElement).toHaveText('Mock'); })); - if (!IS_DART) { - describe('ComponentFixture', () => { - it('should auto detect changes if autoDetectChanges is called', - inject( - [TestComponentBuilder, AsyncTestCompleter], - (tcb: TestComponentBuilder, async: AsyncTestCompleter) => { + describe('ComponentFixture', () => { + it('should auto detect changes if autoDetectChanges is called', + inject( + [TestComponentBuilder, AsyncTestCompleter], + (tcb: TestComponentBuilder, async: AsyncTestCompleter) => { - tcb.createAsync(AutoDetectComp).then((componentFixture) => { - expect(componentFixture.ngZone).not.toBeNull(); - componentFixture.autoDetectChanges(); + tcb.createAsync(AutoDetectComp).then((componentFixture) => { + expect(componentFixture.ngZone).not.toBeNull(); + 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'); let element = componentFixture.debugElement.children[0]; dispatchEvent(element.nativeElement, 'click'); - expect(componentFixture.isStable()).toBe(true); - expect(componentFixture.nativeElement).toHaveText('11'); + 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 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)', + it('should allow changing members of the component', 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) => { + tcb.createAsync(MyIfComp).then((componentFixture) => { componentFixture.detectChanges(); - expect(componentFixture.nativeElement).toHaveText('1'); + expect(componentFixture.nativeElement).toHaveText('MyIf()'); - 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.componentInstance.showMore = true; componentFixture.detectChanges(); - expect(componentFixture.nativeElement).toHaveText('1'); + expect(componentFixture.nativeElement).toHaveText('MyIf(More)'); - 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(); - }); + 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(); - }); - })); - }); - }); - } + + }); }); } diff --git a/modules/@angular/compiler/test/util_spec.ts b/modules/@angular/compiler/test/util_spec.ts index 7ef4dc9d9f..43ff2fbf8b 100644 --- a/modules/@angular/compiler/test/util_spec.ts +++ b/modules/@angular/compiler/test/util_spec.ts @@ -6,7 +6,7 @@ * 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 {SyncAsyncResult} from '../src/util'; @@ -20,5 +20,5 @@ export function main() { sar.asyncResult.then((v: any) => expect(v).toBe(syncValue)); })); }); - }) + }); } diff --git a/modules/@angular/compiler/test/view_resolver_mock_spec.ts b/modules/@angular/compiler/test/view_resolver_mock_spec.ts index 1a602768f6..ae0b009b33 100644 --- a/modules/@angular/compiler/test/view_resolver_mock_spec.ts +++ b/modules/@angular/compiler/test/view_resolver_mock_spec.ts @@ -8,10 +8,9 @@ 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 {Component, ViewMetadata, Injector} from '@angular/core'; -import {isBlank} from '../src/facade/lang'; export function main() { describe('MockViewResolver', () => { diff --git a/modules/@angular/compiler/test/xhr_mock_spec.ts b/modules/@angular/compiler/test/xhr_mock_spec.ts index e7b8bcac16..7732c0d679 100644 --- a/modules/@angular/compiler/test/xhr_mock_spec.ts +++ b/modules/@angular/compiler/test/xhr_mock_spec.ts @@ -6,8 +6,7 @@ * 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} from '@angular/core/testing/testing_internal'; +import {AsyncTestCompleter, beforeEach, ddescribe, describe, expect, iit, inject, it,} from '@angular/core/testing/testing_internal'; import {MockXHR} from '@angular/compiler/testing/xhr_mock'; import {PromiseWrapper} from '../src/facade/async'; import {isPresent} from '../src/facade/lang'; @@ -19,8 +18,7 @@ export function main() { beforeEach(() => { xhr = new MockXHR(); }); function expectResponse( - request: Promise, url: string, response: string, - done: any /** TODO #9100 */ = null) { + request: Promise, url: string, response: string, done: () => void = null) { function onResponse(text: string): string { if (response === null) { throw `Unexpected response ${url} -> ${text}`; diff --git a/modules/@angular/core/test/animation/animation_group_player_spec.ts b/modules/@angular/core/test/animation/animation_group_player_spec.ts index 7a3064d4b6..8d320a07b3 100644 --- a/modules/@angular/core/test/animation/animation_group_player_spec.ts +++ b/modules/@angular/core/test/animation/animation_group_player_spec.ts @@ -7,7 +7,6 @@ */ import {AnimationGroupPlayer} from '../../src/animation/animation_group_player'; -import {isPresent} from '../../src/facade/lang'; import {fakeAsync, flushMicrotasks} from '../../testing'; import {MockAnimationPlayer} from '../../testing/mock_animation_player'; import {AsyncTestCompleter, beforeEach, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '../../testing/testing_internal'; @@ -32,7 +31,7 @@ export function main() { } else { expect(actual).not.toEqual(status); } - } + }; var assertPlaying = (player: MockAnimationPlayer, isPlaying: boolean) => { assertLastStatus(player, 'play', isPlaying); diff --git a/modules/@angular/core/test/animation/animation_integration_spec.ts b/modules/@angular/core/test/animation/animation_integration_spec.ts index bce82f5fa2..80419e233d 100644 --- a/modules/@angular/core/test/animation/animation_integration_spec.ts +++ b/modules/@angular/core/test/animation/animation_integration_spec.ts @@ -7,7 +7,6 @@ */ import {NgIf} from '@angular/common'; -import {CompilerConfig} from '@angular/compiler'; import {TestComponentBuilder} from '@angular/core/testing'; import {AnimationDriver} from '@angular/platform-browser/src/dom/animation_driver'; 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 {AnimationPlayer} from '../../src/animation/animation_player'; import {AnimationStyles} from '../../src/animation/animation_styles'; -import {AnimationEntryMetadata, animate, group, keyframes, sequence, state, style, transition, trigger} from '../../src/animation/metadata'; -import {AUTO_STYLE} from '../../src/animation/metadata'; -import {IS_DART, isArray, isPresent} from '../../src/facade/lang'; +import {AUTO_STYLE, AnimationEntryMetadata, animate, group, keyframes, sequence, state, style, transition, trigger} from '../../src/animation/metadata'; +import {isArray, isPresent} from '../../src/facade/lang'; import {configureCompiler, configureModule, fakeAsync, flushMicrotasks, tick} from '../../testing'; import {MockAnimationPlayer} from '../../testing/mock_animation_player'; import {AsyncTestCompleter, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '../../testing/testing_internal'; export function main() { - if (IS_DART) { - declareTests({useJit: false}); - } else { - describe('jit', () => { declareTests({useJit: true}); }); - describe('no jit', () => { declareTests({useJit: false}); }); - } + describe('jit', () => { declareTests({useJit: true}); }); + describe('no jit', () => { declareTests({useJit: false}); }); } function declareTests({useJit}: {useJit: boolean}) { @@ -254,18 +248,17 @@ function declareTests({useJit}: {useJit: boolean}) { }))); describe('groups/sequences', () => { - var assertPlaying = - (player: MockAnimationDriver, isPlaying: any /** TODO #9100 */) => { - var method = 'play'; - var lastEntry = player.log.length > 0 ? player.log[player.log.length - 1] : null; - if (isPresent(lastEntry)) { - if (isPlaying) { - expect(lastEntry).toEqual(method); - } else { - expect(lastEntry).not.toEqual(method); - } - } + var assertPlaying = (player: MockAnimationDriver, isPlaying: any /** TODO #9100 */) => { + var method = 'play'; + var lastEntry = player.log.length > 0 ? player.log[player.log.length - 1] : null; + if (isPresent(lastEntry)) { + if (isPlaying) { + expect(lastEntry).toEqual(method); + } else { + expect(lastEntry).not.toEqual(method); } + } + }; it('should run animations in sequence one by one if a top-level array is used', inject( diff --git a/modules/@angular/core/test/animation/animation_sequence_player_spec.ts b/modules/@angular/core/test/animation/animation_sequence_player_spec.ts index e5fec37f5f..f266d669b2 100644 --- a/modules/@angular/core/test/animation/animation_sequence_player_spec.ts +++ b/modules/@angular/core/test/animation/animation_sequence_player_spec.ts @@ -32,7 +32,7 @@ export function main() { } else { expect(actual).not.toEqual(status); } - } + }; var assertPlaying = (player: MockAnimationPlayer, isPlaying: boolean) => { assertLastStatus(player, 'play', isPlaying); diff --git a/modules/@angular/core/test/animation/animation_style_util_spec.ts b/modules/@angular/core/test/animation/animation_style_util_spec.ts index ee9ec17da8..a6af0bd914 100644 --- a/modules/@angular/core/test/animation/animation_style_util_spec.ts +++ b/modules/@angular/core/test/animation/animation_style_util_spec.ts @@ -23,7 +23,7 @@ export function main() { var newStyles = {background: 'red'}; var 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', () => { @@ -43,7 +43,7 @@ export function main() { var newStyles = {color: '*', border: '*'}; var flag = '*'; 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}); }); }); diff --git a/modules/@angular/core/test/application_ref_spec.ts b/modules/@angular/core/test/application_ref_spec.ts index 091767c0a9..dad14d0d57 100644 --- a/modules/@angular/core/test/application_ref_spec.ts +++ b/modules/@angular/core/test/application_ref_spec.ts @@ -6,12 +6,10 @@ * 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} from '@angular/core/testing/testing_internal'; -import {Type} from '@angular/core'; +import {AsyncTestCompleter, ddescribe, describe, it, iit, xit, expect, beforeEach, afterEach, inject,} from '@angular/core/testing/testing_internal'; import {SpyChangeDetectorRef} from './spies'; 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 {BaseException} from '../src/facade/exceptions'; import {PromiseWrapper, PromiseCompleter, TimerWrapper} from '../src/facade/async'; diff --git a/modules/@angular/core/test/change_detection/differs/default_iterable_differ_spec.ts b/modules/@angular/core/test/change_detection/differs/default_iterable_differ_spec.ts index f7724ab6bd..e8b491e152 100644 --- a/modules/@angular/core/test/change_detection/differs/default_iterable_differ_spec.ts +++ b/modules/@angular/core/test/change_detection/differs/default_iterable_differ_spec.ts @@ -17,13 +17,13 @@ import {iterableChangesAsString} from '../../change_detection/util'; class ItemWithId { constructor(private id: string) {} - toString() { return `{id: ${this.id}}` } + toString() { return `{id: ${this.id}}`; } } class ComplexItem { 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 @@ -328,7 +328,7 @@ export function main() { var trackByItemId = (index: number, item: any): any => item.id; 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); }); diff --git a/modules/@angular/core/test/debug/debug_node_spec.ts b/modules/@angular/core/test/debug/debug_node_spec.ts index 89ec4b157f..bbc4461a8b 100644 --- a/modules/@angular/core/test/debug/debug_node_spec.ts +++ b/modules/@angular/core/test/debug/debug_node_spec.ts @@ -6,13 +6,12 @@ * 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} 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 {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 {NgFor, NgIf} from '@angular/common'; diff --git a/modules/@angular/core/test/di/injector_spec.ts b/modules/@angular/core/test/di/injector_spec.ts index 04e242f401..31d544483d 100644 --- a/modules/@angular/core/test/di/injector_spec.ts +++ b/modules/@angular/core/test/di/injector_spec.ts @@ -14,12 +14,14 @@ import {IS_DART} from '../../src/facade/lang'; export function main() { describe('Injector.NULL', () => { - it('should throw if no arg is given', () => {expect(() => Injector.NULL.get('someToken')) - .toThrowError('No provider for someToken!')}); + it('should throw if no arg is given', () => { + expect(() => Injector.NULL.get('someToken')).toThrowError('No provider for someToken!'); + }); - it('should throw if THROW_IF_NOT_FOUND is given', - () => {expect(() => Injector.NULL.get('someToken', Injector.THROW_IF_NOT_FOUND)) - .toThrowError('No provider for someToken!')}); + it('should throw if THROW_IF_NOT_FOUND is given', () => { + expect(() => Injector.NULL.get('someToken', Injector.THROW_IF_NOT_FOUND)) + .toThrowError('No provider for someToken!'); + }); it('should return the default value', () => { expect(Injector.NULL.get('someToken', 'notFound')).toEqual('notFound'); }); diff --git a/modules/@angular/core/test/directive_lifecycle_integration_spec.ts b/modules/@angular/core/test/directive_lifecycle_integration_spec.ts index 3ae08d2b04..a1b159fc8d 100644 --- a/modules/@angular/core/test/directive_lifecycle_integration_spec.ts +++ b/modules/@angular/core/test/directive_lifecycle_integration_spec.ts @@ -9,8 +9,7 @@ import {AfterContentChecked, AfterContentInit, AfterViewChecked, AfterViewInit, DoCheck, OnChanges, OnInit} from '@angular/core'; import {Component, Directive, ViewMetadata} from '@angular/core/src/metadata'; import {TestComponentBuilder} from '@angular/core/testing'; -import {AsyncTestCompleter} from '@angular/core/testing/testing_internal'; -import {Log, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} 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'; export function main() { describe('directive lifecycle integration spec', () => { diff --git a/modules/@angular/core/test/facade/observable_spec.ts b/modules/@angular/core/test/facade/observable_spec.ts index 42d257948b..122ce63a30 100644 --- a/modules/@angular/core/test/facade/observable_spec.ts +++ b/modules/@angular/core/test/facade/observable_spec.ts @@ -6,10 +6,9 @@ * 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} from '@angular/core/testing/testing_internal'; +import {AsyncTestCompleter, beforeEach, ddescribe, describe, expect, iit, inject, it, xit} from '@angular/core/testing/testing_internal'; -import {EventEmitter, Observable, PromiseWrapper, Subject} from '../../src/facade/async'; +import {Observable} from '../../src/facade/async'; export function main() { describe('Observable', () => { diff --git a/modules/@angular/core/test/fake_async_spec.ts b/modules/@angular/core/test/fake_async_spec.ts index 58f06e146c..68b8fb8e20 100644 --- a/modules/@angular/core/test/fake_async_spec.ts +++ b/modules/@angular/core/test/fake_async_spec.ts @@ -107,7 +107,7 @@ export function main() { describe('timers', () => { it('should run queued zero duration timer on zero tick', fakeAsync(() => { var ran = false; - TimerWrapper.setTimeout(() => {ran = true}, 0); + TimerWrapper.setTimeout(() => { ran = true; }, 0); expect(ran).toEqual(false); diff --git a/modules/@angular/core/test/forward_ref_integration_spec.ts b/modules/@angular/core/test/forward_ref_integration_spec.ts index 8e47264d60..4fb2975c1e 100644 --- a/modules/@angular/core/test/forward_ref_integration_spec.ts +++ b/modules/@angular/core/test/forward_ref_integration_spec.ts @@ -7,11 +7,9 @@ */ import {NgFor} from '@angular/common'; -import {Component, Directive, Inject, Query, QueryList, bind, forwardRef, provide, resolveForwardRef} from '@angular/core'; -import {asNativeElements} from '@angular/core'; +import {Component, Directive, Inject, Query, QueryList, asNativeElements, bind, forwardRef, provide, resolveForwardRef} from '@angular/core'; import {TestComponentBuilder} from '@angular/core/testing'; -import {beforeEach, ddescribe, describe, expect, iit, inject, it, xit} from '@angular/core/testing/testing_internal'; -import {AsyncTestCompleter} from '@angular/core/testing/testing_internal'; +import {AsyncTestCompleter, beforeEach, ddescribe, describe, expect, iit, inject, it, xit} from '@angular/core/testing/testing_internal'; export function main() { describe('forwardRef integration', function() { diff --git a/modules/@angular/core/test/linker/app_module_integration_spec.ts b/modules/@angular/core/test/linker/app_module_integration_spec.ts index 96e07b2771..8c84af5602 100644 --- a/modules/@angular/core/test/linker/app_module_integration_spec.ts +++ b/modules/@angular/core/test/linker/app_module_integration_spec.ts @@ -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 {ComponentFixture, configureCompiler} from '@angular/core/testing'; import {AsyncTestCompleter, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal'; diff --git a/modules/@angular/core/test/linker/change_detection_integration_spec.ts b/modules/@angular/core/test/linker/change_detection_integration_spec.ts index c3c35881a9..22bad2cdb3 100644 --- a/modules/@angular/core/test/linker/change_detection_integration_spec.ts +++ b/modules/@angular/core/test/linker/change_detection_integration_spec.ts @@ -12,8 +12,7 @@ import {TEST_COMPILER_PROVIDERS} from '@angular/compiler/test/test_bindings'; 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 {DebugDomRenderer} from '@angular/core/src/debug/debug_renderer'; -import {TestComponentBuilder} from '@angular/core/testing'; -import {ComponentFixture, configureCompiler, configureModule, fakeAsync, flushMicrotasks, tick} from '@angular/core/testing'; +import {ComponentFixture, TestComponentBuilder, 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 {By} from '@angular/platform-browser/src/dom/debug/by'; 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(() => { - expect(() => {_bindSimpleProp('(event)="$event=1"')}) - .toThrowError(new RegExp('Cannot assign to a reference or variable!')); + expect(() => { + _bindSimpleProp('(event)="$event=1"'); + }).toThrowError(new RegExp('Cannot assign to a reference or variable!')); })); it('should support short-circuiting', fakeAsync(() => { @@ -625,7 +625,7 @@ export function main() { describe('reading directives', () => { it('should read directive properties', fakeAsync(() => { var ctx = createCompFixture( - '
') + '
'); ctx.detectChanges(false); expect(renderLog.loggedValues).toEqual([42]); })); @@ -1479,7 +1479,7 @@ class Address { set zipcode(v) { this._zipcode = v; } - toString(): string { return isBlank(this.city) ? '-' : this.city } + toString(): string { return this.city || '-'; } } @Component({selector: 'root'}) diff --git a/modules/@angular/core/test/linker/dynamic_component_loader_spec.ts b/modules/@angular/core/test/linker/dynamic_component_loader_spec.ts index 200518bb72..8dc2472c8f 100644 --- a/modules/@angular/core/test/linker/dynamic_component_loader_spec.ts +++ b/modules/@angular/core/test/linker/dynamic_component_loader_spec.ts @@ -6,12 +6,11 @@ * 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} 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 {ComponentFixture, TestComponentBuilder} from '@angular/core/testing'; import {Predicate} from '../../src/facade/collection'; -import {Injector, OnDestroy, DebugElement, Type, ViewContainerRef, ViewChild} from '@angular/core'; -import {Component, ViewMetadata} from '@angular/core/src/metadata'; +import {Injector, DebugElement, Type, ViewContainerRef, ViewChild} from '@angular/core'; +import {Component} from '@angular/core/src/metadata'; import {DynamicComponentLoader} from '@angular/core/src/linker/dynamic_component_loader'; import {ElementRef} from '@angular/core/src/linker/element_ref'; import {DOCUMENT} from '@angular/platform-browser/src/dom/dom_tokens'; diff --git a/modules/@angular/core/test/linker/integration_spec.ts b/modules/@angular/core/test/linker/integration_spec.ts index 8762801275..f6ea836f4e 100644 --- a/modules/@angular/core/test/linker/integration_spec.ts +++ b/modules/@angular/core/test/linker/integration_spec.ts @@ -6,9 +6,8 @@ * 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 {AsyncTestCompleter} from '@angular/core/testing/testing_internal'; import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter'; import {isPresent, stringify, isBlank,} from '../../src/facade/lang'; 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 {Renderer} from '@angular/core/src/render'; -import {IS_DART} from '../../src/facade/lang'; import {el, dispatchEvent} from '@angular/platform-browser/testing/browser_util'; const ANCHOR_ELEMENT = /*@ts2dart_const*/ new OpaqueToken('AnchorElement'); export function main() { - if (IS_DART) { - declareTests({useJit: false}); - } else { - describe('jit', () => { declareTests({useJit: true}); }); + describe('jit', () => { declareTests({useJit: true}); }); - describe('no jit', () => { declareTests({useJit: false}); }); - } + describe('no jit', () => { declareTests({useJit: false}); }); } function declareTests({useJit}: {useJit: boolean}) { @@ -583,18 +577,18 @@ function declareTests({useJit}: {useJit: boolean}) { inject( [TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: AsyncTestCompleter) => { - tcb.overrideView(MyComp, new ViewMetadata({ - template: '

', - directives: [ChildComp] - })) + tcb.overrideView(MyComp, new ViewMetadata({ + template: '

', + directives: [ChildComp] + })) + .createAsync(MyComp) + .then((fixture) => { + expect(fixture.debugElement.children[0].children[0].references['alice']) + .toBeAnInstanceOf(ChildComp); - .createAsync(MyComp) - .then((fixture) => { - expect(fixture.debugElement.children[0].children[0].references['alice']) - .toBeAnInstanceOf(ChildComp); - - async.done(); - })})); + async.done(); + }); + })); it('should assign a directive to a ref-', inject( @@ -604,7 +598,6 @@ function declareTests({useJit}: {useJit: boolean}) { template: '
', directives: [ExportDir] })) - .createAsync(MyComp) .then((fixture) => { expect(fixture.debugElement.children[0].children[0].references['localdir']) @@ -618,97 +611,96 @@ function declareTests({useJit}: {useJit: boolean}) { inject( [TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: AsyncTestCompleter) => { - tcb.overrideView( - MyComp, new ViewMetadata({ - template: - '|{{alice.ctxProp}}|', - directives: [ChildComp, NgIf] - })) + tcb.overrideView( + MyComp, new ViewMetadata({ + template: + '|{{alice.ctxProp}}|', + directives: [ChildComp, NgIf] + })) + .createAsync(MyComp) + .then((fixture) => { + fixture.detectChanges(); - .createAsync(MyComp) - .then((fixture) => { - fixture.detectChanges(); - - expect(fixture.debugElement.nativeElement).toHaveText('hello|hello|hello'); - async.done(); - })})); + expect(fixture.debugElement.nativeElement).toHaveText('hello|hello|hello'); + async.done(); + }); + })); it('should assign two component instances each with a ref-', inject( [TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: AsyncTestCompleter) => { - tcb.overrideView( - MyComp, new ViewMetadata({ - template: - '

', - directives: [ChildComp] - })) + tcb.overrideView( + MyComp, new ViewMetadata({ + template: + '

', + directives: [ChildComp] + })) + .createAsync(MyComp) + .then((fixture) => { + var pEl = fixture.debugElement.children[0]; - .createAsync(MyComp) - .then((fixture) => { - var pEl = fixture.debugElement.children[0]; + var alice = pEl.children[0].references['alice']; + var bob = pEl.children[1].references['bob']; + expect(alice).toBeAnInstanceOf(ChildComp); + expect(bob).toBeAnInstanceOf(ChildComp); + expect(alice).not.toBe(bob); - var alice = pEl.children[0].references['alice']; - var bob = pEl.children[1].references['bob']; - expect(alice).toBeAnInstanceOf(ChildComp); - expect(bob).toBeAnInstanceOf(ChildComp); - expect(alice).not.toBe(bob); - - async.done(); - })})); + async.done(); + }); + })); it('should assign the component instance to a ref- with shorthand syntax', inject( [TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: AsyncTestCompleter) => { - tcb.overrideView(MyComp, new ViewMetadata({ - template: '', - directives: [ChildComp] - })) + tcb.overrideView( + MyComp, + new ViewMetadata( + {template: '', directives: [ChildComp]})) + .createAsync(MyComp) + .then((fixture) => { - .createAsync(MyComp) - .then((fixture) => { + expect(fixture.debugElement.children[0].references['alice']) + .toBeAnInstanceOf(ChildComp); - expect(fixture.debugElement.children[0].references['alice']) - .toBeAnInstanceOf(ChildComp); - - async.done(); - })})); + async.done(); + }); + })); it('should assign the element instance to a user-defined variable', inject( [TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: AsyncTestCompleter) => { - tcb.overrideView( - MyComp, new ViewMetadata( - {template: '
Hello
'})) + tcb.overrideView( + MyComp, new ViewMetadata( + {template: '
Hello
'})) + .createAsync(MyComp) + .then((fixture) => { - .createAsync(MyComp) - .then((fixture) => { + var value = fixture.debugElement.children[0].children[0].references['alice']; + expect(value).not.toBe(null); + expect(value.tagName.toLowerCase()).toEqual('div'); - var value = - fixture.debugElement.children[0].children[0].references['alice']; - expect(value).not.toBe(null); - expect(value.tagName.toLowerCase()).toEqual('div'); - - async.done(); - })})); + async.done(); + }); + })); it('should assign the TemplateRef to a user-defined variable', inject( [TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: AsyncTestCompleter) => { - tcb.overrideView( - MyComp, new ViewMetadata({template: ''})) + tcb.overrideView( + MyComp, new ViewMetadata({template: ''})) + .createAsync(MyComp) + .then((fixture) => { - .createAsync(MyComp) - .then((fixture) => { + var value = fixture.debugElement.childNodes[0].references['alice']; + expect(value).toBeAnInstanceOf(TemplateRef_); - var value = fixture.debugElement.childNodes[0].references['alice']; - expect(value).toBeAnInstanceOf(TemplateRef_); - - async.done(); - })})); + async.done(); + }); + })); it('should preserve case', inject( @@ -718,7 +710,6 @@ function declareTests({useJit}: {useJit: boolean}) { template: '

', directives: [ChildComp] })) - .createAsync(MyComp) .then((fixture) => { expect(fixture.debugElement.children[0].children[0].references['superAlice']) @@ -740,7 +731,6 @@ function declareTests({useJit}: {useJit: boolean}) { '', directives: [ChildCompNoTemplate, NgFor] })) - .createAsync(MyComp) .then((fixture) => { fixture.detectChanges(); @@ -760,53 +750,53 @@ function declareTests({useJit}: {useJit: boolean}) { [TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: AsyncTestCompleter) => { - tcb.overrideView(MyComp, new ViewMetadata({ - template: '', - directives: [[[PushCmpWithRef]]] - })) + tcb.overrideView(MyComp, new ViewMetadata({ + template: '', + directives: [[[PushCmpWithRef]]] + })) + .createAsync(MyComp) + .then((fixture) => { - .createAsync(MyComp) - .then((fixture) => { + var cmp = fixture.debugElement.children[0].references['cmp']; - var cmp = fixture.debugElement.children[0].references['cmp']; + fixture.detectChanges(); + expect(cmp.numberOfChecks).toEqual(1); - fixture.detectChanges(); - expect(cmp.numberOfChecks).toEqual(1); + fixture.detectChanges(); + expect(cmp.numberOfChecks).toEqual(1); - fixture.detectChanges(); - expect(cmp.numberOfChecks).toEqual(1); + cmp.propagate(); - cmp.propagate(); - - fixture.detectChanges(); - expect(cmp.numberOfChecks).toEqual(2); - async.done(); - })})); + fixture.detectChanges(); + expect(cmp.numberOfChecks).toEqual(2); + async.done(); + }); + })); it('should be checked when its bindings got updated', inject( [TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: AsyncTestCompleter) => { - tcb.overrideView(MyComp, new ViewMetadata({ - template: '', - directives: [[[PushCmp]]] - })) + tcb.overrideView(MyComp, new ViewMetadata({ + template: '', + directives: [[[PushCmp]]] + })) + .createAsync(MyComp) + .then((fixture) => { + var cmp = fixture.debugElement.children[0].references['cmp']; - .createAsync(MyComp) - .then((fixture) => { - var cmp = fixture.debugElement.children[0].references['cmp']; + fixture.debugElement.componentInstance.ctxProp = 'one'; + fixture.detectChanges(); + expect(cmp.numberOfChecks).toEqual(1); - fixture.debugElement.componentInstance.ctxProp = 'one'; - fixture.detectChanges(); - expect(cmp.numberOfChecks).toEqual(1); + fixture.debugElement.componentInstance.ctxProp = 'two'; + fixture.detectChanges(); + expect(cmp.numberOfChecks).toEqual(2); - fixture.debugElement.componentInstance.ctxProp = 'two'; - fixture.detectChanges(); - expect(cmp.numberOfChecks).toEqual(2); - - async.done(); - })})); + async.done(); + }); + })); if (getDOM().supportsDOMEvents()) { it('should allow to destroy a component from within a host event handler', @@ -835,69 +825,68 @@ function declareTests({useJit}: {useJit: boolean}) { [TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: AsyncTestCompleter) => { - tcb.overrideView(MyComp, new ViewMetadata({ - template: '', - directives: [[[PushCmp]]] - })) + tcb.overrideView(MyComp, new ViewMetadata({ + template: '', + 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) - .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', {}); - cmpEl.children[0].triggerEventHandler('click', {}); + // regular element + fixture.detectChanges(); + fixture.detectChanges(); + expect(cmp.numberOfChecks).toEqual(2); - // regular element - fixture.detectChanges(); - fixture.detectChanges(); - expect(cmp.numberOfChecks).toEqual(2); + // element inside of an *ngIf + cmpEl.children[1].triggerEventHandler('click', {}); - // element inside of an *ngIf - cmpEl.children[1].triggerEventHandler('click', {}); + fixture.detectChanges(); + fixture.detectChanges(); + expect(cmp.numberOfChecks).toEqual(3); - fixture.detectChanges(); - fixture.detectChanges(); - expect(cmp.numberOfChecks).toEqual(3); + // element inside a nested component + cmpEl.children[2].children[0].triggerEventHandler('click', {}); - // element inside a nested component - cmpEl.children[2].children[0].triggerEventHandler('click', {}); + fixture.detectChanges(); + fixture.detectChanges(); + expect(cmp.numberOfChecks).toEqual(4); - fixture.detectChanges(); - fixture.detectChanges(); - expect(cmp.numberOfChecks).toEqual(4); - - async.done(); - })})); + async.done(); + }); + })); it('should not affect updating properties on the component', inject( [TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: AsyncTestCompleter) => { - tcb.overrideView( - MyComp, new ViewMetadata({ - template: - '', - directives: [[[PushCmpWithRef]]] - })) + tcb.overrideView( + MyComp, new ViewMetadata({ + template: '', + directives: [[[PushCmpWithRef]]] + })) + .createAsync(MyComp) + .then((fixture) => { - .createAsync(MyComp) - .then((fixture) => { + var cmp = fixture.debugElement.children[0].references['cmp']; - 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.detectChanges(); - expect(cmp.prop).toEqual('one'); + fixture.debugElement.componentInstance.ctxProp = 'two'; + fixture.detectChanges(); + expect(cmp.prop).toEqual('two'); - fixture.debugElement.componentInstance.ctxProp = 'two'; - fixture.detectChanges(); - expect(cmp.prop).toEqual('two'); - - async.done(); - })})); + async.done(); + }); + })); if (getDOM().supportsDOMEvents()) { it('should be checked when an async pipe requests a check', @@ -932,27 +921,28 @@ function declareTests({useJit}: {useJit: boolean}) { inject( [TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: AsyncTestCompleter) => { - tcb.overrideView(MyComp, new ViewMetadata({ - template: ` + tcb.overrideView(MyComp, new ViewMetadata({ + template: `

`, - directives: [SomeDirective, CompWithHost] - })) + directives: [SomeDirective, CompWithHost] + })) - .createAsync(MyComp) - .then((fixture) => { + .createAsync(MyComp) + .then((fixture) => { - var childComponent = fixture.debugElement.children[0] - .children[0] - .children[0] - .references['child']; - expect(childComponent.myHost).toBeAnInstanceOf(SomeDirective); + var childComponent = fixture.debugElement.children[0] + .children[0] + .children[0] + .references['child']; + expect(childComponent.myHost).toBeAnInstanceOf(SomeDirective); - async.done(); - })})); + async.done(); + }); + })); it('should create a component that injects an @Host through viewcontainer directive', inject( @@ -989,7 +979,6 @@ function declareTests({useJit}: {useJit: boolean}) { template: '
', directives: [DirectiveEmittingEvent, DirectiveListeningEvent] })) - .createAsync(MyComp) .then((fixture) => { @@ -1026,7 +1015,6 @@ function declareTests({useJit}: {useJit: boolean}) { template: '', directives: [DirectiveEmittingEvent, DirectiveListeningEvent] })) - .createAsync(MyComp) .then((fixture) => { @@ -1057,7 +1045,6 @@ function declareTests({useJit}: {useJit: boolean}) { template: '
', directives: [DirectiveWithTwoWayBinding] })) - .createAsync(MyComp) .then((fixture) => { var tc = fixture.debugElement.children[0]; @@ -1085,7 +1072,6 @@ function declareTests({useJit}: {useJit: boolean}) { template: '
', directives: [DirectiveListeningDomEvent] })) - .createAsync(MyComp) .then((fixture) => { @@ -1115,7 +1101,6 @@ function declareTests({useJit}: {useJit: boolean}) { template: '
', directives: [DirectiveListeningDomEvent] })) - .createAsync(MyComp) .then((fixture) => { var tc = fixture.debugElement.children[0]; @@ -1144,7 +1129,6 @@ function declareTests({useJit}: {useJit: boolean}) { template: '
', directives: [DirectiveUpdatingHostAttributes] })) - .createAsync(MyComp) .then((fixture) => { fixture.detectChanges(); @@ -1165,7 +1149,6 @@ function declareTests({useJit}: {useJit: boolean}) { template: '
', directives: [DirectiveUpdatingHostProperties] })) - .createAsync(MyComp) .then((fixture) => { var tc = fixture.debugElement.children[0]; @@ -1195,7 +1178,6 @@ function declareTests({useJit}: {useJit: boolean}) { DirectiveListeningDomEventPrevent, DirectiveListeningDomEventNoPrevent ] })) - .createAsync(MyComp) .then((fixture) => { var dispatchedEvent = getDOM().createMouseEvent('click'); @@ -1225,7 +1207,6 @@ function declareTests({useJit}: {useJit: boolean}) { directives: [NgIf, DirectiveListeningDomEvent, DirectiveListeningDomEventOther] })) - .createAsync(MyComp) .then((fixture) => { globalCounter = 0; @@ -1269,7 +1250,6 @@ function declareTests({useJit}: {useJit: boolean}) { template: '
', directives: [DynamicViewport] })) - .createAsync(MyComp) .then((fixture) => { 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', - inject([TestComponentBuilder], (tcb: TestComponentBuilder) => { + it('should report a meaningful error when a directive is undefined', + inject([TestComponentBuilder], (tcb: TestComponentBuilder) => { - var undefinedValue: any = void(0); + var undefinedValue: any = void(0); - tcb = tcb.overrideView( - MyComp, new ViewMetadata({directives: [undefinedValue], template: ''})); + tcb = tcb.overrideView( + MyComp, new ViewMetadata({directives: [undefinedValue], template: ''})); - expect(() => tcb.createAsync(MyComp)) - .toThrowError( - `Unexpected directive value 'undefined' on the View of component '${stringify(MyComp)}'`); - })); - } + expect(() => tcb.createAsync(MyComp)) + .toThrowError( + `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)', inject( [TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: AsyncTestCompleter) => { - tcb.overrideView(MyComp, new ViewMetadata({template: '
{{a.b}}
'})) - - .createAsync(MyComp) - .then((fixture) => { - expect(() => fixture.detectChanges()).toThrowError(/:0:5/); - async.done(); - })})); + tcb.overrideView(MyComp, new ViewMetadata({template: '
{{a.b}}
'})) + .createAsync(MyComp) + .then((fixture) => { + expect(() => fixture.detectChanges()).toThrowError(/:0:5/); + async.done(); + }); + })); it('should specify a location of an error that happened during change detection (element property)', inject( [TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: AsyncTestCompleter) => { - tcb.overrideView(MyComp, new ViewMetadata({template: '
'})) - - .createAsync(MyComp) - .then((fixture) => { - expect(() => fixture.detectChanges()).toThrowError(/:0:5/); - async.done(); - })})); + tcb.overrideView(MyComp, new ViewMetadata({template: '
'})) + .createAsync(MyComp) + .then((fixture) => { + expect(() => fixture.detectChanges()).toThrowError(/:0:5/); + async.done(); + }); + })); it('should specify a location of an error that happened during change detection (directive property)', inject( [TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: AsyncTestCompleter) => { - tcb.overrideView(MyComp, new ViewMetadata({ - template: '', - directives: [ChildComp] - })) - - .createAsync(MyComp) - .then((fixture) => { - expect(() => fixture.detectChanges()).toThrowError(/:0:11/); - async.done(); - })})); + tcb.overrideView(MyComp, new ViewMetadata({ + template: '', + directives: [ChildComp] + })) + .createAsync(MyComp) + .then((fixture) => { + expect(() => fixture.detectChanges()).toThrowError(/:0:11/); + async.done(); + }); + })); }); it('should support imperative views', @@ -1725,34 +1703,32 @@ function declareTests({useJit}: {useJit: boolean}) { })); describe('Property bindings', () => { - if (!IS_DART) { - it('should throw on bindings to unknown properties', - inject( - [TestComponentBuilder, AsyncTestCompleter], - (tcb: TestComponentBuilder, async: AsyncTestCompleter) => { - tcb = tcb.overrideView( - MyComp, new ViewMetadata({template: '
'})) + it('should throw on bindings to unknown properties', + inject( + [TestComponentBuilder, AsyncTestCompleter], + (tcb: TestComponentBuilder, async: AsyncTestCompleter) => { + tcb = tcb.overrideView( + MyComp, new ViewMetadata({template: '
'})); - PromiseWrapper.catchError(tcb.createAsync(MyComp), (e) => { - expect(e.message).toEqual( - `Template parse errors:\nCan't bind to 'unknown' since it isn't a known native property ("
]unknown="{{ctxProp}}">
"): MyComp@0:5`); - async.done(); - return null; - }); - })); + PromiseWrapper.catchError(tcb.createAsync(MyComp), (e) => { + expect(e.message).toEqual( + `Template parse errors:\nCan't bind to 'unknown' since it isn't a known native property ("
]unknown="{{ctxProp}}">
"): MyComp@0:5`); + async.done(); + return null; + }); + })); - it('should not throw for property binding to a non-existing property when there is a matching directive property', - inject( - [TestComponentBuilder, AsyncTestCompleter], - (tcb: TestComponentBuilder, async: AsyncTestCompleter) => { - tcb.overrideView(MyComp, new ViewMetadata({ - template: '
', - directives: [MyDir] - })) - .createAsync(MyComp) - .then((val) => { async.done(); }); - })); - } + it('should not throw for property binding to a non-existing property when there is a matching directive property', + inject( + [TestComponentBuilder, AsyncTestCompleter], + (tcb: TestComponentBuilder, async: AsyncTestCompleter) => { + tcb.overrideView( + MyComp, + new ViewMetadata( + {template: '
', directives: [MyDir]})) + .createAsync(MyComp) + .then((val) => { async.done(); }); + })); it('should not be created when there is a directive with the same property', inject( @@ -1987,15 +1963,9 @@ function declareTests({useJit}: {useJit: boolean}) { expect(getDOM().getProperty(use, 'namespaceURI')) .toEqual('http://www.w3.org/2000/svg'); - if (!IS_DART) { - var firstAttribute = getDOM().getProperty(use, 'attributes')[0]; - expect(firstAttribute.name).toEqual('xlink:href'); - expect(firstAttribute.namespaceURI) - .toEqual('http://www.w3.org/1999/xlink'); - } else { - // For Dart where '_Attr' has no instance getter 'namespaceURI' - expect(getDOM().getOuterHTML(use)).toContain('xmlns:xlink'); - } + var firstAttribute = getDOM().getProperty(use, 'attributes')[0]; + expect(firstAttribute.name).toEqual('xlink:href'); + expect(firstAttribute.namespaceURI).toEqual('http://www.w3.org/1999/xlink'); async.done(); }); diff --git a/modules/@angular/core/test/linker/ng_container_integration_spec.ts b/modules/@angular/core/test/linker/ng_container_integration_spec.ts index c5d1caebc0..657da786ce 100644 --- a/modules/@angular/core/test/linker/ng_container_integration_spec.ts +++ b/modules/@angular/core/test/linker/ng_container_integration_spec.ts @@ -6,14 +6,11 @@ * 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} 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, TestComponentBuilder} from '@angular/core/testing'; 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 {CompilerConfig} from '@angular/compiler'; -import {el} from '@angular/platform-browser/testing/browser_util'; export function main() { describe('jit', () => { declareTests({useJit: true}); }); diff --git a/modules/@angular/core/test/linker/precompile_integration_spec.ts b/modules/@angular/core/test/linker/precompile_integration_spec.ts index 3338e30856..e93692acbc 100644 --- a/modules/@angular/core/test/linker/precompile_integration_spec.ts +++ b/modules/@angular/core/test/linker/precompile_integration_spec.ts @@ -6,12 +6,9 @@ * 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 {AsyncTestCompleter} from '@angular/core/testing/testing_internal'; -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'; +import {Component, ComponentFactoryResolver, NoComponentFactoryError, forwardRef, ANALYZE_FOR_PRECOMPILE} from '@angular/core'; export function main() { describe('jit', () => { declareTests({useJit: true}); }); diff --git a/modules/@angular/core/test/linker/projection_integration_spec.ts b/modules/@angular/core/test/linker/projection_integration_spec.ts index 18bda7daa0..bb2dc4ff57 100644 --- a/modules/@angular/core/test/linker/projection_integration_spec.ts +++ b/modules/@angular/core/test/linker/projection_integration_spec.ts @@ -6,13 +6,12 @@ * 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} 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 {ComponentFixture, TestComponentBuilder} from '@angular/core/testing'; 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 {getAllDebugNodes} from '@angular/core/src/debug/debug_node'; diff --git a/modules/@angular/core/test/linker/query_integration_spec.ts b/modules/@angular/core/test/linker/query_integration_spec.ts index bfc2f89e10..195e01e5c6 100644 --- a/modules/@angular/core/test/linker/query_integration_spec.ts +++ b/modules/@angular/core/test/linker/query_integration_spec.ts @@ -6,16 +6,14 @@ * 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 {AsyncTestCompleter} from '@angular/core/testing/testing_internal'; import {isPresent, stringify} from '../../src/facade/lang'; 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 {asNativeElements, ViewContainerRef} from '@angular/core'; export function main() { describe('Query API', () => { @@ -303,9 +301,9 @@ export function main() { expect(needsTpl.vc.createEmbeddedView(needsTpl.contentTpl).rootNodes[0]) .toHaveText('light'); 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: ''}) class NeedsContentChild implements AfterContentInit, AfterContentChecked { + /** @internal */ _child: TextDirective; @ContentChild(TextDirective) @@ -862,6 +861,7 @@ class NeedsViewChild implements AfterViewInit, AfterViewChecked { shouldShow: boolean = true; shouldShow2: boolean = false; + /** @internal */ _child: TextDirective; @ViewChild(TextDirective) diff --git a/modules/@angular/core/test/linker/reflector_component_resolver_spec.ts b/modules/@angular/core/test/linker/reflector_component_resolver_spec.ts index 226442f5a9..f256f975cd 100644 --- a/modules/@angular/core/test/linker/reflector_component_resolver_spec.ts +++ b/modules/@angular/core/test/linker/reflector_component_resolver_spec.ts @@ -6,12 +6,10 @@ * 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 {ComponentResolver, ReflectorComponentResolver} from '@angular/core/src/linker/component_resolver'; 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} 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 {Console} from '../../src/console'; class DummyConsole implements Console { @@ -42,8 +40,8 @@ export function main() { it('should throw when given a string', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { compiler.resolveComponent('someString').catch((e) => { - expect(e.message).toContain('Cannot resolve component using \'someString\'.') - async.done(); + expect(e.message).toContain('Cannot resolve component using \'someString\'.'); + async.done(); }); })); }); diff --git a/modules/@angular/core/test/linker/regression_integration_spec.ts b/modules/@angular/core/test/linker/regression_integration_spec.ts index 0776fb7c4f..0a127ce36a 100644 --- a/modules/@angular/core/test/linker/regression_integration_spec.ts +++ b/modules/@angular/core/test/linker/regression_integration_spec.ts @@ -6,24 +6,16 @@ * 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 {AsyncTestCompleter} from '@angular/core/testing/testing_internal'; -import {IS_DART} from '../../src/facade/lang'; - -import {Component, Pipe, PipeTransform, provide, ViewMetadata, PLATFORM_PIPES, OpaqueToken, Injector, forwardRef} from '@angular/core'; +import {Component, Pipe, PipeTransform, ViewMetadata, OpaqueToken, Injector, forwardRef} from '@angular/core'; import {NgIf, NgClass} from '@angular/common'; -import {CompilerConfig} from '@angular/compiler'; export function main() { - if (IS_DART) { - declareTests({useJit: false}); - } else { - describe('jit', () => { declareTests({useJit: true}); }); + describe('jit', () => { declareTests({useJit: true}); }); - describe('no jit', () => { declareTests({useJit: false}); }); - } + describe('no jit', () => { declareTests({useJit: false}); }); } 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', - inject( - [TestComponentBuilder, AsyncTestCompleter], - (tcb: TestComponentBuilder, async: AsyncTestCompleter) => { - tcb.overrideView(MyComp1, new ViewMetadata({template: `{{!null?.length}}`})) - .createAsync(MyComp1) - .then((fixture) => { - fixture.detectChanges(); - expect(fixture.nativeElement).toHaveText('true'); - async.done(); - }); - })); - } + it('should evaluate conditional and unary operators with right precedence - #8235', + inject( + [TestComponentBuilder, AsyncTestCompleter], + (tcb: TestComponentBuilder, async: AsyncTestCompleter) => { + tcb.overrideView(MyComp1, new ViewMetadata({template: `{{!null?.length}}`})) + .createAsync(MyComp1) + .then((fixture) => { + fixture.detectChanges(); + expect(fixture.nativeElement).toHaveText('true'); + async.done(); + }); + })); }); describe('providers', () => { diff --git a/modules/@angular/core/test/linker/security_integration_spec.ts b/modules/@angular/core/test/linker/security_integration_spec.ts index d4e8eab3ea..e89edc4147 100644 --- a/modules/@angular/core/test/linker/security_integration_spec.ts +++ b/modules/@angular/core/test/linker/security_integration_spec.ts @@ -6,26 +6,17 @@ * 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} from '@angular/core/testing/testing_internal'; +import {AsyncTestCompleter, ddescribe, describe, expect, inject, beforeEachProviders, beforeEach, afterEach, it,} from '@angular/core/testing/testing_internal'; import {configureCompiler, TestComponentBuilder} from '@angular/core/testing'; import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter'; -import {provide, Injectable, OpaqueToken} from '@angular/core'; -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 {Component} from '@angular/core/src/metadata'; import {DomSanitizationService} from '@angular/platform-browser/src/security/dom_sanitization_service'; export function main() { - if (IS_DART) { - declareTests({useJit: false}); - } else { - describe('jit', () => { declareTests({useJit: true}); }); + describe('jit', () => { declareTests({useJit: true}); }); - describe('no jit', () => { declareTests({useJit: false}); }); - } + describe('no jit', () => { declareTests({useJit: false}); }); } @Component({selector: 'my-comp', template: '', directives: []}) diff --git a/modules/@angular/core/test/reflection/reflector_spec.ts b/modules/@angular/core/test/reflection/reflector_spec.ts index 9f7fcdeea6..5fe65baefe 100644 --- a/modules/@angular/core/test/reflection/reflector_spec.ts +++ b/modules/@angular/core/test/reflection/reflector_spec.ts @@ -12,7 +12,7 @@ import {Reflector, ReflectionInfo} from '@angular/core/src/reflection/reflection import {ReflectionCapabilities} from '@angular/core/src/reflection/reflection_capabilities'; import {ClassDecorator, ParamDecorator, PropDecorator, classDecorator, paramDecorator, propDecorator, HasGetterAndSetterDecorators} from './reflector_common'; 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 { value: any /** TODO #9100 */; @@ -20,17 +20,17 @@ class AType { constructor(value: any /** TODO #9100 */) { this.value = value; } } -@ClassDecorator('class') class ClassWithDecorators { +@ClassDecorator('class') +class ClassWithDecorators { @PropDecorator('p1') @PropDecorator('p2') a: any /** TODO #9100 */; b: any /** TODO #9100 */; @PropDecorator('p3') - set c(value: any /** TODO #9100 */) { - } + set c(value: any /** TODO #9100 */) {} constructor(@ParamDecorator('a') a: AType, @ParamDecorator('b') b: AType) { - this.a = a; - this.b = b; + this.a = a; + this.b = b; } } @@ -43,12 +43,11 @@ class TestObj { b: any /** TODO #9100 */; constructor(a: any /** TODO #9100 */, b: any /** TODO #9100 */) { - this.a = a; - this.b = b; + this.a = a; + this.b = b; } - identity(arg: any /** TODO #9100 */) { - return arg; } + identity(arg: any /** TODO #9100 */) { return arg; } } class Interface {} @@ -74,50 +73,50 @@ class SubClassDoesNotDeclareOnInit extends SuperClassImplementingOnInit {} export function main() { 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', () => { - beforeEach(() => { reflector = new Reflector(null); }); + describe('usage tracking', () => { + beforeEach(() => { reflector = new Reflector(null); }); - it('should be disabled by default', () => { - expect(() => reflector.listUnusedKeys()).toThrowError('Usage tracking is disabled'); + it('should be disabled by default', () => { + 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', () => { - reflector.trackUsage(); - expect(reflector.listUnusedKeys()).toEqual([]); + describe('factory', () => { + it('should create a factory for the given type', () => { + var obj = reflector.factory(TestObj)(1, 2); - reflector.registerType(AType, new ReflectionInfo(null, null, () => 'AType')); - reflector.registerType(TestObj, new ReflectionInfo(null, null, () => 'TestObj')); - expect(reflector.listUnusedKeys()).toEqual([AType, TestObj]); + expect(obj.a).toEqual(1); + expect(obj.b).toEqual(2); + }); - reflector.factory(AType); - expect(reflector.listUnusedKeys()).toEqual([TestObj]); + // 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); - reflector.factory(TestObj); - 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 + // clang-format off checkArgs(f(TestObjWith00Args)(), []); checkArgs(f(TestObjWith01Args)(1), [1]); 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(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]); - // 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', () => { - var p = reflector.parameters(ClassWithoutDecorators); - expect(p.length).toEqual(2); + 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', () => { + 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', () => { - reflector.registerType(TestObj, new ReflectionInfo(null, [[1], [2]])); - expect(reflector.parameters(TestObj)).toEqual([[1], [2]]); + describe('propMetadata', () => { + it('should return a string map of prop metadata for the given class', () => { + 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', () => { - reflector.registerType(TestObj, new ReflectionInfo()); - expect(reflector.parameters(TestObj)).toEqual([]); - }); - }); + describe('annotations', () => { + it('should return an array of annotations for a type', () => { + var p = reflector.annotations(ClassWithDecorators); + expect(p).toEqual([classDecorator('class')]); + }); - describe('propMetadata', () => { - it('should return a string map of prop metadata for the given class', () => { - var p = reflector.propMetadata(ClassWithDecorators); - expect(p['a']).toEqual([propDecorator('p1'), propDecorator('p2')]); - expect(p['c']).toEqual([propDecorator('p3')]); - }); + it('should return registered annotations if available', () => { + reflector.registerType(TestObj, new ReflectionInfo([1, 2])); + expect(reflector.annotations(TestObj)).toEqual([1, 2]); + }); - 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]}); + it('should work for a class without annotations', () => { + var p = reflector.annotations(ClassWithoutDecorators); + expect(p).toEqual([]); + }); }); if (IS_DART) { - it('should merge metadata from getters and setters', () => { - var p = reflector.propMetadata(HasGetterAndSetterDecorators); - expect(p['a']).toEqual([propDecorator('get'), propDecorator('set')]); + 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', () => { + 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', () => { - it('should return an array of annotations for a type', () => { - var p = reflector.annotations(ClassWithDecorators); - expect(p).toEqual([classDecorator('class')]); - }); - - 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]); + 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 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('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); + 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); + }); + }); + } }); } class TestObjWith00Args { args: any[]; - constructor() { - this.args = []; } + constructor() { this.args = []; } } class TestObjWith01Args { args: any[]; - constructor(a1: any) { - this.args = [a1]; } + constructor(a1: any) { this.args = [a1]; } } class TestObjWith02Args { args: any[]; - constructor(a1: any, a2: any) { - this.args = [a1, a2]; } + constructor(a1: any, a2: any) { this.args = [a1, a2]; } } class TestObjWith03Args { args: any[]; - constructor(a1: any, a2: any, a3: any) { - this.args = [a1, a2, a3]; } + constructor(a1: any, a2: any, a3: any) { this.args = [a1, a2, a3]; } } class TestObjWith04Args { args: any[]; - constructor(a1: any, a2: any, a3: any, a4: any) { - this.args = [a1, a2, a3, a4]; } + constructor(a1: any, a2: any, a3: any, a4: any) { this.args = [a1, a2, a3, a4]; } } class TestObjWith05Args { args: any[]; - constructor(a1: any, a2: any, a3: any, a4: any, a5: any) { - this.args = [a1, a2, a3, a4, a5]; } + constructor(a1: any, a2: any, a3: any, a4: any, a5: any) { this.args = [a1, a2, a3, a4, a5]; } } class TestObjWith06Args { args: 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 { args: 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 { args: 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 { args: 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 { args: any[]; - constructor(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]; + constructor( + 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]; } } class TestObjWith11Args { args: any[]; - constructor(a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, - a10: any, a11: any) { - this.args = [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11]; + constructor( + a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, a10: any, + a11: any) { + this.args = [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11]; } } class TestObjWith12Args { args: any[]; - constructor(a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, - a10: any, a11: any, a12: any) { - this.args = [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12]; + constructor( + a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, a10: any, + a11: any, a12: any) { + this.args = [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12]; } } class TestObjWith13Args { args: any[]; - constructor(a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, - a10: any, a11: any, a12: any, a13: any) { - this.args = [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13]; + constructor( + a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, a10: any, + a11: any, a12: any, a13: any) { + this.args = [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13]; } } class TestObjWith14Args { args: any[]; - constructor(a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, - a10: any, a11: any, a12: any, a13: any, a14: any) { - this.args = [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14]; + constructor( + a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, a10: any, + 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 { args: any[]; - constructor(a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, - a10: any, 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]; + constructor( + a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, a10: any, + 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 { args: any[]; - constructor(a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, - a10: any, 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]; + constructor( + a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, a10: any, + 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 { args: any[]; - constructor(a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, - a10: any, 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]; + constructor( + a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, a10: any, + 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 { args: any[]; - constructor(a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, - a10: 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]; + constructor( + a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, a10: 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]; } } class TestObjWith19Args { args: any[]; - constructor(a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, - a10: any, a11: any, a12: any, a13: any, a14: any, a15: any, a16: any, a17: any, - a18: any, a19: any) { - this.args = - [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19]; + constructor( + a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, a10: any, + a11: any, a12: any, a13: any, a14: any, a15: any, a16: any, a17: any, a18: any, a19: any) { + this.args = + [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19]; } } class TestObjWith20Args { args: any[]; - constructor(a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, - a10: any, a11: any, a12: any, a13: any, a14: any, a15: any, a16: any, a17: any, - a18: any, a19: any, a20: any) { - this.args = - [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20]; + constructor( + a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, a10: any, + a11: any, a12: any, a13: any, a14: any, a15: any, a16: any, a17: any, a18: any, a19: any, + a20: any) { + this.args = + [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20]; } } class TestObjWith21Args { args: any[]; - constructor(a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, - a10: any, a11: any, a12: any, a13: any, a14: any, a15: any, a16: any, a17: any, - a18: any, a19: any, a20: any, a21: any) { - this.args = [ - a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21 - ]; + constructor( + a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, a10: any, + a11: any, a12: any, a13: any, a14: any, a15: any, a16: any, a17: any, a18: any, a19: any, + a20: any, a21: any) { + this.args = [ + a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, + a12, a13, a14, a15, a16, a17, a18, a19, a20, a21 + ]; } } diff --git a/modules/@angular/core/test/testability/testability_spec.ts b/modules/@angular/core/test/testability/testability_spec.ts index ac1fc09794..d304050d2f 100644 --- a/modules/@angular/core/test/testability/testability_spec.ts +++ b/modules/@angular/core/test/testability/testability_spec.ts @@ -7,8 +7,7 @@ */ 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} 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 {Testability} from '@angular/core/src/testability/testability'; import {NgZone} from '@angular/core/src/zone/ng_zone'; 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()) function microTask(fn: Function): void { 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. scheduleMicroTask(fn); }); @@ -25,9 +24,11 @@ function microTask(fn: Function): void { @Injectable() class MockNgZone extends NgZone { + /** @internal */ _onUnstableStream: EventEmitter; get onUnstable() { return this._onUnstableStream; } + /** @internal */ _onStableStream: EventEmitter; get onStable() { return this._onStableStream; } diff --git a/modules/@angular/core/test/testing_internal_spec.ts b/modules/@angular/core/test/testing_internal_spec.ts index fc3b848797..70ccbe86ca 100644 --- a/modules/@angular/core/test/testing_internal_spec.ts +++ b/modules/@angular/core/test/testing_internal_spec.ts @@ -74,8 +74,7 @@ export function main() { () => { expect(spyObj.spy('someFunc')).not.toHaveBeenCalled(); }); it('should record function calls', () => { - spyObj.spy('someFunc') - .andCallFake((a: any /** TODO #9100 */, b: any /** TODO #9100 */) => {return a + b}); + spyObj.spy('someFunc').andCallFake((a: any, b: any) => a + b); expect(spyObj.someFunc(1, 2)).toEqual(3); expect(spyObj.spy('someFunc')).toHaveBeenCalledWith(1, 2); diff --git a/modules/@angular/core/test/util/decorators_spec.ts b/modules/@angular/core/test/util/decorators_spec.ts index 8a2db7b2cb..93b0d22c3a 100644 --- a/modules/@angular/core/test/util/decorators_spec.ts +++ b/modules/@angular/core/test/util/decorators_spec.ts @@ -89,7 +89,7 @@ export function main() { expect(proto.extends).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', () => { @@ -108,13 +108,15 @@ export function main() { it('should ensure that last position is function', () => { - expect(() => {Class({constructor: []})}) + expect(() => { Class({constructor: []}); }) .toThrowError( 'Last position of Class method array must be Function in key constructor was \'undefined\''); }); it('should ensure that annotation count matches parameters count', () => { - expect(() => {Class({constructor: [String, function MyType() {}]})}) + expect(() => { + Class({constructor: [String, function MyType() {}]}); + }) .toThrowError( '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', () => { - expect(() => {(Class)({extends: 'non_type', constructor: function() {}})}) + expect(() => { (Class)({extends: 'non_type', constructor: function() {}}); }) .toThrowError( 'Class definition \'extends\' property must be a constructor function was: non_type'); }); diff --git a/modules/@angular/core/test/zone/ng_zone_spec.ts b/modules/@angular/core/test/zone/ng_zone_spec.ts index d25d3f42c3..82629bb27c 100644 --- a/modules/@angular/core/test/zone/ng_zone_spec.ts +++ b/modules/@angular/core/test/zone/ng_zone_spec.ts @@ -6,15 +6,14 @@ * 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 {browserDetection} from '@angular/platform-browser/testing/browser_util'; import {ObservableWrapper, PromiseCompleter, PromiseWrapper, TimerWrapper} from '../../src/facade/async'; 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 resultTimer = 1000; @@ -443,7 +442,7 @@ function commonTests() { macroTask(() => { expect(_log.result()).toEqual('run'); - async.done() + async.done(); }); }), testTimeout); diff --git a/modules/@angular/facade/test/async_spec.ts b/modules/@angular/facade/test/async_spec.ts index 8748715aff..b054dd762c 100644 --- a/modules/@angular/facade/test/async_spec.ts +++ b/modules/@angular/facade/test/async_spec.ts @@ -6,8 +6,7 @@ * 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} from '@angular/core/testing/testing_internal'; +import {AsyncTestCompleter, describe, it, expect, beforeEach, ddescribe, iit, xit, inject,} from '@angular/core/testing/testing_internal'; import {browserDetection} from '@angular/platform-browser/testing/browser_util'; import {ObservableWrapper, Observable, Subject, EventEmitter, PromiseWrapper} from '../src/async'; diff --git a/modules/@angular/forms/test/integration_spec.ts b/modules/@angular/forms/test/integration_spec.ts index 26b2800851..1bdeece80f 100644 --- a/modules/@angular/forms/test/integration_spec.ts +++ b/modules/@angular/forms/test/integration_spec.ts @@ -7,17 +7,15 @@ */ import {NgFor, NgIf} from '@angular/common'; -import {Component, Directive, EventEmitter, Output} from '@angular/core'; -import {Input, Provider, forwardRef} from '@angular/core'; +import {Component, Directive, EventEmitter, Input, Output, forwardRef} from '@angular/core'; 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} from '@angular/core/testing/testing_internal'; -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 {AsyncTestCompleter, afterEach, beforeEach, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} 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 {By} from '@angular/platform-browser/src/dom/debug/by'; import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter'; 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 {PromiseWrapper} from '../src/facade/promise'; diff --git a/modules/@angular/forms/test/model_spec.ts b/modules/@angular/forms/test/model_spec.ts index 0518f34de7..50c1894014 100644 --- a/modules/@angular/forms/test/model_spec.ts +++ b/modules/@angular/forms/test/model_spec.ts @@ -7,12 +7,11 @@ */ 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} from '@angular/core/testing/testing_internal'; +import {AsyncTestCompleter, afterEach, beforeEach, ddescribe, describe, iit, inject, it, xit} from '@angular/core/testing/testing_internal'; import {FormArray, FormControl, FormGroup, Validators} from '@angular/forms'; 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'; export function main() { @@ -492,17 +491,15 @@ export function main() { })); // TODO: remove the if statement after making observable delivery sync - if (!IS_DART) { - it('should update set errors and status before emitting an event', - inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { - c.valueChanges.subscribe((value: any /** TODO #9100 */) => { - expect(c.valid).toEqual(false); - expect(c.errors).toEqual({'required': true}); - async.done(); - }); - c.updateValue(''); - })); - } + it('should update set errors and status before emitting an event', + inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { + c.valueChanges.subscribe((value: any /** TODO #9100 */) => { + expect(c.valid).toEqual(false); + expect(c.errors).toEqual({'required': true}); + async.done(); + }); + c.updateValue(''); + })); it('should return a cold observable', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { @@ -946,7 +943,7 @@ export function main() { // rename contains into has 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', () => { expect(group.contains('something else')).toEqual(false); }); @@ -1066,11 +1063,8 @@ export function main() { c2.updateValue('new2'); })); - xit('should not fire an event when an excluded control is updated', - inject( - [AsyncTestCompleter], (async: AsyncTestCompleter) => { - // hard to test without hacking zones - })); + // hard to test without hacking zones + // xit('should not fire an event when an excluded control is updated', () => null); }); describe('statusChanges', () => { @@ -1143,7 +1137,7 @@ export function main() { expect(g.errors).toEqual({'async': true}); expect(g.find(['one']).errors).toEqual({'async': true}); })); - }) + }); }); describe('FormArray', () => { @@ -1644,7 +1638,7 @@ export function main() { expect(g.errors).toEqual({'async': true}); expect(g.pending).toEqual(false); })); - }) + }); }); }); } diff --git a/modules/@angular/forms/test/validators_spec.ts b/modules/@angular/forms/test/validators_spec.ts index 1248de61dc..e6c9953bf1 100644 --- a/modules/@angular/forms/test/validators_spec.ts +++ b/modules/@angular/forms/test/validators_spec.ts @@ -6,7 +6,7 @@ * 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 {AbstractControl, FormControl, Validators} from '@angular/forms'; import {Observable} from 'rxjs/Observable'; @@ -19,9 +19,9 @@ export function main() { function validator(key: string, error: any) { return function(c: AbstractControl) { var r = {}; - (r as any /** TODO #9100 */)[key] = error; + (r as any)[key] = error; return r; - } + }; } class AsyncValidatorDirective { diff --git a/modules/@angular/http/test/backends/jsonp_backend_spec.ts b/modules/@angular/http/test/backends/jsonp_backend_spec.ts index bba0a0190e..8c923ac88b 100644 --- a/modules/@angular/http/test/backends/jsonp_backend_spec.ts +++ b/modules/@angular/http/test/backends/jsonp_backend_spec.ts @@ -6,13 +6,11 @@ * 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} from '@angular/core/testing/testing_internal'; -import {ObservableWrapper} from '../../src/facade/async'; +import {AsyncTestCompleter, SpyObject, afterEach, beforeEach, ddescribe, describe, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal'; import {BrowserJsonp} from '../../src/backends/browser_jsonp'; import {JSONPConnection, JSONPConnection_, JSONPBackend, JSONPBackend_} from '../../src/backends/jsonp_backend'; -import {provide, Injector, ReflectiveInjector} from '@angular/core'; -import {isPresent, StringWrapper} from '../../src/facade/lang'; +import {ReflectiveInjector} from '@angular/core'; +import {isPresent,} from '../../src/facade/lang'; import {TimerWrapper} from '../../src/facade/async'; import {Request} from '../../src/static_request'; 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 {ResponseType, ReadyState, RequestMethod} from '../../src/enums'; -var addEventListenerSpy: any; var existingScripts: MockBrowserJsonp[] = []; var unused: Response; diff --git a/modules/@angular/http/test/backends/mock_backend_spec.ts b/modules/@angular/http/test/backends/mock_backend_spec.ts index 43e782df33..52ad10ad20 100644 --- a/modules/@angular/http/test/backends/mock_backend_spec.ts +++ b/modules/@angular/http/test/backends/mock_backend_spec.ts @@ -6,19 +6,13 @@ * 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} from '@angular/core/testing/testing_internal'; -import {ObservableWrapper} from '../../src/facade/async'; -import {BrowserXhr} from '../../src/backends/browser_xhr'; +import {AsyncTestCompleter, afterEach, beforeEach, ddescribe, describe, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal'; 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 {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 {BaseResponseOptions, ResponseOptions} from '../../src/base_response_options'; -import {ResponseType} from '../../src/enums'; import {ReplaySubject} from 'rxjs/ReplaySubject'; export function main() { @@ -41,10 +35,11 @@ export function main() { 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', - () => {expect(backend.createConnection(sampleRequest1)).toBeAnInstanceOf(MockConnection)}); + it('should create a new MockConnection', () => { + expect(backend.createConnection(sampleRequest1)).toBeAnInstanceOf(MockConnection); + }); it('should create a new connection and allow subscription', () => { let connection: MockConnection = backend.createConnection(sampleRequest1); diff --git a/modules/@angular/http/test/backends/xhr_backend_spec.ts b/modules/@angular/http/test/backends/xhr_backend_spec.ts index 4b89538ede..0c35f29d4b 100644 --- a/modules/@angular/http/test/backends/xhr_backend_spec.ts +++ b/modules/@angular/http/test/backends/xhr_backend_spec.ts @@ -6,13 +6,12 @@ * 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} 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 {BrowserXhr} from '../../src/backends/browser_xhr'; import {Json} from '../../src/facade/lang'; import {XSRFStrategy} from '../../src/interfaces'; 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 {Request} from '../../src/static_request'; import {Response} from '../../src/static_response'; @@ -146,7 +145,7 @@ export function main() { backend.createConnection(sampleRequest); 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 Content-Type: application/json; charset=utf-8 Transfer-Encoding: chunked - Connection: keep-alive` + Connection: keep-alive`; connection.response.subscribe((res: Response) => { 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( sampleRequest, new MockBrowserXHR(), new ResponseOptions({status: statusCode})); var responseHeaders = `X-Request-URL: http://somedomain.com - Foo: Bar` + Foo: Bar`; connection.response.subscribe((res: Response) => { expect(res.url).toEqual('http://somedomain.com'); @@ -643,7 +642,7 @@ export function main() { var connection = new XHRConnection(sampleRequest, mockXhr, new ResponseOptions({status: statusCode})); var responseHeaders = `X-Request-URL: http://somedomain.com - Foo: Bar` + Foo: Bar`; connection.response.subscribe((res: Response) => { expect(res.url).toEqual('http://somedomain.com'); diff --git a/modules/@angular/http/test/http_spec.ts b/modules/@angular/http/test/http_spec.ts index 5e9bbe792c..f2f781fb2c 100644 --- a/modules/@angular/http/test/http_spec.ts +++ b/modules/@angular/http/test/http_spec.ts @@ -6,11 +6,9 @@ * found in the LICENSE file at https://angular.io/license */ -import {Injector, ReflectiveInjector, provide} from '@angular/core'; -import {afterEach, beforeEach, ddescribe, describe, expect, iit, inject, it, xit} from '@angular/core/testing/testing_internal'; -import {AsyncTestCompleter} from '@angular/core/testing/testing_internal'; +import {Injector, ReflectiveInjector} from '@angular/core'; +import {AsyncTestCompleter, afterEach, beforeEach, ddescribe, describe, expect, iit, inject, it, xit} from '@angular/core/testing/testing_internal'; import {Observable} from 'rxjs/Observable'; -import {Subject} from 'rxjs/Subject'; 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'; @@ -354,7 +352,7 @@ export function main() { it('should allow case insensitive strings for method names', () => { inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { 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'}))); async.done(); }); @@ -478,7 +476,7 @@ export function main() { return stringToArrayBuffer(Json.stringify(message)); } }; - c.mockRespond(new Response(new ResponseOptions({body: body()}))) + c.mockRespond(new Response(new ResponseOptions({body: body()}))); }); zip(http.get( diff --git a/modules/@angular/platform-browser-dynamic/test/testing_public_browser_spec.ts b/modules/@angular/platform-browser-dynamic/test/testing_public_browser_spec.ts index 1172dba833..fc2313306e 100644 --- a/modules/@angular/platform-browser-dynamic/test/testing_public_browser_spec.ts +++ b/modules/@angular/platform-browser-dynamic/test/testing_public_browser_spec.ts @@ -21,7 +21,8 @@ class FancyService { value: string = 'real value'; getAsyncValue() { return Promise.resolve('async value'); } 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(); originalJasmineIt = jasmine.getEnv().it; jasmine.getEnv().it = (description: string, fn: any /** TODO #9100 */) => { - var done = () => { deferred.resolve() }; - (done).fail = (err: any /** TODO #9100 */) => { deferred.reject(err) }; + var done = () => { deferred.resolve(); }; + (done).fail = (err: any /** TODO #9100 */) => { deferred.reject(err); }; fn(done); return null; }; diff --git a/modules/@angular/platform-browser-dynamic/test/xhr/xhr_cache_spec.ts b/modules/@angular/platform-browser-dynamic/test/xhr/xhr_cache_spec.ts index 528da9851f..a46ea27610 100644 --- a/modules/@angular/platform-browser-dynamic/test/xhr/xhr_cache_spec.ts +++ b/modules/@angular/platform-browser-dynamic/test/xhr/xhr_cache_spec.ts @@ -7,10 +7,9 @@ */ 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 {beforeEach, beforeEachProviders, ddescribe, describe, iit, inject, it, xit} from '@angular/core/testing/testing_internal'; -import {AsyncTestCompleter} from '@angular/core/testing/testing_internal'; +import {AsyncTestCompleter, beforeEach, beforeEachProviders, ddescribe, describe, iit, inject, it, xit} from '@angular/core/testing/testing_internal'; import {expect} from '@angular/platform-browser/testing/matchers'; import {BaseException} from '../../src/facade/exceptions'; diff --git a/modules/@angular/platform-browser/test/dom/events/event_manager_spec.ts b/modules/@angular/platform-browser/test/dom/events/event_manager_spec.ts index 8a63f18ac2..85f27b70d4 100644 --- a/modules/@angular/platform-browser/test/dom/events/event_manager_spec.ts +++ b/modules/@angular/platform-browser/test/dom/events/event_manager_spec.ts @@ -91,6 +91,7 @@ export function main() { } class FakeEventManagerPlugin extends EventManagerPlugin { + /** @internal */ _eventHandler = new Map(); constructor(public _supports: string[]) { super(); } diff --git a/modules/@angular/platform-browser/test/dom/web_animations_driver_spec.ts b/modules/@angular/platform-browser/test/dom/web_animations_driver_spec.ts index dc933e05c2..1edfb81e10 100644 --- a/modules/@angular/platform-browser/test/dom/web_animations_driver_spec.ts +++ b/modules/@angular/platform-browser/test/dom/web_animations_driver_spec.ts @@ -6,7 +6,7 @@ * 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 {AnimationKeyframe, AnimationStyles} from '../../core_private'; @@ -21,6 +21,7 @@ class ExtendedWebAnimationsDriver extends WebAnimationsDriver { constructor() { super(); } + /** @internal */ _triggerWebAnimation(elm: any, keyframes: any[], options: any): DomAnimatePlayer { this.log.push({'elm': elm, 'keyframes': keyframes, 'options': options}); return new MockDomAnimatePlayer(); diff --git a/modules/@angular/platform-browser/test/dom/web_animations_player_spec.ts b/modules/@angular/platform-browser/test/dom/web_animations_player_spec.ts index 4d2a9cd458..c83656cda7 100644 --- a/modules/@angular/platform-browser/test/dom/web_animations_player_spec.ts +++ b/modules/@angular/platform-browser/test/dom/web_animations_player_spec.ts @@ -22,6 +22,7 @@ class ExtendedWebAnimationsPlayer extends WebAnimationsPlayer { super(element, keyframes, options); } + /** @internal */ _triggerWebAnimation(elm: any, keyframes: any[], options: any): DomAnimatePlayer { return this.domPlayer; } diff --git a/modules/@angular/platform-browser/test/testing_public_spec.ts b/modules/@angular/platform-browser/test/testing_public_spec.ts index 930b9de76b..57f210a8d4 100644 --- a/modules/@angular/platform-browser/test/testing_public_spec.ts +++ b/modules/@angular/platform-browser/test/testing_public_spec.ts @@ -70,7 +70,8 @@ class FancyService { value: string = 'real value'; getAsyncValue() { return Promise.resolve('async value'); } 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(); originalJasmineIt = jasmine.getEnv().it; jasmine.getEnv().it = (description: string, fn: any /** TODO #9100 */) => { - var done = () => { deferred.resolve() }; - (done).fail = (err: any /** TODO #9100 */) => { deferred.reject(err) }; + var done = () => { deferred.resolve(); }; + (done).fail = (err: any /** TODO #9100 */) => { deferred.reject(err); }; fn(done); return null; }; @@ -365,8 +366,8 @@ export function main() { var deferred = PromiseWrapper.completer(); originalJasmineBeforeEach = jasmine.getEnv().beforeEach; jasmine.getEnv().beforeEach = (fn: any) => { - var done = () => { deferred.resolve() }; - (done).fail = (err: any /** TODO #9100 */) => { deferred.reject(err) }; + var done = () => { deferred.resolve(); }; + (done).fail = (err: any /** TODO #9100 */) => { deferred.reject(err); }; fn(done); return null; }; diff --git a/modules/@angular/platform-browser/test/web_workers/shared/message_bus_spec.ts b/modules/@angular/platform-browser/test/web_workers/shared/message_bus_spec.ts index e3dfafecf1..9b83b5cae0 100644 --- a/modules/@angular/platform-browser/test/web_workers/shared/message_bus_spec.ts +++ b/modules/@angular/platform-browser/test/web_workers/shared/message_bus_spec.ts @@ -6,10 +6,9 @@ * 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 {MockNgZone, beforeEach, beforeEachProviders, describe, expect, inject, it} from '@angular/core/testing/testing_internal'; -import {AsyncTestCompleter} from '@angular/core/testing/testing_internal'; +import {AsyncTestCompleter, MockNgZone, beforeEach, beforeEachProviders, describe, expect, inject, it} from '@angular/core/testing/testing_internal'; import {MessageBus} from '@angular/platform-browser/src/web_workers/shared/message_bus'; import {ObservableWrapper, TimerWrapper} from '../../../src/facade/async'; diff --git a/modules/@angular/platform-browser/test/web_workers/shared/web_worker_test_util.ts b/modules/@angular/platform-browser/test/web_workers/shared/web_worker_test_util.ts index 08b3d6befc..bc07c9312a 100644 --- a/modules/@angular/platform-browser/test/web_workers/shared/web_worker_test_util.ts +++ b/modules/@angular/platform-browser/test/web_workers/shared/web_worker_test_util.ts @@ -7,13 +7,12 @@ */ 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_} 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 {MessageBus, MessageBusSink, MessageBusSource} from '@angular/platform-browser/src/web_workers/shared/message_bus'; import {PromiseWrapper} from '../../../src/facade/async'; 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 {SpyMessageBroker} from '../worker/spies'; @@ -52,11 +51,11 @@ export function expectBrokerCall( expect(args.method).toEqual(methodName); if (isPresent(vals)) { 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; if (isPresent(handler)) { - let givenValues = args.args.map((arg) => {arg.value}); + let givenValues = args.args.map((arg) => arg.value); if (givenValues.length > 0) { promise = handler(givenValues); } else { diff --git a/modules/@angular/platform-browser/test/web_workers/worker/platform_location_spec.ts b/modules/@angular/platform-browser/test/web_workers/worker/platform_location_spec.ts index 233d17a4eb..da7e907efc 100644 --- a/modules/@angular/platform-browser/test/web_workers/worker/platform_location_spec.ts +++ b/modules/@angular/platform-browser/test/web_workers/worker/platform_location_spec.ts @@ -6,8 +6,7 @@ * 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} from '@angular/core/testing/testing_internal'; +import {AsyncTestCompleter, beforeEach, beforeEachProviders, describe, expect, inject, it} from '@angular/core/testing/testing_internal'; 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 {LocationType} from '@angular/platform-browser/src/web_workers/shared/serialized_types'; diff --git a/modules/@angular/platform-browser/test/web_workers/worker/renderer_integration_spec.ts b/modules/@angular/platform-browser/test/web_workers/worker/renderer_integration_spec.ts index ea1e7ca9ff..0af9ba9530 100644 --- a/modules/@angular/platform-browser/test/web_workers/worker/renderer_integration_spec.ts +++ b/modules/@angular/platform-browser/test/web_workers/worker/renderer_integration_spec.ts @@ -6,11 +6,10 @@ * 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} from '@angular/core/testing/testing_internal'; +import {AsyncTestCompleter, inject, ddescribe, describe, it, iit, expect, beforeEach, beforeEachProviders,} from '@angular/core/testing/testing_internal'; import {TestBed, TestComponentBuilder, configureModule} from '@angular/core/testing'; 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 {WebWorkerRootRenderer} from '@angular/platform-browser/src/web_workers/worker/renderer'; 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 {createPairedMessageBuses, PairedMessageBuses} from '../shared/web_worker_test_util'; 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 {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() { function createWebWorkerBrokerFactory( @@ -58,205 +56,204 @@ export function main() { return new DebugDomRootRenderer(workerRootRenderer); } - describe( - 'Web Worker Renderer', - () => { - var uiInjector: Injector; - var uiRenderStore: RenderStore; - var workerRenderStore: RenderStore; + describe('Web Worker Renderer', () => { + var uiInjector: Injector; + var uiRenderStore: RenderStore; + var workerRenderStore: RenderStore; - beforeEach(() => { - uiRenderStore = new RenderStore(); - var testUiInjector = new TestBed(); - testUiInjector.platform = browserDynamicTestPlatform(); - testUiInjector.appModule = BrowserTestModule; - testUiInjector.configureModule({ - providers: [ - Serializer, {provide: RenderStore, useValue: uiRenderStore}, - {provide: DomRootRenderer, useClass: 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) { - return (componentRef.hostView).internalView.renderer; - } - - it('should update text nodes', - inject( - [TestComponentBuilder, AsyncTestCompleter], - (tcb: TestComponentBuilder, async: AsyncTestCompleter) => { - tcb.overrideView(MyComp2, new ViewMetadata({template: '
{{ctxProp}}
'})) - .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: ''})) - .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((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 = ''; - tcb.overrideView(MyComp2, new ViewMetadata({template: tpl, directives: [NgIf]})) - - .createAsync(MyComp2) - .then((fixture) => { - (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: '', - 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: ''})) - .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: ''})) - .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(); - }); - })); - } + beforeEach(() => { + uiRenderStore = new RenderStore(); + var testUiInjector = new TestBed(); + testUiInjector.platform = browserDynamicTestPlatform(); + testUiInjector.appModule = BrowserTestModule; + testUiInjector.configureModule({ + providers: [ + Serializer, {provide: RenderStore, useValue: uiRenderStore}, + {provide: DomRootRenderer, useClass: 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) { + return (componentRef.hostView).internalView.renderer; + } + + it('should update text nodes', + inject( + [TestComponentBuilder, AsyncTestCompleter], + (tcb: TestComponentBuilder, async: AsyncTestCompleter) => { + tcb.overrideView(MyComp2, new ViewMetadata({template: '
{{ctxProp}}
'})) + .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: ''})) + .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((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 = ''; + tcb.overrideView(MyComp2, new ViewMetadata({template: tpl, directives: [NgIf]})) + + .createAsync(MyComp2) + .then((fixture) => { + (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: '', + 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: ''})) + .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: ''})) + .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( - {selector: 'my-comp', - directives: []}) @Injectable() class MyComp2 { - ctxProp: string; ctxNumProp: any /** TODO #9100 */; ctxBoolProp: boolean; constructor() { +@Component({selector: 'my-comp', directives: []}) +@Injectable() +class MyComp2 { + ctxProp: string; + ctxNumProp: any /** TODO #9100 */; + ctxBoolProp: boolean; + constructor() { this.ctxProp = 'initial value'; this.ctxNumProp = 0; this.ctxBoolProp = false; } - throwError() { throw 'boom';} + throwError() { throw 'boom'; } } diff --git a/modules/@angular/router-deprecated/test/directives/router_link_spec.ts b/modules/@angular/router-deprecated/test/directives/router_link_spec.ts index b4c82a435c..2c2758469b 100644 --- a/modules/@angular/router-deprecated/test/directives/router_link_spec.ts +++ b/modules/@angular/router-deprecated/test/directives/router_link_spec.ts @@ -6,12 +6,11 @@ * 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 {AsyncTestCompleter} from '@angular/core/testing/testing_internal'; import {SpyRouter, SpyLocation} from '../spies'; -import {provide, Component} from '@angular/core'; +import {Component} from '@angular/core'; import {Location} from '@angular/common'; import {Router, RouteRegistry, RouterLink, RouterOutlet, Route, RouteParams, ComponentInstruction} from '@angular/router-deprecated'; import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter'; diff --git a/modules/@angular/router-deprecated/test/integration/bootstrap_spec.ts b/modules/@angular/router-deprecated/test/integration/bootstrap_spec.ts index b4a30308b4..79fcdb3957 100644 --- a/modules/@angular/router-deprecated/test/integration/bootstrap_spec.ts +++ b/modules/@angular/router-deprecated/test/integration/bootstrap_spec.ts @@ -13,8 +13,7 @@ import {ApplicationRef} from '@angular/core/src/application_ref'; import {Console} from '@angular/core/src/console'; import {Component} from '@angular/core/src/metadata'; 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} 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 {bootstrap} from '@angular/platform-browser-dynamic'; import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter'; import {DOCUMENT} from '@angular/platform-browser/src/dom/dom_tokens'; diff --git a/modules/@angular/router-deprecated/test/integration/impl/async_route_spec_impl.ts b/modules/@angular/router-deprecated/test/integration/impl/async_route_spec_impl.ts index 68e3ad1c5b..f8ea9b7bd3 100644 --- a/modules/@angular/router-deprecated/test/integration/impl/async_route_spec_impl.ts +++ b/modules/@angular/router-deprecated/test/integration/impl/async_route_spec_impl.ts @@ -6,9 +6,8 @@ * 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 {AsyncTestCompleter} from '@angular/core/testing/testing_internal'; import {Location} from '@angular/common'; @@ -40,7 +39,7 @@ function asyncRoutesWithoutChildrenWithRouteData() { it('should inject route data into the component', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { compile(tcb) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([new AsyncRoute( {path: '/route-data', loader: asyncRouteDataCmp, data: {isAdmin: true}})])) .then((_) => rtr.navigateByUrl('/route-data')) @@ -54,7 +53,7 @@ function asyncRoutesWithoutChildrenWithRouteData() { it('should inject empty object if the route has no data property', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { compile(tcb) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([new AsyncRoute( {path: '/route-data-default', loader: asyncRouteDataCmp})])) .then((_) => rtr.navigateByUrl('/route-data-default')) @@ -82,7 +81,7 @@ function asyncRoutesWithoutChildrenWithoutParams() { it('should navigate by URL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { compile(tcb) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([new AsyncRoute( {path: '/test', loader: helloCmpLoader, name: 'Hello'})])) .then((_) => rtr.navigateByUrl('/test')) @@ -95,7 +94,7 @@ function asyncRoutesWithoutChildrenWithoutParams() { it('should navigate by link DSL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { compile(tcb) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([new AsyncRoute( {path: '/test', loader: helloCmpLoader, name: 'Hello'})])) .then((_) => rtr.navigate(['/Hello'])) @@ -108,7 +107,7 @@ function asyncRoutesWithoutChildrenWithoutParams() { it('should generate a link URL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { compile(tcb, `go to hello | `) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([new AsyncRoute( {path: '/test', loader: helloCmpLoader, name: 'Hello'})])) .then((_) => { @@ -124,7 +123,7 @@ function asyncRoutesWithoutChildrenWithoutParams() { (async: AsyncTestCompleter, location: any /** TODO #9100 */) => { compile( tcb, `go to hello | `) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([new AsyncRoute( {path: '/test', loader: helloCmpLoader, name: 'Hello'})])) .then((_) => { @@ -160,7 +159,7 @@ function asyncRoutesWithoutChildrenWithParams() { it('should navigate by URL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { compile(tcb) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([new AsyncRoute( {path: '/user/:name', loader: userCmpLoader, name: 'User'})])) .then((_) => rtr.navigateByUrl('/user/igor')) @@ -173,7 +172,7 @@ function asyncRoutesWithoutChildrenWithParams() { it('should navigate by link DSL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { compile(tcb) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then( (_) => rtr.config([new Route({path: '/user/:name', component: UserCmp, name: 'User'})])) @@ -189,7 +188,7 @@ function asyncRoutesWithoutChildrenWithParams() { compile( tcb, `greet naomi | `) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([new AsyncRoute( {path: '/user/:name', loader: userCmpLoader, name: 'User'})])) .then((_) => { @@ -206,7 +205,7 @@ function asyncRoutesWithoutChildrenWithParams() { compile( tcb, `greet naomi | `) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([new AsyncRoute( {path: '/user/:name', loader: userCmpLoader, name: 'User'})])) .then((_) => { @@ -228,7 +227,7 @@ function asyncRoutesWithoutChildrenWithParams() { it('should navigate between components with different parameters', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { compile(tcb) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([new AsyncRoute( {path: '/user/:name', loader: userCmpLoader, name: 'User'})])) .then((_) => rtr.navigateByUrl('/user/brian')) @@ -262,7 +261,7 @@ function asyncRoutesWithSyncChildrenWithoutDefaultRoutes() { it('should navigate by URL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { compile(tcb, `outer [ ]`) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([new AsyncRoute( {path: '/a/...', loader: parentCmpLoader, name: 'Parent'})])) .then((_) => rtr.navigateByUrl('/a/b')) @@ -275,7 +274,7 @@ function asyncRoutesWithSyncChildrenWithoutDefaultRoutes() { it('should navigate by link DSL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { compile(tcb, `outer [ ]`) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([new AsyncRoute( {path: '/a/...', loader: parentCmpLoader, name: 'Parent'})])) .then((_) => rtr.navigate(['/Parent', 'Child'])) @@ -290,7 +289,7 @@ function asyncRoutesWithSyncChildrenWithoutDefaultRoutes() { compile( tcb, `nav to child | outer [ ]`) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([new AsyncRoute( {path: '/a/...', loader: parentCmpLoader, name: 'Parent'})])) .then((_) => { @@ -307,7 +306,7 @@ function asyncRoutesWithSyncChildrenWithoutDefaultRoutes() { compile( tcb, `nav to child | outer [ ]`) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([new AsyncRoute( {path: '/a/...', loader: parentCmpLoader, name: 'Parent'})])) .then((_) => { @@ -344,7 +343,7 @@ function asyncRoutesWithSyncChildrenWithDefaultRoutes() { it('should navigate by URL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { compile(tcb, `outer [ ]`) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([new AsyncRoute( {path: '/a/...', loader: parentWithDefaultCmpLoader, name: 'Parent'})])) .then((_) => rtr.navigateByUrl('/a')) @@ -357,7 +356,7 @@ function asyncRoutesWithSyncChildrenWithDefaultRoutes() { it('should navigate by link DSL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { compile(tcb, `outer [ ]`) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([new AsyncRoute( {path: '/a/...', loader: parentWithDefaultCmpLoader, name: 'Parent'})])) .then((_) => rtr.navigate(['/Parent'])) @@ -372,7 +371,7 @@ function asyncRoutesWithSyncChildrenWithDefaultRoutes() { compile( tcb, `link to inner | outer [ ]`) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([new AsyncRoute( {path: '/a/...', loader: parentWithDefaultCmpLoader, name: 'Parent'})])) .then((_) => { @@ -389,7 +388,7 @@ function asyncRoutesWithSyncChildrenWithDefaultRoutes() { compile( tcb, `link to inner | outer [ ]`) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([new AsyncRoute( {path: '/a/...', loader: parentWithDefaultCmpLoader, name: 'Parent'})])) .then((_) => { @@ -427,7 +426,7 @@ function asyncRoutesWithAsyncChildrenWithoutParamsWithoutDefaultRoutes() { it('should navigate by URL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { compile(tcb, `outer [ ]`) - .then((rtc) => {rootTC = rtc}) + .then((rtc) => { rootTC = rtc; }) .then((_) => rtr.config([new AsyncRoute( {path: '/a/...', loader: asyncParentCmpLoader, name: 'Parent'})])) .then((_) => rtr.navigateByUrl('/a/b')) @@ -440,7 +439,7 @@ function asyncRoutesWithAsyncChildrenWithoutParamsWithoutDefaultRoutes() { it('should navigate by link DSL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { compile(tcb, `outer [ ]`) - .then((rtc) => {rootTC = rtc}) + .then((rtc) => { rootTC = rtc; }) .then((_) => rtr.config([new AsyncRoute( {path: '/a/...', loader: asyncParentCmpLoader, name: 'Parent'})])) .then((_) => rtr.navigate(['/Parent', 'Child'])) @@ -455,7 +454,7 @@ function asyncRoutesWithAsyncChildrenWithoutParamsWithoutDefaultRoutes() { compile( tcb, `nav to child | outer [ ]`) - .then((rtc) => {rootTC = rtc}) + .then((rtc) => { rootTC = rtc; }) .then((_) => rtr.config([new AsyncRoute( {path: '/a/...', loader: asyncParentCmpLoader, name: 'Parent'})])) .then((_) => { @@ -472,7 +471,7 @@ function asyncRoutesWithAsyncChildrenWithoutParamsWithoutDefaultRoutes() { compile( tcb, `nav to child | outer [ ]`) - .then((rtc) => {rootTC = rtc}) + .then((rtc) => { rootTC = rtc; }) .then((_) => rtr.config([new AsyncRoute( {path: '/a/...', loader: asyncParentCmpLoader, name: 'Parent'})])) .then((_) => { @@ -509,7 +508,7 @@ function asyncRoutesWithAsyncChildrenWithoutParamsWithDefaultRoutes() { it('should navigate by URL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { compile(tcb, `outer [ ]`) - .then((rtc) => {rootTC = rtc}) + .then((rtc) => { rootTC = rtc; }) .then((_) => rtr.config([new AsyncRoute( {path: '/a/...', loader: asyncDefaultParentCmpLoader, name: 'Parent'})])) .then((_) => rtr.navigateByUrl('/a')) @@ -522,7 +521,7 @@ function asyncRoutesWithAsyncChildrenWithoutParamsWithDefaultRoutes() { it('should navigate by link DSL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { compile(tcb, `outer [ ]`) - .then((rtc) => {rootTC = rtc}) + .then((rtc) => { rootTC = rtc; }) .then((_) => rtr.config([new AsyncRoute( {path: '/a/...', loader: asyncDefaultParentCmpLoader, name: 'Parent'})])) .then((_) => rtr.navigate(['/Parent'])) @@ -537,7 +536,7 @@ function asyncRoutesWithAsyncChildrenWithoutParamsWithDefaultRoutes() { compile( tcb, `nav to child | outer [ ]`) - .then((rtc) => {rootTC = rtc}) + .then((rtc) => { rootTC = rtc; }) .then((_) => rtr.config([new AsyncRoute( {path: '/a/...', loader: asyncDefaultParentCmpLoader, name: 'Parent'})])) .then((_) => { @@ -554,7 +553,7 @@ function asyncRoutesWithAsyncChildrenWithoutParamsWithDefaultRoutes() { compile( tcb, `nav to child | outer [ ]`) - .then((rtc) => {rootTC = rtc}) + .then((rtc) => { rootTC = rtc; }) .then((_) => rtr.config([new AsyncRoute( {path: '/a/...', loader: asyncDefaultParentCmpLoader, name: 'Parent'})])) .then((_) => { @@ -591,7 +590,7 @@ function asyncRoutesWithAsyncChildrenWithParamsWithoutDefaultRoutes() { it('should navigate by URL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { compile(tcb, `[ ]`) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([new AsyncRoute( {path: '/team/:id/...', loader: asyncTeamLoader, name: 'Team'})])) .then((_) => rtr.navigateByUrl('/team/angular/user/matias')) @@ -605,7 +604,7 @@ function asyncRoutesWithAsyncChildrenWithParamsWithoutDefaultRoutes() { it('should navigate by link DSL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { compile(tcb, `[ ]`) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([new AsyncRoute( {path: '/team/:id/...', loader: asyncTeamLoader, name: 'Team'})])) .then((_) => rtr.navigate(['/Team', {id: 'angular'}, 'User', {name: 'matias'}])) @@ -621,7 +620,7 @@ function asyncRoutesWithAsyncChildrenWithParamsWithoutDefaultRoutes() { compile( tcb, `nav to matias [ ]`) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([new AsyncRoute( {path: '/team/:id/...', loader: asyncTeamLoader, name: 'Team'})])) .then((_) => { @@ -638,7 +637,7 @@ function asyncRoutesWithAsyncChildrenWithParamsWithoutDefaultRoutes() { compile( tcb, `nav to matias [ ]`) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([new AsyncRoute( {path: '/team/:id/...', loader: asyncTeamLoader, name: 'Team'})])) .then((_) => { diff --git a/modules/@angular/router-deprecated/test/integration/impl/aux_route_spec_impl.ts b/modules/@angular/router-deprecated/test/integration/impl/aux_route_spec_impl.ts index fde4a6be53..2f0031bbe8 100644 --- a/modules/@angular/router-deprecated/test/integration/impl/aux_route_spec_impl.ts +++ b/modules/@angular/router-deprecated/test/integration/impl/aux_route_spec_impl.ts @@ -9,8 +9,7 @@ import {Location} from '@angular/common'; import {Component} from '@angular/core'; 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} 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 {By} from '@angular/platform-browser/src/dom/debug/by'; import {AuxRoute, ROUTER_DIRECTIVES, Route, RouteConfig, Router} from '@angular/router-deprecated'; @@ -38,7 +37,7 @@ function auxRoutes() { compile( tcb, `main [] | aux []`) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([ new Route({path: '/hello', component: HelloCmp, name: 'Hello'}), new AuxRoute({path: '/modal', component: ModalCmp, name: 'Aux'}) @@ -56,7 +55,7 @@ function auxRoutes() { compile( tcb, `main [] | aux []`) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([ new Route({path: '/hello', component: HelloCmp, name: 'Hello'}), new AuxRoute({path: '/modal', component: ModalCmp, name: 'Modal'}) @@ -73,7 +72,7 @@ function auxRoutes() { compile( tcb, `open modal | main [] | aux []`) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([ new Route({path: '/hello', component: HelloCmp, name: 'Hello'}), new AuxRoute({path: '/modal', component: ModalCmp, name: 'Modal'}) @@ -92,7 +91,7 @@ function auxRoutes() { compile( tcb, `open modal | hello | main [] | aux []`) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([ new Route({path: '/hello', component: HelloCmp, name: 'Hello'}), new AuxRoute({path: '/modal', component: ModalCmp, name: 'Modal'}) @@ -151,7 +150,7 @@ function auxRoutesWithAPrimaryRoute() { compile( tcb, `main [] | aux []`) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([ new Route({path: '/hello', component: HelloCmp, name: 'Hello'}), new AuxRoute({path: '/modal', component: ModalCmp, name: 'Aux'}) @@ -169,7 +168,7 @@ function auxRoutesWithAPrimaryRoute() { compile( tcb, `main [] | aux []`) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([ new Route({path: '/hello', component: HelloCmp, name: 'Hello'}), new AuxRoute({path: '/modal', component: ModalCmp, name: 'Modal'}) @@ -186,7 +185,7 @@ function auxRoutesWithAPrimaryRoute() { compile( tcb, `open modal | main [] | aux []`) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([ new Route({path: '/hello', component: HelloCmp, name: 'Hello'}), new AuxRoute({path: '/modal', component: ModalCmp, name: 'Modal'}) @@ -205,7 +204,7 @@ function auxRoutesWithAPrimaryRoute() { compile( tcb, `open modal | main [] | aux []`) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([ new Route({path: '/hello', component: HelloCmp, name: 'Hello'}), new AuxRoute({path: '/modal', component: ModalCmp, name: 'Modal'}) diff --git a/modules/@angular/router-deprecated/test/integration/impl/sync_route_spec_impl.ts b/modules/@angular/router-deprecated/test/integration/impl/sync_route_spec_impl.ts index 03eba9ba2d..bc2283e974 100644 --- a/modules/@angular/router-deprecated/test/integration/impl/sync_route_spec_impl.ts +++ b/modules/@angular/router-deprecated/test/integration/impl/sync_route_spec_impl.ts @@ -6,8 +6,7 @@ * 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} 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 {specs, compile, TEST_ROUTER_PROVIDERS, clickOnElement, getHref} from '../util'; @@ -38,7 +37,7 @@ function syncRoutesWithoutChildrenWithoutParams() { it('should navigate by URL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { compile(tcb) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then( (_) => rtr.config([new Route({path: '/test', component: HelloCmp, name: 'Hello'})])) .then((_) => rtr.navigateByUrl('/test')) @@ -51,7 +50,7 @@ function syncRoutesWithoutChildrenWithoutParams() { it('should navigate by link DSL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { compile(tcb) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then( (_) => rtr.config([new Route({path: '/test', component: HelloCmp, name: 'Hello'})])) .then((_) => rtr.navigate(['/Hello'])) @@ -64,7 +63,7 @@ function syncRoutesWithoutChildrenWithoutParams() { it('should generate a link URL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { compile(tcb, `go to hello | `) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then( (_) => rtr.config([new Route({path: '/test', component: HelloCmp, name: 'Hello'})])) .then((_) => { @@ -80,7 +79,7 @@ function syncRoutesWithoutChildrenWithoutParams() { (async: AsyncTestCompleter, location: any /** TODO #9100 */) => { compile( tcb, `go to hello | `) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then( (_) => 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) => { compile(tcb) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then( (_) => 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) => { compile(tcb) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then( (_) => rtr.config([new Route({path: '/user/:name', component: UserCmp, name: 'User'})])) @@ -147,7 +146,7 @@ function syncRoutesWithoutChildrenWithParams() { compile( tcb, `greet naomi | `) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then( (_) => rtr.config([new Route({path: '/user/:name', component: UserCmp, name: 'User'})])) @@ -165,7 +164,7 @@ function syncRoutesWithoutChildrenWithParams() { compile( tcb, `greet naomi | `) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([new Route( {path: '/user/:name', component: UserCmp, name: 'User'})])) .then((_) => { @@ -187,7 +186,7 @@ function syncRoutesWithoutChildrenWithParams() { it('should navigate between components with different parameters', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { compile(tcb) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then( (_) => 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) => { compile(tcb, `outer [ ]`) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then( (_) => 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) => { compile(tcb, `outer [ ]`) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then( (_) => rtr.config([new Route({path: '/a/...', component: ParentCmp, name: 'Parent'})])) @@ -252,7 +251,7 @@ function syncRoutesWithSyncChildrenWithoutDefaultRoutesWithoutParams() { compile( tcb, `nav to child | outer [ ]`) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then( (_) => rtr.config([new Route({path: '/a/...', component: ParentCmp, name: 'Parent'})])) @@ -270,7 +269,7 @@ function syncRoutesWithSyncChildrenWithoutDefaultRoutesWithoutParams() { compile( tcb, `nav to child | outer [ ]`) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([new Route( {path: '/a/...', component: ParentCmp, name: 'Parent'})])) .then((_) => { @@ -307,7 +306,7 @@ function syncRoutesWithSyncChildrenWithoutDefaultRoutesWithParams() { it('should navigate by URL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { compile(tcb, `[ ]`) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([new Route( {path: '/team/:id/...', component: TeamCmp, name: 'Team'})])) .then((_) => rtr.navigateByUrl('/team/angular/user/matias')) @@ -321,7 +320,7 @@ function syncRoutesWithSyncChildrenWithoutDefaultRoutesWithParams() { it('should navigate by link DSL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { compile(tcb, `[ ]`) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([new Route( {path: '/team/:id/...', component: TeamCmp, name: 'Team'})])) .then((_) => rtr.navigate(['/Team', {id: 'angular'}, 'User', {name: 'matias'}])) @@ -337,7 +336,7 @@ function syncRoutesWithSyncChildrenWithoutDefaultRoutesWithParams() { compile( tcb, `nav to matias [ ]`) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([new Route( {path: '/team/:id/...', component: TeamCmp, name: 'Team'})])) .then((_) => { @@ -354,7 +353,7 @@ function syncRoutesWithSyncChildrenWithoutDefaultRoutesWithParams() { compile( tcb, `nav to matias [ ]`) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([new Route( {path: '/team/:id/...', component: TeamCmp, name: 'Team'})])) .then((_) => { @@ -391,7 +390,7 @@ function syncRoutesWithSyncChildrenWithDefaultRoutesWithoutParams() { it('should navigate by URL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { compile(tcb, `outer [ ]`) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([new Route( {path: '/a/...', component: ParentWithDefaultCmp, name: 'Parent'})])) .then((_) => rtr.navigateByUrl('/a')) @@ -404,7 +403,7 @@ function syncRoutesWithSyncChildrenWithDefaultRoutesWithoutParams() { it('should navigate by link DSL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { compile(tcb, `outer [ ]`) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([new Route( {path: '/a/...', component: ParentWithDefaultCmp, name: 'Parent'})])) .then((_) => rtr.navigate(['/Parent'])) @@ -419,7 +418,7 @@ function syncRoutesWithSyncChildrenWithDefaultRoutesWithoutParams() { compile( tcb, `link to inner | outer [ ]`) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([new Route( {path: '/a/...', component: ParentWithDefaultCmp, name: 'Parent'})])) .then((_) => { @@ -436,7 +435,7 @@ function syncRoutesWithSyncChildrenWithDefaultRoutesWithoutParams() { compile( tcb, `link to inner | outer [ ]`) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([new Route( {path: '/a/...', component: ParentWithDefaultCmp, name: 'Parent'})])) .then((_) => { @@ -472,40 +471,38 @@ function syncRoutesWithDynamicComponents() { })); - it('should work', - inject( - [AsyncTestCompleter], - (async: AsyncTestCompleter) => { - tcb.createAsync(DynamicLoaderCmp) - .then((rtc) => {fixture = rtc}) - .then((_) => rtr.config([new Route({path: '/', component: HelloCmp})])) - .then((_) => { - fixture.detectChanges(); - expect(fixture.debugElement.nativeElement).toHaveText('[ ]'); - return fixture.componentInstance.onSomeAction(); - }) - .then((_) => { - fixture.detectChanges(); - return rtr.navigateByUrl('/'); - }) - .then((_) => { - fixture.detectChanges(); - expect(fixture.debugElement.nativeElement).toHaveText('[ hello ]'); + it('should work', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { + tcb.createAsync(DynamicLoaderCmp) + .then((rtc) => { fixture = rtc; }) + .then((_) => rtr.config([new Route({path: '/', component: HelloCmp})])) + .then((_) => { + fixture.detectChanges(); + expect(fixture.debugElement.nativeElement).toHaveText('[ ]'); + return fixture.componentInstance.onSomeAction(); + }) + .then((_) => { + fixture.detectChanges(); + return rtr.navigateByUrl('/'); + }) + .then((_) => { + fixture.detectChanges(); + expect(fixture.debugElement.nativeElement).toHaveText('[ hello ]'); - return fixture.componentInstance.onSomeAction(); - }) - .then((_) => { + return fixture.componentInstance.onSomeAction(); + }) + .then((_) => { - // TODO(i): This should be rewritten to use NgZone#onStable or - // something - // similar basically the assertion needs to run when the world is - // stable and we don't know when that is, only zones know. - PromiseWrapper.resolve(null).then((_) => { - fixture.detectChanges(); - expect(fixture.debugElement.nativeElement).toHaveText('[ hello ]'); - async.done(); - }); - })})); + // TODO(i): This should be rewritten to use NgZone#onStable or + // something + // similar basically the assertion needs to run when the world is + // stable and we don't know when that is, only zones know. + PromiseWrapper.resolve(null).then((_) => { + fixture.detectChanges(); + expect(fixture.debugElement.nativeElement).toHaveText('[ hello ]'); + async.done(); + }); + }); + })); } diff --git a/modules/@angular/router-deprecated/test/integration/lifecycle_hook_spec.ts b/modules/@angular/router-deprecated/test/integration/lifecycle_hook_spec.ts index 10e260efe9..658400f21b 100644 --- a/modules/@angular/router-deprecated/test/integration/lifecycle_hook_spec.ts +++ b/modules/@angular/router-deprecated/test/integration/lifecycle_hook_spec.ts @@ -6,10 +6,9 @@ * 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 {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 {AsyncTestCompleter, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal'; import {RouteParams, Router, RouterLink, RouterOutlet} from '@angular/router-deprecated'; 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 {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 log: string[]; @@ -47,7 +46,7 @@ export function main() { it('should call the routerOnActivate hook', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { compile(tcb) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})])) .then((_) => rtr.navigateByUrl('/on-activate')) .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', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { compile(tcb) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})])) .then((_) => { ObservableWrapper.subscribe(eventBus, (ev) => { @@ -83,7 +82,7 @@ export function main() { it('should call the routerOnDeactivate hook', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { compile(tcb) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})])) .then((_) => rtr.navigateByUrl('/on-deactivate')) .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', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { compile(tcb) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})])) .then((_) => rtr.navigateByUrl('/parent-deactivate/child-deactivate')) .then((_) => { @@ -124,7 +123,7 @@ export function main() { it('should reuse a component when the routerCanReuse hook returns true', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { compile(tcb) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})])) .then((_) => rtr.navigateByUrl('/on-reuse/1/a')) .then((_) => { @@ -147,7 +146,7 @@ export function main() { it('should not reuse a component when the routerCanReuse hook returns false', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { compile(tcb) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})])) .then((_) => rtr.navigateByUrl('/never-reuse/1/a')) .then((_) => { @@ -170,7 +169,7 @@ export function main() { it('should navigate when routerCanActivate returns true', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { compile(tcb) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})])) .then((_) => { ObservableWrapper.subscribe(eventBus, (ev) => { @@ -190,7 +189,7 @@ export function main() { it('should not navigate when routerCanActivate returns false', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { compile(tcb) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})])) .then((_) => { ObservableWrapper.subscribe(eventBus, (ev) => { @@ -210,7 +209,7 @@ export function main() { it('should navigate away when routerCanDeactivate returns true', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { compile(tcb) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})])) .then((_) => rtr.navigateByUrl('/can-deactivate/a')) .then((_) => { @@ -236,7 +235,7 @@ export function main() { it('should not navigate away when routerCanDeactivate returns false', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { compile(tcb) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})])) .then((_) => rtr.navigateByUrl('/can-deactivate/a')) .then((_) => { @@ -263,7 +262,7 @@ export function main() { it('should run activation and deactivation hooks in the correct order', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { compile(tcb) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})])) .then((_) => rtr.navigateByUrl('/activation-hooks/child')) .then((_) => { @@ -291,7 +290,7 @@ export function main() { it('should only run reuse hooks when reusing', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { compile(tcb) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})])) .then((_) => rtr.navigateByUrl('/reuse-hooks/1')) .then((_) => { diff --git a/modules/@angular/router-deprecated/test/integration/navigation_spec.ts b/modules/@angular/router-deprecated/test/integration/navigation_spec.ts index ab6b397d39..4bdb88f6d6 100644 --- a/modules/@angular/router-deprecated/test/integration/navigation_spec.ts +++ b/modules/@angular/router-deprecated/test/integration/navigation_spec.ts @@ -9,8 +9,7 @@ import {Location} from '@angular/common'; import {Component, Inject, Injector, provide} from '@angular/core'; 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} 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 {RouteData, RouteParams, Router, RouterLink, RouterOutlet} from '@angular/router-deprecated'; 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) => { compile(tcb) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([new Route({path: '/test', component: HelloCmp})])) .then((_) => rtr.navigateByUrl('/test')) .then((_) => { @@ -55,7 +54,7 @@ export function main() { it('should navigate between components with different parameters', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { compile(tcb) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([new Route({path: '/user/:name', component: UserCmp})])) .then((_) => rtr.navigateByUrl('/user/brian')) .then((_) => { @@ -73,7 +72,7 @@ export function main() { it('should navigate to child routes', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { compile(tcb, 'outer [ ]') - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([new Route({path: '/a/...', component: ParentCmp})])) .then((_) => rtr.navigateByUrl('/a/b')) .then((_) => { @@ -87,7 +86,7 @@ export function main() { inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { compile(tcb, 'outer [ ]') - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([new Route({path: '/a/...', component: ParentCmp})])) .then((_) => rtr.navigateByUrl('/a')) .then((_) => { @@ -102,7 +101,7 @@ export function main() { [AsyncTestCompleter, Location], (async: AsyncTestCompleter, location: any /** TODO #9100 */) => { compile(tcb, 'outer [ ]') - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([new Route({path: '/...', component: ParentCmp})])) .then((_) => rtr.navigateByUrl('/b')) .then((_) => { @@ -117,7 +116,7 @@ export function main() { it('should navigate to child routes of async routes', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { compile(tcb, 'outer [ ]') - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([new AsyncRoute({path: '/a/...', loader: parentLoader})])) .then((_) => rtr.navigateByUrl('/a/b')) .then((_) => { @@ -133,7 +132,7 @@ export function main() { [AsyncTestCompleter, Location], (async: AsyncTestCompleter, location: any /** TODO #9100 */) => { compile(tcb) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => location.setInitialPath('/test/')) .then((_) => rtr.config([new Route({path: '/test', component: HelloCmp})])) .then((_) => rtr.navigateByUrl('/test')) @@ -148,7 +147,7 @@ export function main() { it('should reuse common parent components', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { compile(tcb) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([new Route({path: '/team/:id/...', component: TeamCmp})])) .then((_) => rtr.navigateByUrl('/team/angular/user/rado')) .then((_) => { @@ -169,7 +168,7 @@ export function main() { it('should not reuse children when parent components change', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { compile(tcb) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([new Route({path: '/team/:id/...', component: TeamCmp})])) .then((_) => rtr.navigateByUrl('/team/angular/user/rado')) .then((_) => { @@ -191,7 +190,7 @@ export function main() { it('should inject route data into component', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { compile(tcb) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([new Route( {path: '/route-data', component: RouteDataCmp, data: {isAdmin: true}})])) .then((_) => rtr.navigateByUrl('/route-data')) @@ -205,7 +204,7 @@ export function main() { it('should inject route data into component with AsyncRoute', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { compile(tcb) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([new AsyncRoute( {path: '/route-data', loader: asyncRouteDataCmp, data: {isAdmin: true}})])) .then((_) => rtr.navigateByUrl('/route-data')) @@ -219,7 +218,7 @@ export function main() { it('should inject empty object if the route has no data property', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { compile(tcb) - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([new Route( {path: '/route-data-default', component: RouteDataCmp})])) .then((_) => rtr.navigateByUrl('/route-data-default')) @@ -233,7 +232,7 @@ export function main() { it('should fire an event for each activated component', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { compile(tcb, '') - .then((rtc) => {fixture = rtc}) + .then((rtc) => { fixture = rtc; }) .then((_) => rtr.config([new Route({path: '/test', component: HelloCmp})])) .then((_) => rtr.navigateByUrl('/test')) .then((_) => { diff --git a/modules/@angular/router-deprecated/test/integration/redirect_route_spec.ts b/modules/@angular/router-deprecated/test/integration/redirect_route_spec.ts index 0f60214596..f02f6c8c6a 100644 --- a/modules/@angular/router-deprecated/test/integration/redirect_route_spec.ts +++ b/modules/@angular/router-deprecated/test/integration/redirect_route_spec.ts @@ -8,8 +8,7 @@ import {Location} from '@angular/common'; 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} 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 {RouteData, RouteParams, Router, RouterLink, RouterOutlet} from '@angular/router-deprecated'; import {AsyncRoute, AuxRoute, Redirect, Route, RouteConfig} from '../../src/route_config/route_config_decorator'; @@ -44,7 +43,7 @@ export function main() { [AsyncTestCompleter, Location], (async: AsyncTestCompleter, location: any /** TODO #9100 */) => { compile(tcb) - .then((rtc) => {rootTC = rtc}) + .then((rtc) => { rootTC = rtc; }) .then((_) => rtr.config([ new Redirect({path: '/original', redirectTo: ['Hello']}), new Route({path: '/redirected', component: HelloCmp, name: 'Hello'}) @@ -64,7 +63,7 @@ export function main() { [AsyncTestCompleter, Location], (async: AsyncTestCompleter, location: any /** TODO #9100 */) => { compile(tcb) - .then((rtc) => {rootTC = rtc}) + .then((rtc) => { rootTC = rtc; }) .then((_) => rtr.config([ new Redirect({path: '/original', redirectTo: ['/Hello']}), new Route({path: '/redirected', component: HelloCmp, name: 'Hello'}) @@ -84,7 +83,7 @@ export function main() { [AsyncTestCompleter, Location], (async: AsyncTestCompleter, location: any /** TODO #9100 */) => { compile(tcb) - .then((rtc) => {rootTC = rtc}) + .then((rtc) => { rootTC = rtc; }) .then((_) => rtr.config([ new Redirect({path: '/original', redirectTo: ['./Hello']}), new Route({path: '/redirected', component: HelloCmp, name: 'Hello'}) @@ -104,7 +103,7 @@ export function main() { [AsyncTestCompleter, Location], (async: AsyncTestCompleter, location: any /** TODO #9100 */) => { compile(tcb) - .then((rtc) => {rootTC = rtc}) + .then((rtc) => { rootTC = rtc; }) .then((_) => rtr.config([ new Route({path: '/original/...', component: RedirectToParentCmp}), new Route({path: '/redirected', component: HelloCmp, name: 'HelloSib'}) @@ -124,7 +123,7 @@ export function main() { [AsyncTestCompleter, Location], (async: AsyncTestCompleter, location: any /** TODO #9100 */) => { compile(tcb) - .then((rtc) => {rootTC = rtc}) + .then((rtc) => { rootTC = rtc; }) .then((_) => rtr.config([ new Route({path: '/foo', component: HelloCmp, name: 'Hello'}), new Route({path: '/:param', component: GoodbyeCmp, name: 'Goodbye'}), diff --git a/modules/@angular/router-deprecated/test/integration/router_link_spec.ts b/modules/@angular/router-deprecated/test/integration/router_link_spec.ts index e7620ab4e1..69eeae1687 100644 --- a/modules/@angular/router-deprecated/test/integration/router_link_spec.ts +++ b/modules/@angular/router-deprecated/test/integration/router_link_spec.ts @@ -6,8 +6,7 @@ * 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} 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 {ComponentFixture, TestComponentBuilder} from '@angular/core/testing'; import {Location} from '@angular/common'; import {NumberWrapper, escapeRegExp} from '../../src/facade/lang'; diff --git a/modules/@angular/router-deprecated/test/location/location_spec.ts b/modules/@angular/router-deprecated/test/location/location_spec.ts index 7def0103e2..ede43fa928 100644 --- a/modules/@angular/router-deprecated/test/location/location_spec.ts +++ b/modules/@angular/router-deprecated/test/location/location_spec.ts @@ -6,11 +6,10 @@ * 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} from '@angular/core/testing/testing_internal'; +import {AsyncTestCompleter, describe, it, iit, ddescribe, expect, inject, beforeEach, beforeEachProviders,} from '@angular/core/testing/testing_internal'; -import {Injector, provide, ReflectiveInjector} from '@angular/core'; -import {Location, LocationStrategy, APP_BASE_HREF} from '@angular/common'; +import {ReflectiveInjector} from '@angular/core'; +import {Location, LocationStrategy} from '@angular/common'; import {MockLocationStrategy} from '@angular/common/testing/mock_location_strategy'; export function main() { diff --git a/modules/@angular/router-deprecated/test/route_config/route_config_spec.ts b/modules/@angular/router-deprecated/test/route_config/route_config_spec.ts index e0005c6305..e95afdd040 100644 --- a/modules/@angular/router-deprecated/test/route_config/route_config_spec.ts +++ b/modules/@angular/router-deprecated/test/route_config/route_config_spec.ts @@ -6,18 +6,16 @@ * 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 {APP_BASE_HREF, LocationStrategy} from '@angular/common'; +import {LocationStrategy} from '@angular/common'; import {Component, Directive} from '@angular/core/src/metadata'; import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter'; 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 {AsyncTestCompleter} from '@angular/core/testing/testing_internal'; 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'; class _ArrayLogger { @@ -138,38 +136,37 @@ export function main() { })); it('should throw if a config is missing a target', - inject( - [AsyncTestCompleter], - (async: AsyncTestCompleter) => {bootstrap(WrongConfigCmp, testBindings).catch((e) => { - expect(e.originalException) - .toContainError( - 'Route config should contain exactly one "component", "loader", or "redirectTo" property.'); - async.done(); - return null; - })})); + inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { + bootstrap(WrongConfigCmp, testBindings).catch((e) => { + expect(e.originalException) + .toContainError( + 'Route config should contain exactly one "component", "loader", or "redirectTo" property.'); + async.done(); + return null; + }); + })); it('should throw if a config has an invalid component type', - inject( - [AsyncTestCompleter], - (async: - AsyncTestCompleter) => {bootstrap(WrongComponentTypeCmp, testBindings).catch((e) => { - expect(e.originalException) - .toContainError( - 'Invalid component type "intentionallyWrongComponentType". Valid types are "constructor" and "loader".'); - async.done(); - return null; - })})); + inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { + bootstrap(WrongComponentTypeCmp, testBindings).catch((e) => { + expect(e.originalException) + .toContainError( + 'Invalid component type "intentionallyWrongComponentType". Valid types are "constructor" and "loader".'); + async.done(); + return null; + }); + })); it('should throw if a config has an invalid alias name', - inject( - [AsyncTestCompleter], - (async: AsyncTestCompleter) => {bootstrap(BadAliasNameCmp, testBindings).catch((e) => { - expect(e.originalException) - .toContainError( - `Route "/child" with name "child" does not begin with an uppercase letter. Route names should be PascalCase like "Child".`); - async.done(); - return null; - })})); + inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { + bootstrap(BadAliasNameCmp, testBindings).catch((e) => { + expect(e.originalException) + .toContainError( + `Route "/child" with name "child" does not begin with an uppercase letter. Route names should be PascalCase like "Child".`); + async.done(); + return null; + }); + })); }); } diff --git a/modules/@angular/router-deprecated/test/route_registry_spec.ts b/modules/@angular/router-deprecated/test/route_registry_spec.ts index ff4cde194b..d615b93c21 100644 --- a/modules/@angular/router-deprecated/test/route_registry_spec.ts +++ b/modules/@angular/router-deprecated/test/route_registry_spec.ts @@ -6,8 +6,7 @@ * 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} from '@angular/core/testing/testing_internal'; +import {AsyncTestCompleter, describe, it, iit, ddescribe, expect, inject, beforeEach,} from '@angular/core/testing/testing_internal'; import {PromiseWrapper} from '../src/facade/async'; import {Type, IS_DART} from '../src/facade/lang'; diff --git a/modules/@angular/router-deprecated/test/router_spec.ts b/modules/@angular/router-deprecated/test/router_spec.ts index 7059773615..7124bd5f92 100644 --- a/modules/@angular/router-deprecated/test/router_spec.ts +++ b/modules/@angular/router-deprecated/test/router_spec.ts @@ -9,8 +9,7 @@ import {Location} from '@angular/common'; import {SpyLocation} from '@angular/common/testing'; import {provide} from '@angular/core'; -import {beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xit} from '@angular/core/testing/testing_internal'; -import {AsyncTestCompleter} from '@angular/core/testing/testing_internal'; +import {AsyncTestCompleter, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xit} from '@angular/core/testing/testing_internal'; import {RouterOutlet} from '../src/directives/router_outlet'; import {ObservableWrapper, PromiseWrapper} from '../src/facade/async'; diff --git a/modules/@angular/router-deprecated/test/rules/route_paths/regex_route_param_spec.ts b/modules/@angular/router-deprecated/test/rules/route_paths/regex_route_param_spec.ts index 524cfd6448..97ce7c2d91 100644 --- a/modules/@angular/router-deprecated/test/rules/route_paths/regex_route_param_spec.ts +++ b/modules/@angular/router-deprecated/test/rules/route_paths/regex_route_param_spec.ts @@ -10,7 +10,7 @@ import {describe, it, iit, ddescribe, expect, inject, beforeEach,} from '@angula import {GeneratedUrl} from '../../../src/rules/route_paths/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 */) { return new GeneratedUrl('', {}); @@ -47,10 +47,9 @@ export function main() { }); it('should raise an error when the number of parameters doesnt match', () => { - expect( - () => {new RegexRoutePath( - '^a-([0-9]+)-b-([0-9]+)$', emptySerializer, ['complete_match', 'a'])}) - .toThrowError(`Regex group names [complete_match,a] must contain names for each matching \ + expect(() => { + new RegexRoutePath('^a-([0-9]+)-b-([0-9]+)$', emptySerializer, ['complete_match', 'a']); + }).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]+)$'. \ 3 group names are expected.`); }); diff --git a/modules/@angular/router-deprecated/test/rules/rule_set_spec.ts b/modules/@angular/router-deprecated/test/rules/rule_set_spec.ts index 28a8f16ccc..084d427dcd 100644 --- a/modules/@angular/router-deprecated/test/rules/rule_set_spec.ts +++ b/modules/@angular/router-deprecated/test/rules/rule_set_spec.ts @@ -6,8 +6,7 @@ * 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} from '@angular/core/testing/testing_internal'; +import {AsyncTestCompleter, describe, it, iit, ddescribe, expect, inject, beforeEach,} from '@angular/core/testing/testing_internal'; import {RouteMatch, PathMatch, RedirectMatch} from '../../src/rules/rules'; import {RuleSet} from '../../src/rules/rule_set'; import {GeneratedUrl} from '../../src/rules/route_paths/route_path'; diff --git a/modules/@angular/router/test/apply_redirects.spec.ts b/modules/@angular/router/test/apply_redirects.spec.ts index d2b8d69705..6103d2ed50 100644 --- a/modules/@angular/router/test/apply_redirects.spec.ts +++ b/modules/@angular/router/test/apply_redirects.spec.ts @@ -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 {of } from 'rxjs/observable/of'; diff --git a/modules/@angular/router/test/config.spec.ts b/modules/@angular/router/test/config.spec.ts index 36c8378c0b..f8536f9160 100644 --- a/modules/@angular/router/test/config.spec.ts +++ b/modules/@angular/router/test/config.spec.ts @@ -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'; describe('config', () => { diff --git a/modules/@angular/router/test/create_router_state.spec.ts b/modules/@angular/router/test/create_router_state.spec.ts index 44897e3fed..e1f18ddf88 100644 --- a/modules/@angular/router/test/create_router_state.spec.ts +++ b/modules/@angular/router/test/create_router_state.spec.ts @@ -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 {createRouterState} from '../src/create_router_state'; import {recognize} from '../src/recognize'; diff --git a/modules/@angular/router/test/create_url_tree.spec.ts b/modules/@angular/router/test/create_url_tree.spec.ts index 821d440af4..c5c0e58ca8 100644 --- a/modules/@angular/router/test/create_url_tree.spec.ts +++ b/modules/@angular/router/test/create_url_tree.spec.ts @@ -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 {createUrlTree} from '../src/create_url_tree'; diff --git a/modules/@angular/router/test/recognize.spec.ts b/modules/@angular/router/test/recognize.spec.ts index 9463214dd1..c743d9572f 100644 --- a/modules/@angular/router/test/recognize.spec.ts +++ b/modules/@angular/router/test/recognize.spec.ts @@ -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 {recognize} from '../src/recognize'; import {ActivatedRouteSnapshot, RouterStateSnapshot} from '../src/router_state'; diff --git a/modules/@angular/router/test/resolve.spec.ts b/modules/@angular/router/test/resolve.spec.ts index 1716a880db..458e3df896 100644 --- a/modules/@angular/router/test/resolve.spec.ts +++ b/modules/@angular/router/test/resolve.spec.ts @@ -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 {recognize} from '../src/recognize'; import {resolve} from '../src/resolve'; diff --git a/modules/@angular/router/test/router.spec.ts b/modules/@angular/router/test/router.spec.ts index 50c75c2498..93de765411 100644 --- a/modules/@angular/router/test/router.spec.ts +++ b/modules/@angular/router/test/router.spec.ts @@ -1,9 +1,16 @@ +/** + * @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 'rxjs/add/operator/map'; import {Location} from '@angular/common'; import {AppModule, AppModuleFactoryLoader, Component} from '@angular/core'; -import {ComponentFixture, TestComponentBuilder} from '@angular/core/testing'; -import {addProviders, configureModule, fakeAsync, inject, tick} from '@angular/core/testing'; +import {ComponentFixture, TestComponentBuilder, addProviders, configureModule, fakeAsync, inject, tick} from '@angular/core/testing'; import {expect} from '@angular/platform-browser/testing/matchers'; import {Observable} from 'rxjs/Observable'; import {of } from 'rxjs/observable/of'; @@ -1375,7 +1382,7 @@ describe('Integration', () => { const recordedEvents: any[] = []; router.events.forEach(e => recordedEvents.push(e)); - router.navigateByUrl('/lazy/loaded').catch(s => {}) + router.navigateByUrl('/lazy/loaded').catch(s => {}); advance(fixture); expect(location.path()).toEqual('/'); diff --git a/modules/@angular/router/test/url_serializer.spec.ts b/modules/@angular/router/test/url_serializer.spec.ts index abed0dd90b..3fc810b209 100644 --- a/modules/@angular/router/test/url_serializer.spec.ts +++ b/modules/@angular/router/test/url_serializer.spec.ts @@ -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 {PRIMARY_OUTLET} from '../src/shared'; import {DefaultUrlSerializer, UrlSegment, serializePath} from '../src/url_tree'; diff --git a/modules/@angular/router/test/url_tree.spec.ts b/modules/@angular/router/test/url_tree.spec.ts index 9a24679c35..821e126a5d 100644 --- a/modules/@angular/router/test/url_tree.spec.ts +++ b/modules/@angular/router/test/url_tree.spec.ts @@ -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 {DefaultUrlSerializer, UrlTree, containsTree} from '../src/url_tree'; describe('UrlTree', () => { diff --git a/modules/@angular/router/test/utils/tree.spec.ts b/modules/@angular/router/test/utils/tree.spec.ts index 5c5e35dedf..65a534ea4f 100644 --- a/modules/@angular/router/test/utils/tree.spec.ts +++ b/modules/@angular/router/test/utils/tree.spec.ts @@ -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 {Tree, TreeNode} from '../../src/utils/tree'; describe('tree', () => { diff --git a/modules/@angular/upgrade/test/metadata_spec.ts b/modules/@angular/upgrade/test/metadata_spec.ts index 0c603fb129..04dd812287 100644 --- a/modules/@angular/upgrade/test/metadata_spec.ts +++ b/modules/@angular/upgrade/test/metadata_spec.ts @@ -57,7 +57,7 @@ export function main() { } ]); }); - }) + }); }); } diff --git a/modules/@angular/upgrade/test/upgrade_spec.ts b/modules/@angular/upgrade/test/upgrade_spec.ts index f21f3cc377..75bac45b05 100644 --- a/modules/@angular/upgrade/test/upgrade_spec.ts +++ b/modules/@angular/upgrade/test/upgrade_spec.ts @@ -201,7 +201,7 @@ export function main() { 'ignore: -; ' + 'literal: Text; interpolate: Hello world; ' + 'oneWayA: A; oneWayB: B; twoWayA: newA; twoWayB: newB; (2) | ' + - 'modelA: newA; modelB: newB; eventA: aFired; eventB: bFired;') + 'modelA: newA; modelB: newB; eventA: aFired; eventB: bFired;'); ref.dispose(); async.done(); }); @@ -230,10 +230,12 @@ export function main() { }); ng1Module.directive('ng2', adapter.downgradeNg2Component(Ng2)); var element = html(''); - adapter.bootstrap(element, ['ng1']).ready((ref) => {onDestroyed.subscribe(() => { - ref.dispose(); - async.done(); - })}); + adapter.bootstrap(element, ['ng1']).ready((ref) => { + onDestroyed.subscribe(() => { + ref.dispose(); + async.done(); + }); + }); })); @@ -288,7 +290,7 @@ export function main() { // Should not update because [model-a] is uni directional scope.dataA = 'VICTOR'; } - }) + }); } }; }; @@ -351,7 +353,7 @@ export function main() { constructor: function() { this.dataList = [1, 2, 3]; - this.someText = 'ng2' + this.someText = 'ng2'; } }); ng1Module.directive('ng2', adapter.downgradeNg2Component(Ng2)); @@ -395,7 +397,7 @@ export function main() { constructor: function() { this.dataList = [1, 2, 3]; - this.someText = 'ng2' + this.someText = 'ng2'; } }); ng1Module.directive('ng2', adapter.downgradeNg2Component(Ng2)); @@ -446,7 +448,7 @@ export function main() { post: any /** TODO #9100 */, cbFn: any /** TODO #9100 */) => { cbFn(200, `${method}:${url}`); }); - var ng1 = function() { return {templateUrl() { return 'url.html' }}; }; + var ng1 = function() { return {templateUrl() { return 'url.html'; }}; }; ng1Module.directive('ng1', ng1); var Ng2 = Component({ selector: 'ng2', @@ -488,7 +490,7 @@ export function main() { var adapter = new UpgradeAdapter(); var ng1Module = angular.module('ng1', []); - var ng1 = function() { return {template() { return '' }}; }; + var ng1 = function() { return {template() { return ''; }}; }; ng1Module.directive('ng1', ng1); var Ng2 = Component({ selector: 'ng2',