fix(testing): remove deprecated testing APIs (#9923)

See https://github.com/angular/angular/blob/master/CHANGELOG.md for
prior deprecation and how to update.
This commit is contained in:
Julie Ralph 2016-07-11 16:04:32 -07:00 committed by GitHub
parent 94dc632a6d
commit 9af2d8b810
71 changed files with 122 additions and 416 deletions

View File

@ -7,9 +7,8 @@
*/
import {NgClass, NgFor} from '@angular/common';
import {TestComponentBuilder} from '@angular/compiler/testing';
import {Component, provide} from '@angular/core';
import {ComponentFixture} from '@angular/core/testing';
import {ComponentFixture, TestComponentBuilder} from '@angular/core/testing';
import {beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
@ -30,7 +29,7 @@ export function main() {
var template = '<div *ngFor="let item of items" [ngClass]="item"></div>';
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((fixture) => {
.then((fixture: ComponentFixture<TestComponent>) => {
fixture.debugElement.componentInstance.items = [['0']];
fixture.detectChanges();
fixture.debugElement.componentInstance.items = [['1']];

View File

@ -8,7 +8,7 @@
import {beforeEach, beforeEachProviders, ddescribe, describe, iit, inject, it, xit,} from '@angular/core/testing/testing_internal';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {TestComponentBuilder} from '@angular/compiler/testing';
import {TestComponentBuilder} from '@angular/core/testing';
import {ListWrapper} from '../../src/facade/collection';
import {IS_DART} from '../../src/facade/lang';
import {Component, TemplateRef, ContentChild} from '@angular/core';

View File

@ -7,7 +7,7 @@
*/
import {beforeEach, ddescribe, describe, iit, inject, it, xit,} from '@angular/core/testing/testing_internal';
import {TestComponentBuilder} from '@angular/compiler/testing';
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';

View File

@ -8,7 +8,7 @@
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 {TestComponentBuilder} from '@angular/compiler/testing';
import {TestComponentBuilder} from '@angular/core/testing';
import {Component, Injectable} from '@angular/core';
import {NgPlural, NgPluralCase, NgLocalization} from '@angular/common';

View File

@ -7,7 +7,7 @@
*/
import {beforeEach, beforeEachProviders, ddescribe, xdescribe, describe, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal';
import {TestComponentBuilder} from '@angular/compiler/testing';
import {TestComponentBuilder} from '@angular/core/testing';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {StringMapWrapper} from '../../src/facade/collection';

View File

@ -9,7 +9,7 @@
import {beforeEach, ddescribe, describe, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {Component} from '@angular/core';
import {TestComponentBuilder} from '@angular/compiler/testing';
import {TestComponentBuilder} from '@angular/core/testing';
import {NgSwitch, NgSwitchCase, NgSwitchDefault} from '@angular/common';

View File

@ -7,7 +7,7 @@
*/
import {beforeEach, ddescribe, describe, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal';
import {TestComponentBuilder} from '@angular/compiler/testing';
import {TestComponentBuilder} from '@angular/core/testing';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {Component, Directive, TemplateRef, ContentChildren, QueryList} from '@angular/core';
import {NgTemplateOutlet} from '@angular/common';

View File

@ -7,7 +7,7 @@
*/
import {beforeEach, ddescribe, describe, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal';
import {TestComponentBuilder} from '@angular/compiler/testing';
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';

View File

@ -8,10 +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 {TestComponentBuilder} from '@angular/compiler/testing';
import {Component, Directive, EventEmitter, Output} from '@angular/core';
import {Input, Provider, forwardRef} from '@angular/core';
import {ComponentFixture, configureModule, fakeAsync, flushMicrotasks, tick} from '@angular/core/testing';
import {ComponentFixture, TestComponentBuilder, configureModule, fakeAsync, flushMicrotasks, tick} from '@angular/core/testing';
import {afterEach, beforeEach, ddescribe, describe, expect, iit, inject, it, xit} from '@angular/core/testing/testing_internal';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {By} from '@angular/platform-browser/src/dom/debug/by';

View File

@ -8,7 +8,7 @@
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 {TestComponentBuilder} from '@angular/compiler/testing';
import {TestComponentBuilder} from '@angular/core/testing';
import {Json, StringWrapper} from '../../src/facade/lang';
import {Component} from '@angular/core';

View File

@ -7,7 +7,7 @@
*/
import {ddescribe, describe, it, iit, xit, expect, beforeEach, afterEach, inject,} from '@angular/core/testing/testing_internal';
import {TestComponentBuilder} from '@angular/compiler/testing';
import {TestComponentBuilder} from '@angular/core/testing';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {browserDetection} from '@angular/platform-browser/testing/browser_util';

View File

@ -8,7 +8,6 @@
import {DirectiveResolver} from '@angular/compiler/src/directive_resolver';
import {ContentChild, ContentChildMetadata, ContentChildren, ContentChildrenMetadata, Directive, DirectiveMetadata, HostBinding, HostListener, Input, Output, ViewChild, ViewChildMetadata, ViewChildren, ViewChildrenMetadata} from '@angular/core/src/metadata';
import {beforeEach, ddescribe, describe, expect, iit, it} from '@angular/core/testing';
@Directive({selector: 'someDirective'})
class SomeDirective {

View File

@ -7,7 +7,6 @@
*/
import {Lexer, Token} from '@angular/compiler/src/expression_parser/lexer';
import {ddescribe, describe, expect, it} from '@angular/core/testing';
import {StringWrapper} from '../../src/facade/lang';

View File

@ -9,7 +9,7 @@
import {AST, ASTWithSource, BindingPipe, Interpolation, LiteralPrimitive, ParserError, TemplateBinding} from '@angular/compiler/src/expression_parser/ast';
import {Lexer} from '@angular/compiler/src/expression_parser/lexer';
import {Parser, TemplateBindingParseResult} from '@angular/compiler/src/expression_parser/parser';
import {beforeEach, ddescribe, describe, expect, iit, it, xit} from '@angular/core/testing';
import {expect} from '@angular/core/testing/testing_internal';
import {isBlank, isPresent} from '../../src/facade/lang';

View File

@ -8,7 +8,6 @@
import {SelectorMatcher} from '@angular/compiler/src/selector';
import {CssSelector} from '@angular/compiler/src/selector';
import {beforeEach, ddescribe, describe, expect, iit, it, xit} from '@angular/core/testing';
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
import {el} from '@angular/platform-browser/testing/browser_util';

View File

@ -8,7 +8,6 @@
import {extractStyleUrls, isStyleUrlResolvable} from '@angular/compiler/src/style_url_resolver';
import {UrlResolver} from '@angular/compiler/src/url_resolver';
import {beforeEach, ddescribe, describe, expect, iit, it, xit} from '@angular/core/testing';
export function main() {
describe('extractStyleUrls', () => {

View File

@ -7,7 +7,7 @@
*/
import {beforeEach, ddescribe, xdescribe, describe, expect, iit, inject, beforeEachProviders, it, xit,} from '@angular/core/testing/testing_internal';
import {TestComponentBuilder, ComponentFixtureAutoDetect, ComponentFixtureNoNgZone} from '@angular/compiler/testing';
import {TestComponentBuilder, ComponentFixtureAutoDetect, ComponentFixtureNoNgZone} 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';

View File

@ -8,7 +8,6 @@
import {ViewResolver} from '@angular/compiler/src/view_resolver';
import {Component, ViewMetadata} from '@angular/core/src/metadata';
import {beforeEach, ddescribe, describe, expect, iit, it} from '@angular/core/testing';
class SomeDir {}
class SomePipe {}

View File

@ -13,29 +13,6 @@ import {DirectiveResolver, ViewResolver} from '../index';
import {MapWrapper} from '../src/facade/collection';
import {ConcreteType, IS_DART, Type, isPresent} from '../src/facade/lang';
/**
* @deprecated Import TestComponentRenderer from @angular/core/testing
*/
export {TestComponentRenderer} from '@angular/core/testing';
/**
* @deprecated Import TestComponentBuilder from @angular/core/testing
*/
export {TestComponentBuilder} from '@angular/core/testing';
/**
* @deprecated Import ComponentFixture from @angular/core/testing
*/
export {ComponentFixture} from '@angular/core/testing';
/**
* @deprecated Import ComponentFixtureNoNgZone from @angular/core/testing
*/
export {ComponentFixtureNoNgZone} from '@angular/core/testing';
/**
* @deprecated Import ComponentFixtureAutoDetect from @angular/core/testing
*/
export {ComponentFixtureAutoDetect} from '@angular/core/testing';
/**
* A TestComponentBuilder that allows overriding based on the compiler.
*/

View File

@ -8,7 +8,7 @@
import {NgIf} from '@angular/common';
import {CompilerConfig} from '@angular/compiler';
import {TestComponentBuilder} from '@angular/compiler/testing';
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';
import {MockAnimationDriver} from '@angular/platform-browser/testing/mock_animation_driver';

View File

@ -8,7 +8,7 @@
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 {TestComponentBuilder} from '@angular/compiler/testing';
import {TestComponentBuilder} from '@angular/core/testing';
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';

View File

@ -7,7 +7,6 @@
*/
import {isDevMode} from '@angular/core';
import {beforeEach, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '../testing';
export function main() {
describe('dev mode', () => {

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {beforeEach, ddescribe, describe, expect, iit, it} from '@angular/core/testing';
import {expect} from '@angular/core/testing/testing_internal';
import {BaseException} from '../../src/facade/exceptions';
import {isBlank, isPresent, stringify} from '../../src/facade/lang';

View File

@ -7,7 +7,6 @@
*/
import {KeyRegistry, ReflectiveKey} from '@angular/core/src/di/reflective_key';
import {beforeEach, describe, expect, iit, it} from '@angular/core/testing';
export function main() {
describe('key', function() {

View File

@ -6,9 +6,9 @@
* found in the LICENSE file at https://angular.io/license
*/
import {TestComponentBuilder} from '@angular/compiler/testing';
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';

View File

@ -7,9 +7,9 @@
*/
import {NgFor} from '@angular/common';
import {TestComponentBuilder} from '@angular/compiler/testing';
import {Component, Directive, Inject, Query, QueryList, bind, forwardRef, provide, resolveForwardRef} from '@angular/core';
import {asNativeElements} 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';

View File

@ -9,9 +9,10 @@
import {AsyncPipe, NgFor} from '@angular/common';
import {ElementSchemaRegistry} from '@angular/compiler/src/schema/element_schema_registry';
import {TEST_COMPILER_PROVIDERS} from '@angular/compiler/test/test_bindings';
import {MockSchemaRegistry, TestComponentBuilder} from '@angular/compiler/testing';
import {MockSchemaRegistry} from '@angular/compiler/testing';
import {AfterContentChecked, AfterContentInit, AfterViewChecked, AfterViewInit, ChangeDetectionStrategy, ChangeDetectorRef, Component, DebugElement, Directive, DoCheck, Injectable, Input, OnChanges, OnDestroy, OnInit, Output, Pipe, PipeTransform, RenderComponentType, Renderer, RootRenderer, SimpleChange, SimpleChanges, TemplateRef, ViewContainerRef, ViewMetadata, WrappedValue, forwardRef} from '@angular/core';
import {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 {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';

View File

@ -8,8 +8,7 @@
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 {ComponentFixture} from '@angular/core/testing';
import {TestComponentBuilder} from '@angular/compiler/testing';
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';

View File

@ -7,8 +7,7 @@
*/
import {beforeEach, ddescribe, xdescribe, describe, expect, iit, inject, beforeEachProviders, it, xit,} from '@angular/core/testing/testing_internal';
import {fakeAsync, tick, ComponentFixture, configureCompiler, configureModule} from '@angular/core/testing';
import {TestComponentBuilder} from '@angular/compiler/testing';
import {fakeAsync, tick, ComponentFixture, configureCompiler, configureModule, TestComponentBuilder} from '@angular/core/testing';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
import {isPresent, stringify, isBlank,} from '../../src/facade/lang';

View File

@ -7,9 +7,8 @@
*/
import {beforeEach, ddescribe, xdescribe, describe, expect, iit, inject, beforeEachProviders, it, xit,} from '@angular/core/testing/testing_internal';
import {TestComponentBuilder} from '@angular/compiler/testing';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {configureCompiler} from '@angular/core/testing';
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 {NgIf} from '@angular/common';

View File

@ -7,7 +7,7 @@
*/
import {beforeEach, ddescribe, xdescribe, describe, expect, iit, inject, beforeEachProviders, it, xit,} from '@angular/core/testing/testing_internal';
import {TestComponentBuilder} from '@angular/compiler/testing';
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';

View File

@ -8,8 +8,7 @@
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 {ComponentFixture} from '@angular/core/testing';
import {TestComponentBuilder} from '@angular/compiler/testing';
import {ComponentFixture, TestComponentBuilder} from '@angular/core/testing';
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';

View File

@ -7,7 +7,7 @@
*/
import {beforeEach, ddescribe, describe, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal';
import {TestComponentBuilder} from '@angular/compiler/testing';
import {TestComponentBuilder} from '@angular/core/testing';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {isPresent, stringify} from '../../src/facade/lang';

View File

@ -7,8 +7,7 @@
*/
import {beforeEach, ddescribe, xdescribe, describe, expect, iit, inject, beforeEachProviders, it, xit,} from '@angular/core/testing/testing_internal';
import {configureCompiler, configureModule} from '@angular/core/testing';
import {TestComponentBuilder} from '@angular/compiler/testing';
import {configureCompiler, configureModule, TestComponentBuilder} from '@angular/core/testing';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {IS_DART} from '../../src/facade/lang';

View File

@ -7,9 +7,8 @@
*/
import {ddescribe, describe, expect, inject, beforeEachProviders, beforeEach, afterEach, it,} from '@angular/core/testing/testing_internal';
import {TestComponentBuilder} from '@angular/compiler/testing';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {configureCompiler} from '@angular/core/testing';
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';

View File

@ -7,8 +7,7 @@
*/
import {describe, ddescribe, it, iit, xit, xdescribe, expect, beforeEach, beforeEachProviders, inject,} from '@angular/core/testing/testing_internal';
import {fakeAsync, flushMicrotasks, tick, ComponentFixture} from '@angular/core/testing';
import {TestComponentBuilder} from '@angular/compiler/testing';
import {fakeAsync, flushMicrotasks, tick, ComponentFixture, TestComponentBuilder} from '@angular/core/testing';
import {isBlank, ConcreteType} from '../../src/facade/lang';
import {Type, ViewContainerRef, TemplateRef, ElementRef, ChangeDetectorRef, ChangeDetectionStrategy, Directive, Component, DebugElement, forwardRef, Input, PipeTransform, Attribute, ViewMetadata, provide, Optional, Inject, Self, InjectMetadata, Pipe, Host, SkipSelfMetadata} from '@angular/core';
import {NgIf, NgFor} from '@angular/common';

View File

@ -1,29 +0,0 @@
/**
* @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 {describe, it, iit, ddescribe, expect, tick, beforeEach,} from '../testing';
import {getDOM} from '../../platform-browser/src/dom/dom_adapter';
export function main() {
describe('testing', () => {
describe('toHaveCssClass', () => {
it('should assert that the CSS class is present', () => {
var el = getDOM().createElement('div');
getDOM().addClass(el, 'matias');
expect(el).toHaveCssClass('matias');
});
it('should assert that the CSS class is not present', () => {
var el = getDOM().createElement('div');
getDOM().addClass(el, 'matias');
expect(el).not.toHaveCssClass('fatias');
});
});
});
}

View File

@ -7,7 +7,7 @@
*/
import {AsyncTestCompleter, beforeEach, ddescribe, describe, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal';
import {TestComponentBuilder} from '@angular/compiler/testing';
import {TestComponentBuilder} from '@angular/core/testing';
import {Component, ViewMetadata, Input, Directive, ViewChild, ViewChildren, QueryList, ElementRef} from '@angular/core';

View File

@ -9,7 +9,6 @@
import {SpyObject} from '@angular/core/testing/testing_internal';
import {MapWrapper} from '../../platform-browser/src/facade/collection';
import {beforeEach, ddescribe, describe, expect, iit, it, tick} from '../testing';
class TestObj {
prop: any;

View File

@ -18,100 +18,11 @@ declare var global: any;
var _global = <any>(typeof window === 'undefined' ? global : window);
/**
* @deprecated you no longer need to import jasmine functions from @angular/core/testing. Simply use
* the globals.
*
* See http://jasmine.github.io/ for more details.
*/
export var expect: Function = _global.expect;
/**
* @deprecated you no longer need to import jasmine functions from @angular/core/testing. Simply use
* the globals.
*
* See http://jasmine.github.io/ for more details.
*/
export var afterEach: Function = _global.afterEach;
/**
* @deprecated you no longer need to import jasmine functions from @angular/core/testing. Simply use
* the globals.
*
* See http://jasmine.github.io/ for more details.
*/
export var describe: Function = _global.describe;
/**
* @deprecated you no longer need to import jasmine functions from @angular/core/testing. Simply use
* the globals.
*
* See http://jasmine.github.io/ for more details.
*/
export var fdescribe = _global.fdescribe;
/**
* @deprecated you no longer need to import jasmine functions from @angular/core/testing. Simply use
* the globals.
*
* See http://jasmine.github.io/ for more details.
*/
export var ddescribe = _global.ddescribe;
/**
* @deprecated you no longer need to import jasmine functions from @angular/core/testing. Simply use
* the globals.
*
* See http://jasmine.github.io/ for more details.
*/
export var xdescribe: Function = _global.xdescribe;
/**
* @deprecated you no longer need to import jasmine functions from @angular/core/testing. Simply use
* the globals.
*
* See http://jasmine.github.io/ for more details.
*/
export var beforeEach = _global.beforeEach;
/**
* @deprecated you no longer need to import jasmine functions from @angular/core/testing. Simply use
* the globals.
*
* See http://jasmine.github.io/ for more details.
*/
export var it = _global.it;
/**
* @deprecated you no longer need to import jasmine functions from @angular/core/testing. Simply use
* the globals.
*
* See http://jasmine.github.io/ for more details.
*/
export var fit = _global.fit;
/**
* @deprecated you no longer need to import jasmine functions from @angular/core/testing. Simply use
* the globals.
*
* See http://jasmine.github.io/ for more details.
*/
export var iit = _global.fit;
/**
* @deprecated you no longer need to import jasmine functions from @angular/core/testing. Simply use
* the globals.
*
* See http://jasmine.github.io/ for more details.
*/
export var xit = _global.xit;
var testInjector: TestInjector = getTestInjector();
// Reset the test providers before each test.
if (_global.beforeEach) {
beforeEach(() => { testInjector.reset(); });
_global.beforeEach(() => { testInjector.reset(); });
}
/**
@ -173,10 +84,3 @@ export function configureCompiler(config: {providers?: any[], useJit?: boolean})
'current `it` function.');
}
}
/**
* @deprecated Use beforeEach(() => addProviders())
*/
export function beforeEachProviders(fn: () => Array<any>): void {
beforeEach(() => { addProviders(fn()); });
}

View File

@ -16,8 +16,6 @@ import {getTestInjector, inject} from './test_injector';
export {AsyncTestCompleter} from './async_test_completer';
export {MockAnimationPlayer} from './mock_animation_player';
export {inject} from './test_injector';
export {expect} from './testing';
export * from './logger';
export * from './ng_zone_mock';
export * from './mock_application_ref';
@ -27,6 +25,7 @@ export var proxy: ClassDecorator = (t: any /** TODO #9100 */) => t;
var _global = <any>(typeof window === 'undefined' ? global : window);
export var afterEach: Function = _global.afterEach;
export var expect: Function = _global.expect;
var jsmBeforeEach = _global.beforeEach;
var jsmDescribe = _global.describe;

View File

@ -6,7 +6,6 @@
* found in the LICENSE file at https://angular.io/license
*/
import {expect} from '@angular/core/testing';
import {verifyNoBrowserErrors} from '@angular/platform-browser/testing_e2e';
function waitForElement(selector: string) {

View File

@ -6,7 +6,6 @@
* found in the LICENSE file at https://angular.io/license
*/
import {expect} from '@angular/core/testing';
import {verifyNoBrowserErrors} from '@angular/platform-browser/testing_e2e';
function waitForElement(selector: string) {

View File

@ -6,7 +6,6 @@
* found in the LICENSE file at https://angular.io/license
*/
import {expect} from '@angular/core/testing';
import {verifyNoBrowserErrors} from '@angular/platform-browser/testing_e2e';
function waitForElement(selector: string) {

View File

@ -6,7 +6,6 @@
* found in the LICENSE file at https://angular.io/license
*/
import {expect} from '@angular/core/testing';
import {verifyNoBrowserErrors} from '@angular/platform-browser/testing_e2e';
function waitForElement(selector: string) {

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {describe, discardPeriodicTasks, expect, fakeAsync, it, tick} from '@angular/core/testing';
import {discardPeriodicTasks, fakeAsync, tick} from '@angular/core/testing';
// #docregion basic

View File

@ -1,44 +0,0 @@
/**
* @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 {expect} from '@angular/core/testing';
var value: any;
var element: any;
var exception: any;
abstract class OtherClass {}
class SomeClass {}
// #docregion toBePromise
expect(value).toBePromise();
// #enddocregion
// #docregion toBeAnInstanceOf
expect(value).toBeAnInstanceOf(SomeClass);
// #enddocregion
// #docregion toHaveText
expect(element).toHaveText('Hello world!');
// #enddocregion
// #docregion toHaveCssClass
expect(element).toHaveCssClass('current');
// #enddocregion
// #docregion toHaveCssStyle
expect(element).toHaveCssStyle({width: '100px', height: 'auto'});
// #enddocregion
// #docregion toContainError
expect(exception).toContainError('Failed to load');
// #enddocregion
// #docregion toImplement
expect(SomeClass).toImplement(OtherClass);
// #enddocregion

View File

@ -6,8 +6,6 @@
* found in the LICENSE file at https://angular.io/license
*/
import {beforeEach, ddescribe, describe, expect, iit, it, xit} from '@angular/core/testing';
import {ListWrapper, MapWrapper, StringMapWrapper} from '../src/collection';
export function main() {

View File

@ -6,7 +6,6 @@
* found in the LICENSE file at https://angular.io/license
*/
import {beforeEach, ddescribe, describe, expect, iit, it, xit} from '@angular/core/testing';
import {NumberWrapper, RegExpMatcherWrapper, RegExpWrapper, StringWrapper, escapeRegExp, hasConstructor, isPresent, resolveEnumToken} from '../src/lang';
enum UsefulEnum {

View File

@ -7,10 +7,9 @@
*/
import {NgFor, NgIf} from '@angular/common';
import {TestComponentBuilder} from '@angular/compiler/testing';
import {Component, Directive, EventEmitter, Output} from '@angular/core';
import {Input, Provider, forwardRef} from '@angular/core';
import {ComponentFixture, configureModule, fakeAsync, flushMicrotasks, tick} from '@angular/core/testing';
import {ComponentFixture, TestComponentBuilder, configureModule, fakeAsync, flushMicrotasks, tick} from '@angular/core/testing';
import {afterEach, beforeEach, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal';
import {AsyncTestCompleter} 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';

View File

@ -6,17 +6,15 @@
* found in the LICENSE file at https://angular.io/license
*/
import {it, iit, xit, describe, ddescribe, xdescribe, expect, beforeEach, beforeEachProviders, inject,} from '@angular/core/testing';
import {async, fakeAsync, flushMicrotasks, tick,} from '@angular/core/testing';
import {XHR} from '@angular/compiler';
import {Component, bind} from '@angular/core';
import {TestComponentBuilder, addProviders, async, fakeAsync, flushMicrotasks, inject, tick} from '@angular/core/testing';
import {ROUTER_DIRECTIVES, Route} from '@angular/router-deprecated';
import {Component, bind} from '@angular/core';
import {PromiseWrapper} from '../src/facade/promise';
import {XHR} from '@angular/compiler';
import {XHRImpl} from '../src/xhr/xhr_impl';
import {TestComponentBuilder} from '@angular/compiler/testing';
// Components for the tests.
class FancyService {
@ -51,45 +49,6 @@ class TestRouterComponent {
// For general tests, see test/testing/testing_public_spec.ts.
export function main() {
describe('test APIs for the browser', () => {
describe('angular2 jasmine matchers', () => {
describe('toHaveCssClass', () => {
it('should assert that the CSS class is present', () => {
var el = document.createElement('div');
el.classList.add('matias');
expect(el).toHaveCssClass('matias');
});
it('should assert that the CSS class is not present', () => {
var el = document.createElement('div');
el.classList.add('matias');
expect(el).not.toHaveCssClass('fatias');
});
});
describe('toHaveCssStyle', () => {
it('should assert that the CSS style is present', () => {
var el = document.createElement('div');
expect(el).not.toHaveCssStyle('width');
el.style.setProperty('width', '100px');
expect(el).toHaveCssStyle('width');
});
it('should assert that the styles are matched against the element', () => {
var el = document.createElement('div');
expect(el).not.toHaveCssStyle({width: '100px', height: '555px'});
el.style.setProperty('width', '100px');
expect(el).toHaveCssStyle({width: '100px'});
expect(el).not.toHaveCssStyle({width: '100px', height: '555px'});
el.style.setProperty('height', '555px');
expect(el).toHaveCssStyle({height: '555px'});
expect(el).toHaveCssStyle({width: '100px', height: '555px'});
});
});
});
describe('using the async helper', () => {
var actuallyDone: boolean;
@ -107,10 +66,10 @@ export function main() {
describe('using the test injector with the inject helper', () => {
describe('setting up Providers', () => {
beforeEachProviders(() => [{provide: FancyService, useValue: new FancyService()}]);
beforeEach(() => addProviders([{provide: FancyService, useValue: new FancyService()}]));
it('provides a real XHR instance',
inject([XHR], (xhr: XHR) => { expect(xhr).toBeAnInstanceOf(XHRImpl); }));
inject([XHR], (xhr: XHR) => { expect(xhr instanceof XHRImpl).toBeTruthy(); }));
it('should allow the use of fakeAsync',
fakeAsync(inject([FancyService], (service: any /** TODO #9100 */) => {
@ -166,8 +125,8 @@ export function main() {
tcb.createAsync(ExternalTemplateComp).then((componentFixture) => {
componentFixture.detectChanges();
expect(componentFixture.debugElement.nativeElement)
.toHaveText('from external template\n');
expect(componentFixture.debugElement.nativeElement.textContent)
.toEqual('from external template\n');
});
})),
10000); // Long timeout here because this test makes an actual XHR, and is slow on Edge.

View File

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

View File

@ -6,8 +6,8 @@
* found in the LICENSE file at https://angular.io/license
*/
import {TestComponentRenderer} from '@angular/compiler/testing';
import {Inject, Injectable} from '@angular/core';
import {TestComponentRenderer} from '@angular/core/testing';
import {DOCUMENT} from '@angular/platform-browser';
import {getDOM} from '../platform_browser_private';

View File

@ -6,7 +6,6 @@
* found in the LICENSE file at https://angular.io/license
*/
import {afterEach, ddescribe, describe, expect, iit, it, xit} from '@angular/core/testing';
import {Title} from '@angular/platform-browser';
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';

View File

@ -6,8 +6,6 @@
* found in the LICENSE file at https://angular.io/license
*/
import {ddescribe, describe, expect, iit, it} from '@angular/core/testing';
import {StringMapWrapper} from '../src/facade/collection';
import {BrowserDetection} from '../testing/browser_util';

View File

@ -8,9 +8,8 @@
import {NgIf} from '@angular/common';
import {CompilerConfig, XHR} from '@angular/compiler';
import {TestComponentBuilder} from '@angular/compiler/testing';
import {AppModule, Component, ComponentFactoryResolver, Directive, Injectable, Input, Pipe, ViewMetadata, provide} from '@angular/core';
import {addProviders, async, configureCompiler, configureModule, fakeAsync, inject, tick, withModule, withProviders} from '@angular/core/testing';
import {TestComponentBuilder, addProviders, async, configureCompiler, configureModule, fakeAsync, inject, tick, withModule, withProviders} from '@angular/core/testing';
import {expect} from '@angular/platform-browser/testing/matchers';
import {stringify} from '../../http/src/facade/lang';

View File

@ -7,7 +7,6 @@
*/
import {NgZone} from '@angular/core/src/zone/ng_zone';
import {expect} from '@angular/core/testing';
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 {MessageBus, MessageBusSink, MessageBusSource} from '@angular/platform-browser/src/web_workers/shared/message_bus';

View File

@ -8,8 +8,7 @@
import {inject, ddescribe, describe, it, iit, expect, beforeEach, beforeEachProviders,} from '@angular/core/testing/testing_internal';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {TestInjector, configureModule} from '@angular/core/testing';
import {TestComponentBuilder} from '@angular/compiler/testing';
import {TestInjector, 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 {NgIf} from '@angular/common';

View File

@ -7,7 +7,7 @@
*/
import {Component, disposePlatform} from '@angular/core';
import {afterEach, async, beforeEach, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing';
import {async} from '@angular/core/testing';
import {BROWSER_APP_PROVIDERS} from '@angular/platform-browser';
import {BROWSER_APP_COMPILER_PROVIDERS} from '@angular/platform-browser-dynamic';
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';

View File

@ -7,7 +7,7 @@
*/
import {beforeEach, ddescribe, xdescribe, describe, expect, iit, inject, beforeEachProviders, it, xit,} from '@angular/core/testing/testing_internal';
import {TestComponentBuilder} from '@angular/compiler/testing';
import {TestComponentBuilder} from '@angular/core/testing';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {SpyRouter, SpyLocation} from '../spies';

View File

@ -8,11 +8,11 @@
import {APP_BASE_HREF, LocationStrategy} from '@angular/common';
import {MockLocationStrategy} from '@angular/common/testing/mock_location_strategy';
import {TestComponentBuilder} from '@angular/compiler/testing';
import {disposePlatform} from '@angular/core';
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 {bootstrap} from '@angular/platform-browser-dynamic';

View File

@ -7,8 +7,7 @@
*/
import {beforeEach, beforeEachProviders, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal';
import {TestComponentBuilder} from '@angular/compiler/testing';
import {ComponentFixture} from '@angular/core/testing';
import {ComponentFixture, TestComponentBuilder} from '@angular/core/testing';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {Location} from '@angular/common';

View File

@ -7,9 +7,8 @@
*/
import {Location} from '@angular/common';
import {TestComponentBuilder} from '@angular/compiler/testing';
import {Component} from '@angular/core';
import {ComponentFixture} from '@angular/core/testing';
import {ComponentFixture, TestComponentBuilder} from '@angular/core/testing';
import {beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {By} from '@angular/platform-browser/src/dom/debug/by';

View File

@ -8,8 +8,7 @@
import {beforeEach, beforeEachProviders, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {TestComponentBuilder} from '@angular/compiler/testing';
import {ComponentFixture} from '@angular/core/testing';
import {ComponentFixture, TestComponentBuilder} from '@angular/core/testing';
import {specs, compile, TEST_ROUTER_PROVIDERS, clickOnElement, getHref} from '../util';
import {Location} from '@angular/common';

View File

@ -6,9 +6,8 @@
* found in the LICENSE file at https://angular.io/license
*/
import {TestComponentBuilder} from '@angular/compiler/testing';
import {Component, Inject, Injector, provide} from '@angular/core';
import {ComponentFixture} from '@angular/core/testing';
import {ComponentFixture, TestComponentBuilder} from '@angular/core/testing';
import {beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {RouteParams, Router, RouterLink, RouterOutlet} from '@angular/router-deprecated';

View File

@ -7,9 +7,8 @@
*/
import {Location} from '@angular/common';
import {TestComponentBuilder} from '@angular/compiler/testing';
import {Component, Inject, Injector, provide} from '@angular/core';
import {ComponentFixture} from '@angular/core/testing';
import {ComponentFixture, TestComponentBuilder} from '@angular/core/testing';
import {beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {RouteData, RouteParams, Router, RouterLink, RouterOutlet} from '@angular/router-deprecated';

View File

@ -7,8 +7,7 @@
*/
import {Location} from '@angular/common';
import {TestComponentBuilder} from '@angular/compiler/testing';
import {ComponentFixture} from '@angular/core/testing';
import {ComponentFixture, TestComponentBuilder} from '@angular/core/testing';
import {beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {RouteData, RouteParams, Router, RouterLink, RouterOutlet} from '@angular/router-deprecated';

View File

@ -8,8 +8,7 @@
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 {TestComponentBuilder} from '@angular/compiler/testing';
import {ComponentFixture} from '@angular/core/testing';
import {ComponentFixture, TestComponentBuilder} from '@angular/core/testing';
import {Location} from '@angular/common';
import {NumberWrapper, escapeRegExp} from '../../src/facade/lang';
import {PromiseWrapper} from '../../src/facade/async';

View File

@ -8,9 +8,8 @@
import {Location} from '@angular/common';
import {SpyLocation} from '@angular/common/testing';
import {TestComponentBuilder} from '@angular/compiler/testing';
import {Component, provide} from '@angular/core';
import {ComponentFixture} from '@angular/core/testing';
import {ComponentFixture, TestComponentBuilder} from '@angular/core/testing';
import {beforeEach, beforeEachProviders, ddescribe, describe, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal';
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
import {ROUTER_DIRECTIVES, ROUTER_PRIMARY_COMPONENT, Router} from '@angular/router-deprecated';

View File

@ -1,11 +1,13 @@
import 'rxjs/add/operator/map';
import {Location} from '@angular/common';
import {ComponentFixture, TestComponentBuilder} from '@angular/compiler/testing';
import {AppModule, AppModuleFactory, AppModuleFactoryLoader, Compiler, Component, Injectable} from '@angular/core';
import {beforeEach, beforeEachProviders, configureModule, describe, fakeAsync, inject, it, tick} from '@angular/core/testing';
import {ComponentFixture, TestComponentBuilder} from '@angular/core/testing';
import {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';
import {ActivatedRoute, ActivatedRouteSnapshot, CanActivate, CanDeactivate, Event, NavigationCancel, NavigationEnd, NavigationError, NavigationStart, Params, ROUTER_DIRECTIVES, Resolve, Router, RouterStateSnapshot, RoutesRecognized, provideRoutes} from '../index';
import {RouterTestModule, SpyAppModuleFactoryLoader} from '../testing';
@ -462,11 +464,13 @@ describe('Integration', () => {
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): number { return 6; }
}
beforeEachProviders(
() =>
[{provide: 'resolveTwo', useValue: (a: any, b: any) => 2},
{provide: 'resolveFour', useValue: (a: any, b: any) => 4},
{provide: 'resolveSix', useClass: ResolveSix}]);
beforeEach(() => {
addProviders([
{provide: 'resolveTwo', useValue: (a: any, b: any) => 2},
{provide: 'resolveFour', useValue: (a: any, b: any) => 4},
{provide: 'resolveSix', useClass: ResolveSix}
]);
});
it('should provide resolved data',
fakeAsync(inject(
@ -725,7 +729,9 @@ describe('Integration', () => {
describe('guards', () => {
describe('CanActivate', () => {
describe('should not activate a route when CanActivate returns false', () => {
beforeEachProviders(() => [{provide: 'alwaysFalse', useValue: (a: any, b: any) => false}]);
beforeEach(() => {
addProviders([{provide: 'alwaysFalse', useValue: (a: any, b: any) => false}]);
});
// handle errors
@ -748,8 +754,9 @@ describe('Integration', () => {
describe(
'should not activate a route when CanActivate returns false (componentless route)',
() => {
beforeEachProviders(
() => [{provide: 'alwaysFalse', useValue: (a: any, b: any) => false}]);
beforeEach(() => {
addProviders([{provide: 'alwaysFalse', useValue: (a: any, b: any) => false}]);
});
it('works', fakeAsync(inject(
[Router, TestComponentBuilder, Location],
@ -770,10 +777,12 @@ describe('Integration', () => {
});
describe('should activate a route when CanActivate returns true', () => {
beforeEachProviders(() => [{
provide: 'alwaysTrue',
useValue: (a: ActivatedRouteSnapshot, s: RouterStateSnapshot) => true
}]);
beforeEach(() => {
addProviders([{
provide: 'alwaysTrue',
useValue: (a: ActivatedRouteSnapshot, s: RouterStateSnapshot) => true
}]);
});
it('works',
fakeAsync(inject(
@ -798,7 +807,7 @@ describe('Integration', () => {
}
}
beforeEachProviders(() => [AlwaysTrue]);
beforeEach(() => { addProviders([AlwaysTrue]); });
it('works', fakeAsync(inject(
[Router, TestComponentBuilder, Location],
@ -816,12 +825,13 @@ describe('Integration', () => {
});
describe('should work when returns an observable', () => {
beforeEachProviders(() => [{
provide: 'CanActivate',
useValue: (a: ActivatedRouteSnapshot, b: RouterStateSnapshot) => {
return of (false);
}
}]);
beforeEach(() => {
addProviders([{
provide: 'CanActivate',
useValue: (a: ActivatedRouteSnapshot, b: RouterStateSnapshot) => { return of (false); }
}]);
});
it('works',
fakeAsync(inject(
@ -841,26 +851,28 @@ describe('Integration', () => {
describe('CanDeactivate', () => {
describe('should not deactivate a route when CanDeactivate returns false', () => {
beforeEachProviders(
() =>
[{
provide: 'CanDeactivateParent',
useValue: (c: any, a: ActivatedRouteSnapshot, b: RouterStateSnapshot) => {
return a.params['id'] === '22';
}
},
{
provide: 'CanDeactivateTeam',
useValue: (c: any, a: ActivatedRouteSnapshot, b: RouterStateSnapshot) => {
return c.route.snapshot.params['id'] === '22';
}
},
{
provide: 'CanDeactivateUser',
useValue: (c: any, a: ActivatedRouteSnapshot, b: RouterStateSnapshot) => {
return a.params['name'] === 'victor';
}
}]);
beforeEach(() => {
addProviders([
{
provide: 'CanDeactivateParent',
useValue: (c: any, a: ActivatedRouteSnapshot, b: RouterStateSnapshot) => {
return a.params['id'] === '22';
}
},
{
provide: 'CanDeactivateTeam',
useValue: (c: any, a: ActivatedRouteSnapshot, b: RouterStateSnapshot) => {
return c.route.snapshot.params['id'] === '22';
}
},
{
provide: 'CanDeactivateUser',
useValue: (c: any, a: ActivatedRouteSnapshot, b: RouterStateSnapshot) => {
return a.params['name'] === 'victor';
}
}
]);
});
it('works',
fakeAsync(inject(
@ -959,7 +971,7 @@ describe('Integration', () => {
}
}
beforeEachProviders(() => [AlwaysTrue]);
beforeEach(() => { addProviders([AlwaysTrue]); });
it('works',
fakeAsync(inject(
@ -982,11 +994,14 @@ describe('Integration', () => {
});
describe('should work when returns an observable', () => {
beforeEachProviders(() => [{
provide: 'CanDeactivate',
useValue: (c: TeamCmp, a: ActivatedRouteSnapshot,
b: RouterStateSnapshot) => { return of (false); }
}]);
beforeEach(() => {
addProviders([{
provide: 'CanDeactivate',
useValue: (c: TeamCmp, a: ActivatedRouteSnapshot, b: RouterStateSnapshot) => {
return of (false);
}
}]);
});
it('works',
fakeAsync(inject(
@ -1379,4 +1394,4 @@ function createRoot(tcb: TestComponentBuilder, router: Router, type: any): Compo
router.initialNavigation();
advance(f);
return f;
}
}

View File

@ -1,18 +1,9 @@
/** @stable */
export declare function addProviders(providers: Array<any>): void;
/** @deprecated */
export declare var afterEach: Function;
/** @stable */
export declare function async(fn: Function): (done: any) => any;
/** @deprecated */
export declare var beforeEach: any;
/** @deprecated */
export declare function beforeEachProviders(fn: () => Array<any>): void;
/** @stable */
export declare class ComponentFixture<T> {
changeDetectorRef: ChangeDetectorRef;
@ -52,36 +43,18 @@ export declare function configureModule(moduleDef: {
modules?: any[];
}): void;
/** @deprecated */
export declare var ddescribe: any;
/** @deprecated */
export declare var describe: Function;
/** @experimental */
export declare function discardPeriodicTasks(): void;
/** @deprecated */
export declare var expect: Function;
/** @experimental */
export declare function fakeAsync(fn: Function): (...args: any[]) => any;
/** @deprecated */
export declare var fdescribe: any;
/** @deprecated */
export declare var fit: any;
/** @experimental */
export declare function flushMicrotasks(): void;
/** @experimental */
export declare function getTestInjector(): TestInjector;
/** @deprecated */
export declare var iit: any;
/** @experimental */
export declare function initTestEnvironment(appModule: Type, platform: PlatformRef): void;
@ -100,9 +73,6 @@ export declare class InjectSetupWrapper {
inject(tokens: any[], fn: Function): () => any;
}
/** @deprecated */
export declare var it: any;
/** @deprecated */
export declare function resetBaseTestProviders(): void;
@ -169,9 +139,3 @@ export declare function withModule(moduleDef: () => {
/** @experimental */
export declare function withProviders(providers: () => any): InjectSetupWrapper;
/** @deprecated */
export declare var xdescribe: Function;
/** @deprecated */
export declare var xit: any;