build: add bazel test rules for remainder of packages (#21053)
PR Close #21053
This commit is contained in:
parent
cc1058f6e1
commit
3d50fd7cac
|
@ -1,6 +1,9 @@
|
|||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
exports_files(["tsconfig.json"])
|
||||
exports_files([
|
||||
"tsconfig.json",
|
||||
"node_modules/angular/angular.js",
|
||||
])
|
||||
|
||||
# This rule belongs in node_modules/BUILD
|
||||
# It's here as a workaround for
|
||||
|
|
|
@ -12,3 +12,7 @@ import {NoopAnimationsModule} from '@angular/platform-browser/animations';
|
|||
|
||||
TestBed.initTestEnvironment(
|
||||
[BrowserDynamicTestingModule, NoopAnimationsModule], platformBrowserDynamicTesting());
|
||||
|
||||
(window as any).isNode = false;
|
||||
(window as any).isBrowser = true;
|
||||
(window as any).global = window;
|
|
@ -32,6 +32,9 @@ jasmineCore.boot = function() {
|
|||
// 5) Patch jasmine ENV with code which understands ProxyZone.
|
||||
import 'zone.js/dist/jasmine-patch.js';
|
||||
|
||||
(global as any).isNode = true;
|
||||
(global as any).isBrowser = false;
|
||||
|
||||
// Init TestBed
|
||||
import {TestBed} from '@angular/core/testing';
|
||||
import {ServerTestingModule, platformServerTesting} from '@angular/platform-server/testing/src/server';
|
||||
|
|
|
@ -12,7 +12,7 @@ import {AnimationDriver} from '../../src/render/animation_driver';
|
|||
import {TimelineAnimationEngine} from '../../src/render/timeline_animation_engine';
|
||||
import {MockAnimationDriver, MockAnimationPlayer} from '../../testing/src/mock_animation_driver';
|
||||
|
||||
(function(){
|
||||
(function() {
|
||||
const defaultDriver = new MockAnimationDriver();
|
||||
|
||||
function makeEngine(driver?: AnimationDriver, normalizer?: AnimationStyleNormalizer) {
|
||||
|
|
|
@ -16,7 +16,7 @@ import {MockAnimationDriver, MockAnimationPlayer} from '../../testing/src/mock_a
|
|||
|
||||
const DEFAULT_NAMESPACE_ID = 'id';
|
||||
|
||||
(function(){
|
||||
(function() {
|
||||
const driver = new MockAnimationDriver();
|
||||
|
||||
// these tests are only mean't to be run within the DOM
|
||||
|
|
|
@ -10,7 +10,7 @@ import {AsyncTestCompleter, describe, expect, inject, it} from '@angular/core/te
|
|||
|
||||
import {Injector, Metric, MultiMetric} from '../../index';
|
||||
|
||||
(function(){
|
||||
(function() {
|
||||
function createMetric(ids: any[]) {
|
||||
const m = Injector
|
||||
.create([
|
||||
|
|
|
@ -12,7 +12,7 @@ import {AsyncTestCompleter, beforeEach, describe, expect, inject, it} from '@ang
|
|||
import {Injector, Metric, Options, PerfLogEvent, PerfLogFeatures, PerflogMetric, WebDriverExtension} from '../../index';
|
||||
import {TraceEventFactory} from '../trace_event_factory';
|
||||
|
||||
(function(){
|
||||
(function() {
|
||||
let commandLog: any[];
|
||||
const eventFactory = new TraceEventFactory('timeline', 'pid0');
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import {AsyncTestCompleter, describe, expect, inject, it} from '@angular/core/te
|
|||
|
||||
import {Options, PerfLogEvent, PerfLogFeatures, UserMetric, WebDriverAdapter} from '../../index';
|
||||
|
||||
(function(){
|
||||
(function() {
|
||||
let wdAdapter: MockDriverAdapter;
|
||||
|
||||
function createMetric(
|
||||
|
|
|
@ -10,7 +10,7 @@ import {AsyncTestCompleter, describe, expect, inject, it} from '@angular/core/te
|
|||
|
||||
import {Injector, MeasureValues, MultiReporter, Reporter} from '../../index';
|
||||
|
||||
(function(){
|
||||
(function() {
|
||||
function createReporters(ids: any[]) {
|
||||
const r = Injector
|
||||
.create([
|
||||
|
|
|
@ -10,7 +10,7 @@ import {AsyncTestCompleter, describe, expect, inject, it} from '@angular/core/te
|
|||
|
||||
import {Injector, Options, WebDriverExtension} from '../index';
|
||||
|
||||
(function(){
|
||||
(function() {
|
||||
function createExtension(ids: any[], caps: any) {
|
||||
return new Promise<any>((res, rej) => {
|
||||
try {
|
||||
|
|
|
@ -5,10 +5,12 @@ load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
|
|||
ts_library(
|
||||
name = "testing",
|
||||
testonly = 1,
|
||||
srcs = glob(["testing/**/*.ts"]),
|
||||
srcs = glob(["**/*.ts"]),
|
||||
module_name = "@angular/common/http/testing",
|
||||
tsconfig = "//packages:tsconfig",
|
||||
deps = [
|
||||
"//packages/common/http",
|
||||
"//packages/core",
|
||||
"@rxjs",
|
||||
],
|
||||
)
|
||||
|
|
|
@ -10,14 +10,14 @@ ts_library(
|
|||
),
|
||||
tsconfig = "//packages:tsconfig",
|
||||
deps = [
|
||||
"//packages/compiler",
|
||||
"//packages/common",
|
||||
"//packages/common/locales",
|
||||
"//packages/compiler",
|
||||
"//packages/core",
|
||||
"//packages/core/testing",
|
||||
"//packages/platform-browser",
|
||||
"//packages/platform-browser/testing",
|
||||
"//packages/platform-browser-dynamic",
|
||||
"//packages/platform-browser/testing",
|
||||
],
|
||||
)
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import {DeprecatedCurrencyPipe, DeprecatedDecimalPipe, DeprecatedPercentPipe} fr
|
|||
import {beforeEach, describe, expect, it} from '@angular/core/testing/src/testing_internal';
|
||||
import {browserDetection} from '@angular/platform-browser/testing/src/browser_util';
|
||||
|
||||
(function(){
|
||||
(function() {
|
||||
function isNumeric(value: any): boolean { return !isNaN(value - parseFloat(value)); }
|
||||
|
||||
// Between the symbol and the number, Edge adds a no breaking space and IE11 adds a standard space
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
import {describe, expect, it} from '../../../core/testing/src/testing_internal';
|
||||
import {CssLexer, CssLexerMode, CssToken, CssTokenType, cssScannerError, getRawMessage, getToken} from '../../src/css_parser/css_lexer';
|
||||
|
||||
(function(){
|
||||
(function() {
|
||||
function tokenize(
|
||||
code: string, trackComments: boolean = false,
|
||||
mode: CssLexerMode = CssLexerMode.ALL): CssToken[] {
|
||||
|
|
|
@ -115,7 +115,7 @@ function _getCaptureAst(capture: any[], index = 0): CssAst {
|
|||
return <CssAst>capture[index][0];
|
||||
}
|
||||
|
||||
(function(){
|
||||
(function() {
|
||||
function parse(cssCode: string, ignoreErrors: boolean = false) {
|
||||
const output = new CssParser().parse(cssCode, 'some-fake-css-file.css');
|
||||
const errors = output.errors;
|
||||
|
|
|
@ -15,7 +15,7 @@ import {expect} from '@angular/platform-browser/testing/src/matchers';
|
|||
import {unparse} from './unparser';
|
||||
import {validate} from './validator';
|
||||
|
||||
(function(){
|
||||
(function() {
|
||||
function createParser() { return new Parser(new Lexer()); }
|
||||
|
||||
function parseAction(text: string, location: any = null): ASTWithSource {
|
||||
|
|
|
@ -242,7 +242,7 @@ lignes</target>
|
|||
</xliff>
|
||||
`;
|
||||
|
||||
(function(){
|
||||
(function() {
|
||||
const serializer = new Xliff2();
|
||||
|
||||
function toXliff(html: string, locale: string | null = null): string {
|
||||
|
|
|
@ -226,7 +226,7 @@ lignes</target>
|
|||
</xliff>
|
||||
`;
|
||||
|
||||
(function(){
|
||||
(function() {
|
||||
const serializer = new Xliff();
|
||||
|
||||
function toXliff(html: string, locale: string | null = null): string {
|
||||
|
|
|
@ -323,7 +323,7 @@ class ArrayConsole implements Console {
|
|||
}
|
||||
|
||||
|
||||
(function(){
|
||||
(function() {
|
||||
let ngIf: CompileDirectiveSummary;
|
||||
let parse: (
|
||||
template: string, directives: CompileDirectiveSummary[], pipes?: CompilePipeSummary[],
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
import {AfterContentChecked, AfterContentInit, AfterViewChecked, AfterViewInit, Component, DoCheck, Input, OnChanges, OnDestroy, OnInit, SimpleChanges, Type} from '@angular/core';
|
||||
import {TestBed} from '@angular/core/testing';
|
||||
|
||||
(function(){
|
||||
(function() {
|
||||
describe('lifecycle hooks examples', () => {
|
||||
it('should work with ngOnInit', () => {
|
||||
// #docregion OnInit
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load("@angular//:index.bzl", "ng_module")
|
||||
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
|
||||
|
||||
ng_module(
|
||||
name = "forms",
|
||||
srcs = glob(
|
||||
[
|
||||
"*.ts",
|
||||
"src/**/*.ts",
|
||||
],
|
||||
),
|
||||
module_name = "@angular/forms",
|
||||
tsconfig = "//packages:tsconfig",
|
||||
deps = [
|
||||
"//packages/core",
|
||||
"//packages/platform-browser",
|
||||
"@rxjs",
|
||||
],
|
||||
)
|
|
@ -0,0 +1,38 @@
|
|||
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library", "ts_web_test")
|
||||
load("@build_bazel_rules_nodejs//:defs.bzl", "jasmine_node_test")
|
||||
|
||||
ts_library(
|
||||
name = "test_lib",
|
||||
testonly = 1,
|
||||
srcs = glob(["**/*.ts"]),
|
||||
tsconfig = "//packages:tsconfig",
|
||||
deps = [
|
||||
"//packages/core",
|
||||
"//packages/core/testing",
|
||||
"//packages/forms",
|
||||
"//packages/platform-browser",
|
||||
"//packages/platform-browser/testing",
|
||||
"@rxjs",
|
||||
],
|
||||
)
|
||||
|
||||
jasmine_node_test(
|
||||
name = "test",
|
||||
bootstrap = ["angular_src/packages/_testing_init/init_node_spec.js"],
|
||||
deps = [
|
||||
":test_lib",
|
||||
"//packages/_testing_init:node",
|
||||
],
|
||||
)
|
||||
|
||||
ts_web_test(
|
||||
name = "test_web",
|
||||
bootstrap = [
|
||||
"//:angular_bootstrap_scripts",
|
||||
],
|
||||
# do not sort
|
||||
deps = [
|
||||
"//packages/_testing_init:browser",
|
||||
":test_lib",
|
||||
],
|
||||
)
|
|
@ -10,7 +10,7 @@ import {SimpleChange} from '@angular/core';
|
|||
import {fakeAsync, flushMicrotasks, tick} from '@angular/core/testing';
|
||||
import {beforeEach, describe, expect, it} from '@angular/core/testing/src/testing_internal';
|
||||
import {AbstractControl, CheckboxControlValueAccessor, ControlValueAccessor, DefaultValueAccessor, FormArray, FormArrayName, FormControl, FormControlDirective, FormControlName, FormGroup, FormGroupDirective, FormGroupName, NgControl, NgForm, NgModel, NgModelGroup, SelectControlValueAccessor, SelectMultipleControlValueAccessor, ValidationErrors, Validator, Validators} from '@angular/forms';
|
||||
import {composeValidators, selectValueAccessor} from '../src/directives/shared';
|
||||
import {composeValidators, selectValueAccessor} from '@angular/forms/src/directives/shared';
|
||||
import {SpyNgControl, SpyValueAccessor} from './spies';
|
||||
|
||||
class DummyControlValueAccessor implements ControlValueAccessor {
|
||||
|
|
|
@ -9,10 +9,10 @@
|
|||
import {fakeAsync, tick} from '@angular/core/testing';
|
||||
import {AsyncTestCompleter, beforeEach, describe, inject, it} from '@angular/core/testing/src/testing_internal';
|
||||
import {AbstractControl, FormArray, FormControl, FormGroup, ValidationErrors} from '@angular/forms';
|
||||
import {Validators} from '@angular/forms/src/validators';
|
||||
import {of } from 'rxjs/observable/of';
|
||||
import {Validators} from '../src/validators';
|
||||
|
||||
(function(){
|
||||
(function() {
|
||||
function asyncValidator(expected: string, timeouts = {}) {
|
||||
return (c: AbstractControl) => {
|
||||
let resolve: (result: any) => void = undefined !;
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
import {beforeEach, describe, expect, it} from '@angular/core/testing/src/testing_internal';
|
||||
import {FormBuilder} from '@angular/forms';
|
||||
|
||||
(function(){
|
||||
(function() {
|
||||
function syncValidator(_: any /** TODO #9100 */): any /** TODO #9100 */ { return null; }
|
||||
function asyncValidator(_: any /** TODO #9100 */) { return Promise.resolve(null); }
|
||||
|
||||
|
|
|
@ -11,9 +11,9 @@ import {fakeAsync, tick} from '@angular/core/testing';
|
|||
import {AsyncTestCompleter, beforeEach, describe, inject, it} from '@angular/core/testing/src/testing_internal';
|
||||
import {FormControl, FormGroup, Validators} from '@angular/forms';
|
||||
|
||||
import {FormArray} from '../src/model';
|
||||
import {FormArray} from '@angular/forms/src/model';
|
||||
|
||||
(function(){
|
||||
(function() {
|
||||
function asyncValidator(expected: string, timeouts = {}) {
|
||||
return (c: FormControl) => {
|
||||
let resolve: (result: any) => void = undefined !;
|
||||
|
|
|
@ -13,7 +13,7 @@ import {AbstractControl, FormArray, FormControl, FormGroup, ValidationErrors, Va
|
|||
import {of } from 'rxjs/observable/of';
|
||||
|
||||
|
||||
(function(){
|
||||
(function() {
|
||||
function simpleValidator(c: AbstractControl): ValidationErrors|null {
|
||||
return c.get('one') !.value === 'correct' ? null : {'broken': true};
|
||||
}
|
||||
|
@ -1070,12 +1070,12 @@ import {of } from 'rxjs/observable/of';
|
|||
});
|
||||
|
||||
it('should update tree validity', () => {
|
||||
form._updateTreeValidity();
|
||||
(form as any)._updateTreeValidity();
|
||||
expect(logger).toEqual(['one', 'two', 'nested', 'three', 'form']);
|
||||
});
|
||||
|
||||
it('should not emit events when turned off', () => {
|
||||
form._updateTreeValidity({emitEvent: false});
|
||||
(form as any)._updateTreeValidity({emitEvent: false});
|
||||
expect(logger).toEqual([]);
|
||||
});
|
||||
|
||||
|
|
|
@ -1560,6 +1560,7 @@ import {MyInput, MyInputForm} from './value_accessor_integration_spec';
|
|||
}));
|
||||
|
||||
it('should not update the view when the value initially came from the view', fakeAsync(() => {
|
||||
if (isNode) return;
|
||||
const fixture = initTest(FormControlNgModel);
|
||||
fixture.componentInstance.control = new FormControl('');
|
||||
fixture.detectChanges();
|
||||
|
|
|
@ -295,7 +295,7 @@ import {NgModelCustomComp, NgModelCustomWrapper} from './value_accessor_integrat
|
|||
|
||||
const form = fixture.debugElement.children[0].injector.get(NgForm);
|
||||
const name = form.control.get('name') as FormControl;
|
||||
expect(name._updateOn).toBeUndefined();
|
||||
expect((name as any)._updateOn).toBeUndefined();
|
||||
expect(name.updateOn).toEqual('change');
|
||||
}));
|
||||
|
||||
|
@ -309,7 +309,7 @@ import {NgModelCustomComp, NgModelCustomWrapper} from './value_accessor_integrat
|
|||
|
||||
const form = fixture.debugElement.children[0].injector.get(NgForm);
|
||||
const name = form.control.get('name') as FormControl;
|
||||
expect(name._updateOn).toEqual('blur');
|
||||
expect((name as any)._updateOn).toEqual('blur');
|
||||
expect(name.updateOn).toEqual('blur');
|
||||
}));
|
||||
|
||||
|
@ -555,7 +555,7 @@ import {NgModelCustomComp, NgModelCustomWrapper} from './value_accessor_integrat
|
|||
|
||||
const form = fixture.debugElement.children[0].injector.get(NgForm);
|
||||
const name = form.control.get('name') as FormControl;
|
||||
expect(name._updateOn).toEqual('submit');
|
||||
expect((name as any)._updateOn).toEqual('submit');
|
||||
expect(name.updateOn).toEqual('submit');
|
||||
}));
|
||||
|
||||
|
@ -891,12 +891,12 @@ import {NgModelCustomComp, NgModelCustomWrapper} from './value_accessor_integrat
|
|||
|
||||
const form = fixture.debugElement.children[0].injector.get(NgForm);
|
||||
const controlOne = form.control.get('one') !as FormControl;
|
||||
expect(controlOne._updateOn).toBeUndefined();
|
||||
expect((controlOne as any)._updateOn).toBeUndefined();
|
||||
expect(controlOne.updateOn)
|
||||
.toEqual('blur', 'Expected first control to inherit updateOn from parent form.');
|
||||
|
||||
const controlTwo = form.control.get('two') !as FormControl;
|
||||
expect(controlTwo._updateOn).toBeUndefined();
|
||||
expect((controlTwo as any)._updateOn).toBeUndefined();
|
||||
expect(controlTwo.updateOn)
|
||||
.toEqual('blur', 'Expected last control to inherit updateOn from parent form.');
|
||||
}));
|
||||
|
@ -932,12 +932,13 @@ import {NgModelCustomComp, NgModelCustomWrapper} from './value_accessor_integrat
|
|||
|
||||
const form = fixture.debugElement.children[0].injector.get(NgForm);
|
||||
const controlOne = form.control.get('one') !as FormControl;
|
||||
expect(controlOne._updateOn).toBeUndefined();
|
||||
expect((controlOne as any)._updateOn).toBeUndefined();
|
||||
expect(controlOne.updateOn)
|
||||
.toEqual('change', 'Expected control updateOn to inherit form updateOn.');
|
||||
|
||||
const controlTwo = form.control.get('two') !as FormControl;
|
||||
expect(controlTwo._updateOn).toEqual('blur', 'Expected control to set blur override.');
|
||||
expect((controlTwo as any)._updateOn)
|
||||
.toEqual('blur', 'Expected control to set blur override.');
|
||||
expect(controlTwo.updateOn)
|
||||
.toEqual('blur', 'Expected control updateOn to override form updateOn.');
|
||||
}));
|
||||
|
|
|
@ -9,15 +9,15 @@
|
|||
import {fakeAsync, tick} from '@angular/core/testing';
|
||||
import {describe, expect, it} from '@angular/core/testing/src/testing_internal';
|
||||
import {AbstractControl, AsyncValidatorFn, FormArray, FormControl, Validators} from '@angular/forms';
|
||||
import {normalizeAsyncValidator} from '@angular/forms/src/directives/normalize_validator';
|
||||
import {AsyncValidator, ValidationErrors, ValidatorFn} from '@angular/forms/src/directives/validators';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import {of } from 'rxjs/observable/of';
|
||||
import {timer} from 'rxjs/observable/timer';
|
||||
import {first} from 'rxjs/operator/first';
|
||||
import {map} from 'rxjs/operator/map';
|
||||
import {normalizeAsyncValidator} from '../src/directives/normalize_validator';
|
||||
import {AsyncValidator, ValidationErrors, ValidatorFn} from '../src/directives/validators';
|
||||
|
||||
(function(){
|
||||
(function() {
|
||||
function validator(key: string, error: any): ValidatorFn {
|
||||
return (c: AbstractControl) => {
|
||||
const r: ValidationErrors = {};
|
||||
|
|
|
@ -164,6 +164,7 @@ import {dispatchEvent} from '@angular/platform-browser/testing/src/browser_util'
|
|||
describe('in reactive forms', () => {
|
||||
|
||||
it(`should support primitive values`, () => {
|
||||
if (isNode) return;
|
||||
const fixture = initTest(FormControlNameSelect);
|
||||
fixture.detectChanges();
|
||||
|
||||
|
@ -183,6 +184,7 @@ import {dispatchEvent} from '@angular/platform-browser/testing/src/browser_util'
|
|||
});
|
||||
|
||||
it(`should support objects`, () => {
|
||||
if (isNode) return;
|
||||
const fixture = initTest(FormControlSelectNgValue);
|
||||
fixture.detectChanges();
|
||||
|
||||
|
@ -201,6 +203,7 @@ import {dispatchEvent} from '@angular/platform-browser/testing/src/browser_util'
|
|||
});
|
||||
|
||||
it('should compare options using provided compareWith function', () => {
|
||||
if (isNode) return;
|
||||
const fixture = initTest(FormControlSelectWithCompareFn);
|
||||
fixture.detectChanges();
|
||||
|
||||
|
@ -211,6 +214,7 @@ import {dispatchEvent} from '@angular/platform-browser/testing/src/browser_util'
|
|||
});
|
||||
|
||||
it('should support re-assigning the options array with compareWith', () => {
|
||||
if (isNode) return;
|
||||
const fixture = initTest(FormControlSelectWithCompareFn);
|
||||
fixture.detectChanges();
|
||||
|
||||
|
@ -239,6 +243,7 @@ import {dispatchEvent} from '@angular/platform-browser/testing/src/browser_util'
|
|||
|
||||
describe('in template-driven forms', () => {
|
||||
it('with option values that are objects', fakeAsync(() => {
|
||||
if (isNode) return;
|
||||
const fixture = initTest(NgModelSelectForm);
|
||||
const comp = fixture.componentInstance;
|
||||
comp.cities = [{'name': 'SF'}, {'name': 'NYC'}, {'name': 'Buffalo'}];
|
||||
|
@ -263,6 +268,7 @@ import {dispatchEvent} from '@angular/platform-browser/testing/src/browser_util'
|
|||
}));
|
||||
|
||||
it('when new options are added', fakeAsync(() => {
|
||||
if (isNode) return;
|
||||
const fixture = initTest(NgModelSelectForm);
|
||||
const comp = fixture.componentInstance;
|
||||
comp.cities = [{'name': 'SF'}, {'name': 'NYC'}];
|
||||
|
@ -300,6 +306,7 @@ import {dispatchEvent} from '@angular/platform-browser/testing/src/browser_util'
|
|||
}));
|
||||
|
||||
it('when option values have same content, but different identities', fakeAsync(() => {
|
||||
if (isNode) return;
|
||||
const fixture = initTest(NgModelSelectForm);
|
||||
const comp = fixture.componentInstance;
|
||||
comp.cities = [{'name': 'SF'}, {'name': 'NYC'}, {'name': 'NYC'}];
|
||||
|
@ -347,6 +354,7 @@ import {dispatchEvent} from '@angular/platform-browser/testing/src/browser_util'
|
|||
});
|
||||
|
||||
it('should compare options using provided compareWith function', fakeAsync(() => {
|
||||
if (isNode) return;
|
||||
const fixture = initTest(NgModelSelectWithCustomCompareFnForm);
|
||||
const comp = fixture.componentInstance;
|
||||
comp.selectedCity = {id: 1, name: 'SF'};
|
||||
|
@ -361,6 +369,7 @@ import {dispatchEvent} from '@angular/platform-browser/testing/src/browser_util'
|
|||
}));
|
||||
|
||||
it('should support re-assigning the options array with compareWith', fakeAsync(() => {
|
||||
if (isNode) return;
|
||||
const fixture = initTest(NgModelSelectWithCustomCompareFnForm);
|
||||
fixture.componentInstance.selectedCity = {id: 1, name: 'SF'};
|
||||
fixture.componentInstance.cities = [{id: 1, name: 'SF'}, {id: 2, name: 'NY'}];
|
||||
|
@ -400,6 +409,7 @@ import {dispatchEvent} from '@angular/platform-browser/testing/src/browser_util'
|
|||
describe('in reactive forms', () => {
|
||||
|
||||
it('should support primitive values', () => {
|
||||
if (isNode) return;
|
||||
const fixture = initTest(FormControlSelectMultiple);
|
||||
fixture.detectChanges();
|
||||
|
||||
|
@ -410,6 +420,7 @@ import {dispatchEvent} from '@angular/platform-browser/testing/src/browser_util'
|
|||
});
|
||||
|
||||
it('should support objects', () => {
|
||||
if (isNode) return;
|
||||
const fixture = initTest(FormControlSelectMultipleNgValue);
|
||||
fixture.detectChanges();
|
||||
|
||||
|
@ -427,6 +438,7 @@ import {dispatchEvent} from '@angular/platform-browser/testing/src/browser_util'
|
|||
});
|
||||
|
||||
it('should compare options using provided compareWith function', fakeAsync(() => {
|
||||
if (isNode) return;
|
||||
const fixture = initTest(FormControlSelectMultipleWithCompareFn);
|
||||
fixture.detectChanges();
|
||||
tick();
|
||||
|
@ -478,6 +490,7 @@ import {dispatchEvent} from '@angular/platform-browser/testing/src/browser_util'
|
|||
|
||||
it('should reflect state of model after option selected and new options subsequently added',
|
||||
fakeAsync(() => {
|
||||
if (isNode) return;
|
||||
setSelectedCities([]);
|
||||
|
||||
selectOptionViaUI('1: Object');
|
||||
|
@ -491,6 +504,7 @@ import {dispatchEvent} from '@angular/platform-browser/testing/src/browser_util'
|
|||
|
||||
it('should reflect state of model after option selected and then other options removed',
|
||||
fakeAsync(() => {
|
||||
if (isNode) return;
|
||||
setSelectedCities([]);
|
||||
|
||||
selectOptionViaUI('1: Object');
|
||||
|
@ -512,6 +526,7 @@ import {dispatchEvent} from '@angular/platform-browser/testing/src/browser_util'
|
|||
});
|
||||
|
||||
it('should compare options using provided compareWith function', fakeAsync(() => {
|
||||
if (isNode) return;
|
||||
const fixture = initTest(NgModelSelectMultipleWithCustomCompareFnForm);
|
||||
const comp = fixture.componentInstance;
|
||||
comp.cities = [{id: 1, name: 'SF'}, {id: 2, name: 'LA'}];
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library", "ts_web_test")
|
||||
load("@build_bazel_rules_nodejs//:defs.bzl", "jasmine_node_test")
|
||||
|
||||
ts_library(
|
||||
name = "test_lib",
|
||||
testonly = 1,
|
||||
srcs = glob(["**/*.ts"]),
|
||||
tsconfig = "//packages:tsconfig",
|
||||
deps = [
|
||||
"//packages/core",
|
||||
"//packages/core/testing",
|
||||
"//packages/http",
|
||||
"//packages/http/testing",
|
||||
"//packages/platform-browser",
|
||||
"//packages/platform-browser/testing",
|
||||
"@rxjs",
|
||||
],
|
||||
)
|
||||
|
||||
jasmine_node_test(
|
||||
name = "test",
|
||||
bootstrap = ["angular_src/packages/_testing_init/init_node_spec.js"],
|
||||
deps = [
|
||||
":test_lib",
|
||||
"//packages/_testing_init:node",
|
||||
],
|
||||
)
|
||||
|
||||
ts_web_test(
|
||||
name = "test_web",
|
||||
bootstrap = [
|
||||
"//:angular_bootstrap_scripts",
|
||||
],
|
||||
# do not sort
|
||||
deps = [
|
||||
"//packages/_testing_init:browser",
|
||||
":test_lib",
|
||||
],
|
||||
)
|
|
@ -8,13 +8,14 @@
|
|||
|
||||
import {Injector} from '@angular/core';
|
||||
import {AsyncTestCompleter, SpyObject, afterEach, beforeEach, describe, inject, it} from '@angular/core/testing/src/testing_internal';
|
||||
import {BrowserJsonp} from '@angular/http/src/backends/browser_jsonp';
|
||||
import {JSONPBackend, JSONPConnection} from '@angular/http/src/backends/jsonp_backend';
|
||||
import {BaseRequestOptions, RequestOptions} from '@angular/http/src/base_request_options';
|
||||
import {BaseResponseOptions, ResponseOptions} from '@angular/http/src/base_response_options';
|
||||
import {ReadyState, RequestMethod, ResponseType} from '@angular/http/src/enums';
|
||||
import {Request} from '@angular/http/src/static_request';
|
||||
import {Response} from '@angular/http/src/static_response';
|
||||
import {expect} from '@angular/platform-browser/testing/src/matchers';
|
||||
import {BrowserJsonp} from '../../src/backends/browser_jsonp';
|
||||
import {JSONPBackend, JSONPConnection} from '../../src/backends/jsonp_backend';
|
||||
import {BaseRequestOptions, RequestOptions} from '../../src/base_request_options';
|
||||
import {BaseResponseOptions, ResponseOptions} from '../../src/base_response_options';
|
||||
import {ReadyState, RequestMethod, ResponseType} from '../../src/enums';
|
||||
import {Request} from '../../src/static_request';
|
||||
|
||||
let existingScripts: MockBrowserJsonp[] = [];
|
||||
|
||||
|
@ -75,10 +76,10 @@ class MockBrowserJsonp extends BrowserJsonp {
|
|||
describe('JSONPConnection', () => {
|
||||
it('should use the injected BaseResponseOptions to create the response',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
const connection = new JSONPConnection(
|
||||
const connection = new (JSONPConnection as any)(
|
||||
sampleRequest, new MockBrowserJsonp(),
|
||||
new ResponseOptions({type: ResponseType.Error}));
|
||||
connection.response.subscribe(res => {
|
||||
connection.response.subscribe((res: Response) => {
|
||||
expect(res.type).toBe(ResponseType.Error);
|
||||
async.done();
|
||||
});
|
||||
|
@ -88,7 +89,7 @@ class MockBrowserJsonp extends BrowserJsonp {
|
|||
|
||||
it('should ignore load/callback when disposed',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
const connection = new JSONPConnection(sampleRequest, new MockBrowserJsonp());
|
||||
const connection = new (JSONPConnection as any)(sampleRequest, new MockBrowserJsonp());
|
||||
const spy = new SpyObject();
|
||||
const loadSpy = spy.spy('load');
|
||||
const errorSpy = spy.spy('error');
|
||||
|
@ -111,13 +112,13 @@ class MockBrowserJsonp extends BrowserJsonp {
|
|||
|
||||
it('should report error if loaded without invoking callback',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
const connection = new JSONPConnection(sampleRequest, new MockBrowserJsonp());
|
||||
const connection = new (JSONPConnection as any)(sampleRequest, new MockBrowserJsonp());
|
||||
connection.response.subscribe(
|
||||
res => {
|
||||
(res: Response) => {
|
||||
expect('response listener called').toBe(false);
|
||||
async.done();
|
||||
},
|
||||
err => {
|
||||
(err: Response) => {
|
||||
expect(err.text()).toEqual('JSONP injected script did not invoke callback.');
|
||||
async.done();
|
||||
});
|
||||
|
@ -127,14 +128,14 @@ class MockBrowserJsonp extends BrowserJsonp {
|
|||
|
||||
it('should report error if script contains error',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
const connection = new JSONPConnection(sampleRequest, new MockBrowserJsonp());
|
||||
const connection = new (JSONPConnection as any)(sampleRequest, new MockBrowserJsonp());
|
||||
|
||||
connection.response.subscribe(
|
||||
res => {
|
||||
(res: Response) => {
|
||||
expect('response listener called').toBe(false);
|
||||
async.done();
|
||||
},
|
||||
err => {
|
||||
(err: Response) => {
|
||||
expect(err.text()).toBe('Oops!');
|
||||
async.done();
|
||||
});
|
||||
|
@ -149,16 +150,18 @@ class MockBrowserJsonp extends BrowserJsonp {
|
|||
const base = new BaseRequestOptions();
|
||||
const req = new Request(base.merge(
|
||||
new RequestOptions({url: 'https://google.com', method: method})) as any);
|
||||
expect(() => new JSONPConnection(req, new MockBrowserJsonp()).response.subscribe())
|
||||
expect(
|
||||
() => new (JSONPConnection as any)(req, new MockBrowserJsonp())
|
||||
.response.subscribe())
|
||||
.toThrowError();
|
||||
});
|
||||
});
|
||||
|
||||
it('should respond with data passed to callback',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
const connection = new JSONPConnection(sampleRequest, new MockBrowserJsonp());
|
||||
const connection = new (JSONPConnection as any)(sampleRequest, new MockBrowserJsonp());
|
||||
|
||||
connection.response.subscribe(res => {
|
||||
connection.response.subscribe((res: Response) => {
|
||||
expect(res.json()).toEqual(({fake_payload: true, blob_id: 12345}));
|
||||
async.done();
|
||||
});
|
||||
|
|
|
@ -8,15 +8,14 @@
|
|||
|
||||
import {Injector} from '@angular/core';
|
||||
import {AsyncTestCompleter, beforeEach, describe, inject, it, xit} from '@angular/core/testing/src/testing_internal';
|
||||
import {BaseRequestOptions, RequestOptions} from '@angular/http/src/base_request_options';
|
||||
import {BaseResponseOptions, ResponseOptions} from '@angular/http/src/base_response_options';
|
||||
import {Request} from '@angular/http/src/static_request';
|
||||
import {Response} from '@angular/http/src/static_response';
|
||||
import {MockBackend, MockConnection} from '@angular/http/testing/src/mock_backend';
|
||||
import {expect} from '@angular/platform-browser/testing/src/matchers';
|
||||
import {ReplaySubject} from 'rxjs/ReplaySubject';
|
||||
|
||||
import {BaseRequestOptions, RequestOptions} from '../../src/base_request_options';
|
||||
import {BaseResponseOptions, ResponseOptions} from '../../src/base_response_options';
|
||||
import {Request} from '../../src/static_request';
|
||||
import {Response} from '../../src/static_response';
|
||||
import {MockBackend, MockConnection} from '../../testing/src/mock_backend';
|
||||
|
||||
{
|
||||
describe('MockBackend', () => {
|
||||
|
||||
|
|
|
@ -8,17 +8,17 @@
|
|||
|
||||
import {Injectable} from '@angular/core';
|
||||
import {AsyncTestCompleter, SpyObject, afterEach, beforeEach, beforeEachProviders, describe, expect, inject, it} from '@angular/core/testing/src/testing_internal';
|
||||
import {BrowserXhr} from '@angular/http/src/backends/browser_xhr';
|
||||
import {CookieXSRFStrategy, XHRBackend, XHRConnection} from '@angular/http/src/backends/xhr_backend';
|
||||
import {BaseRequestOptions, RequestOptions} from '@angular/http/src/base_request_options';
|
||||
import {BaseResponseOptions, ResponseOptions} from '@angular/http/src/base_response_options';
|
||||
import {ResponseContentType, ResponseType} from '@angular/http/src/enums';
|
||||
import {Headers} from '@angular/http/src/headers';
|
||||
import {XSRFStrategy} from '@angular/http/src/interfaces';
|
||||
import {Request} from '@angular/http/src/static_request';
|
||||
import {Response} from '@angular/http/src/static_response';
|
||||
import {URLSearchParams} from '@angular/http/src/url_search_params';
|
||||
import {ɵgetDOM as getDOM} from '@angular/platform-browser';
|
||||
import {BrowserXhr} from '../../src/backends/browser_xhr';
|
||||
import {CookieXSRFStrategy, XHRBackend, XHRConnection} from '../../src/backends/xhr_backend';
|
||||
import {BaseRequestOptions, RequestOptions} from '../../src/base_request_options';
|
||||
import {BaseResponseOptions, ResponseOptions} from '../../src/base_response_options';
|
||||
import {ResponseContentType, ResponseType} from '../../src/enums';
|
||||
import {Headers} from '../../src/headers';
|
||||
import {XSRFStrategy} from '../../src/interfaces';
|
||||
import {Request} from '../../src/static_request';
|
||||
import {Response} from '../../src/static_response';
|
||||
import {URLSearchParams} from '../../src/url_search_params';
|
||||
|
||||
let abortSpy: any;
|
||||
let sendSpy: any;
|
||||
|
@ -422,7 +422,7 @@ class MockBrowserXHR extends BrowserXhr {
|
|||
(res: Response) => {
|
||||
|
||||
},
|
||||
errRes => {
|
||||
(errRes: Response) => {
|
||||
expect(errRes.status).toBe(statusCode);
|
||||
async.done();
|
||||
});
|
||||
|
@ -444,7 +444,7 @@ class MockBrowserXHR extends BrowserXhr {
|
|||
nextCalled = true;
|
||||
expect(res.status).toBe(statusCode);
|
||||
},
|
||||
errRes => { errorCalled = true; },
|
||||
(errRes: Response) => { errorCalled = true; },
|
||||
() => {
|
||||
expect(nextCalled).toBe(true);
|
||||
expect(errorCalled).toBe(false);
|
||||
|
@ -461,7 +461,7 @@ class MockBrowserXHR extends BrowserXhr {
|
|||
const connection = new XHRConnection(
|
||||
sampleRequest, new MockBrowserXHR(), new ResponseOptions({status: statusCode}));
|
||||
|
||||
connection.response.subscribe(res => {
|
||||
connection.response.subscribe((res: Response) => {
|
||||
expect(res.ok).toBe(true);
|
||||
async.done();
|
||||
});
|
||||
|
@ -477,8 +477,8 @@ class MockBrowserXHR extends BrowserXhr {
|
|||
sampleRequest, new MockBrowserXHR(), new ResponseOptions({status: statusCode}));
|
||||
|
||||
connection.response.subscribe(
|
||||
res => { throw 'should not be called'; },
|
||||
errRes => {
|
||||
(res: Response) => { throw 'should not be called'; },
|
||||
(errRes: Response) => {
|
||||
expect(errRes.ok).toBe(false);
|
||||
async.done();
|
||||
});
|
||||
|
@ -497,7 +497,7 @@ class MockBrowserXHR extends BrowserXhr {
|
|||
|
||||
connection.response.subscribe(
|
||||
(res: Response) => { nextCalled = true; },
|
||||
errRes => {
|
||||
(errRes: Response) => {
|
||||
expect(errRes.status).toBe(statusCode);
|
||||
expect(nextCalled).toBe(false);
|
||||
async.done();
|
||||
|
@ -553,8 +553,8 @@ class MockBrowserXHR extends BrowserXhr {
|
|||
connection1.response.subscribe((res: Response) => {
|
||||
expect(res.text()).toBe(responseBody);
|
||||
|
||||
connection2.response.subscribe(ress => {
|
||||
expect(ress.text()).toBe(responseBody);
|
||||
connection2.response.subscribe((res: Response) => {
|
||||
expect(res.text()).toBe(responseBody);
|
||||
async.done();
|
||||
});
|
||||
existingXHRs[1].setStatusCode(200);
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
*/
|
||||
|
||||
import {describe, expect, it} from '@angular/core/testing/src/testing_internal';
|
||||
import {BaseRequestOptions, RequestOptions} from '../src/base_request_options';
|
||||
import {RequestMethod} from '../src/enums';
|
||||
import {Headers} from '../src/headers';
|
||||
import {BaseRequestOptions, RequestOptions} from '@angular/http/src/base_request_options';
|
||||
import {RequestMethod} from '@angular/http/src/enums';
|
||||
import {Headers} from '@angular/http/src/headers';
|
||||
|
||||
{
|
||||
describe('BaseRequestOptions', () => {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Headers} from '../src/headers';
|
||||
import {Headers} from '@angular/http/src/headers';
|
||||
|
||||
{
|
||||
describe('Headers', () => {
|
||||
|
|
|
@ -9,12 +9,12 @@
|
|||
import {Injector} from '@angular/core';
|
||||
import {TestBed, getTestBed} from '@angular/core/testing';
|
||||
import {AsyncTestCompleter, afterEach, beforeEach, describe, inject, it} from '@angular/core/testing/src/testing_internal';
|
||||
import {stringToArrayBuffer} from '@angular/http/src/http_utils';
|
||||
import {expect} from '@angular/platform-browser/testing/src/matchers';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import {zip} from 'rxjs/observable/zip';
|
||||
|
||||
import {BaseRequestOptions, ConnectionBackend, Http, HttpModule, JSONPBackend, Jsonp, JsonpModule, Request, RequestMethod, RequestOptions, Response, ResponseContentType, ResponseOptions, URLSearchParams, XHRBackend} from '../index';
|
||||
import {stringToArrayBuffer} from '../src/http_utils';
|
||||
import {MockBackend, MockConnection} from '../testing/src/mock_backend';
|
||||
|
||||
{
|
||||
|
|
|
@ -7,14 +7,13 @@
|
|||
*/
|
||||
|
||||
import {describe, expect, it} from '@angular/core/testing/src/testing_internal';
|
||||
import {RequestOptions} from '@angular/http/src/base_request_options';
|
||||
import {ContentType} from '@angular/http/src/enums';
|
||||
import {Headers} from '@angular/http/src/headers';
|
||||
import {stringToArrayBuffer, stringToArrayBuffer8} from '@angular/http/src/http_utils';
|
||||
import {ArrayBuffer, Request} from '@angular/http/src/static_request';
|
||||
import {ɵgetDOM as getDOM} from '@angular/platform-browser';
|
||||
|
||||
import {RequestOptions} from '../src/base_request_options';
|
||||
import {ContentType} from '../src/enums';
|
||||
import {Headers} from '../src/headers';
|
||||
import {stringToArrayBuffer, stringToArrayBuffer8} from '../src/http_utils';
|
||||
import {ArrayBuffer, Request} from '../src/static_request';
|
||||
|
||||
{
|
||||
describe('Request', () => {
|
||||
describe('detectContentType', () => {
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
|
||||
import {describe, expect, it} from '@angular/core/testing/src/testing_internal';
|
||||
|
||||
import {ResponseOptions} from '../src/base_response_options';
|
||||
import {Response} from '../src/static_response';
|
||||
import {ResponseOptions} from '@angular/http/src/base_response_options';
|
||||
import {Response} from '@angular/http/src/static_response';
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
import {describe, expect, it} from '@angular/core/testing/src/testing_internal';
|
||||
import {URLSearchParams} from '../src/url_search_params';
|
||||
import {URLSearchParams} from '@angular/http/src/url_search_params';
|
||||
|
||||
{
|
||||
describe('URLSearchParams', () => {
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
|
||||
|
||||
ts_library(
|
||||
name = "language-service",
|
||||
srcs = glob(
|
||||
[
|
||||
"*.ts",
|
||||
"src/**/*.ts",
|
||||
],
|
||||
),
|
||||
module_name = "@angular/language-service",
|
||||
tsconfig = "//packages:tsconfig",
|
||||
deps = [
|
||||
"//packages:types",
|
||||
"//packages/compiler",
|
||||
"//packages/compiler-cli",
|
||||
"//packages/core",
|
||||
],
|
||||
)
|
|
@ -72,7 +72,7 @@ export class ReflectorHost implements StaticSymbolResolverHost {
|
|||
containingFile = path.join(this.options.basePath !, 'index.ts');
|
||||
}
|
||||
const resolved =
|
||||
ts.resolveModuleName(moduleName, containingFile, this.options, this.hostAdapter)
|
||||
ts.resolveModuleName(moduleName, containingFile !, this.options, this.hostAdapter)
|
||||
.resolvedModule;
|
||||
return resolved ? resolved.resolvedFileName : null;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library", "ts_web_test")
|
||||
load("@build_bazel_rules_nodejs//:defs.bzl", "jasmine_node_test")
|
||||
|
||||
ts_library(
|
||||
name = "test_lib",
|
||||
testonly = 1,
|
||||
srcs = glob(["**/*.ts"]),
|
||||
tsconfig = "//packages:tsconfig",
|
||||
deps = [
|
||||
"//packages:types",
|
||||
"//packages/compiler",
|
||||
"//packages/language-service",
|
||||
],
|
||||
)
|
||||
|
||||
jasmine_node_test(
|
||||
name = "test",
|
||||
bootstrap = ["angular_src/packages/_testing_init/init_node_spec.js"],
|
||||
# dissable since tests are running but not yet passing
|
||||
tags = ["manual"],
|
||||
deps = [
|
||||
":test_lib",
|
||||
"//packages/_testing_init:node",
|
||||
],
|
||||
)
|
|
@ -0,0 +1,43 @@
|
|||
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library", "ts_web_test")
|
||||
load("@build_bazel_rules_nodejs//:defs.bzl", "jasmine_node_test")
|
||||
|
||||
ts_library(
|
||||
name = "test_lib",
|
||||
testonly = 1,
|
||||
srcs = glob(["**/*.ts"]),
|
||||
tsconfig = "//packages:tsconfig",
|
||||
deps = [
|
||||
"//packages:types",
|
||||
"//packages/compiler",
|
||||
"//packages/core",
|
||||
"//packages/core/testing",
|
||||
"//packages/platform-browser-dynamic",
|
||||
"//packages/platform-browser-dynamic/testing",
|
||||
"//packages/platform-browser/testing",
|
||||
],
|
||||
)
|
||||
|
||||
jasmine_node_test(
|
||||
name = "test",
|
||||
bootstrap = ["angular_src/packages/_testing_init/init_node_spec.js"],
|
||||
# dissable since tests are running but not yet passing
|
||||
tags = ["manual"],
|
||||
deps = [
|
||||
":test_lib",
|
||||
"//packages/_testing_init:node",
|
||||
],
|
||||
)
|
||||
|
||||
ts_web_test(
|
||||
name = "test_web",
|
||||
bootstrap = [
|
||||
"//:angular_bootstrap_scripts",
|
||||
],
|
||||
# dissable since tests are running but not yet passing
|
||||
tags = ["manual"],
|
||||
# do not sort
|
||||
deps = [
|
||||
"//packages/_testing_init:browser",
|
||||
":test_lib",
|
||||
],
|
||||
)
|
|
@ -6,8 +6,8 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {MetadataOverrider} from '@angular/platform-browser-dynamic/testing/src/metadata_overrider';
|
||||
import {expect} from '@angular/platform-browser/testing/src/matchers';
|
||||
import {MetadataOverrider} from '../testing/src/metadata_overrider';
|
||||
|
||||
interface SomeMetadataType {
|
||||
plainProp?: string;
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library", "ts_web_test")
|
||||
load("@build_bazel_rules_nodejs//:defs.bzl", "jasmine_node_test")
|
||||
|
||||
ts_library(
|
||||
name = "test_lib",
|
||||
testonly = 1,
|
||||
srcs = glob(["**/*.ts"]),
|
||||
tsconfig = "//packages:tsconfig",
|
||||
deps = [
|
||||
"//packages:types",
|
||||
"//packages/animations",
|
||||
"//packages/animations/browser",
|
||||
"//packages/animations/browser/testing",
|
||||
"//packages/common",
|
||||
"//packages/compiler",
|
||||
"//packages/core",
|
||||
"//packages/core/testing",
|
||||
"//packages/platform-browser",
|
||||
"//packages/platform-browser-dynamic",
|
||||
"//packages/platform-browser/animations",
|
||||
"//packages/platform-browser/testing",
|
||||
"@rxjs",
|
||||
],
|
||||
)
|
||||
|
||||
jasmine_node_test(
|
||||
name = "test",
|
||||
bootstrap = ["angular_src/packages/_testing_init/init_node_spec.js"],
|
||||
# dissable since tests are running but not yet passing
|
||||
tags = ["manual"],
|
||||
deps = [
|
||||
":test_lib",
|
||||
"//packages/_testing_init:node",
|
||||
],
|
||||
)
|
||||
|
||||
ts_web_test(
|
||||
name = "test_web",
|
||||
bootstrap = [
|
||||
"//:angular_bootstrap_scripts",
|
||||
],
|
||||
# dissable since tests are running but not yet passing
|
||||
tags = ["manual"],
|
||||
# do not sort
|
||||
deps = [
|
||||
"//packages/_testing_init:browser",
|
||||
":test_lib",
|
||||
],
|
||||
)
|
|
@ -161,7 +161,7 @@ function bootstrap(
|
|||
inject([AsyncTestCompleter], (done: AsyncTestCompleter) => {
|
||||
const logger = new MockConsole();
|
||||
const errorHandler = new ErrorHandler();
|
||||
errorHandler._console = logger as any;
|
||||
(errorHandler as any)._console = logger as any;
|
||||
expect(
|
||||
() => bootstrap(
|
||||
HelloRootDirectiveIsNotCmp, [{provide: ErrorHandler, useValue: errorHandler}]))
|
||||
|
@ -173,7 +173,7 @@ function bootstrap(
|
|||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
const logger = new MockConsole();
|
||||
const errorHandler = new ErrorHandler();
|
||||
errorHandler._console = logger as any;
|
||||
(errorHandler as any)._console = logger as any;
|
||||
bootstrap(NonExistentComp, [
|
||||
{provide: ErrorHandler, useValue: errorHandler}
|
||||
]).then(null, (reason) => {
|
||||
|
@ -187,7 +187,7 @@ function bootstrap(
|
|||
it('should throw if no provider', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
const logger = new MockConsole();
|
||||
const errorHandler = new ErrorHandler();
|
||||
errorHandler._console = logger as any;
|
||||
(errorHandler as any)._console = logger as any;
|
||||
|
||||
class IDontExist {}
|
||||
|
||||
|
@ -223,7 +223,7 @@ function bootstrap(
|
|||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
const logger = new MockConsole();
|
||||
const errorHandler = new ErrorHandler();
|
||||
errorHandler._console = logger as any;
|
||||
(errorHandler as any)._console = logger as any;
|
||||
|
||||
const refPromise =
|
||||
bootstrap(NonExistentComp, [{provide: ErrorHandler, useValue: errorHandler}]);
|
||||
|
@ -238,7 +238,7 @@ function bootstrap(
|
|||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
const logger = new MockConsole();
|
||||
const errorHandler = new ErrorHandler();
|
||||
errorHandler._console = logger as any;
|
||||
(errorHandler as any)._console = logger as any;
|
||||
|
||||
const refPromise =
|
||||
bootstrap(NonExistentComp, [{provide: ErrorHandler, useValue: errorHandler}]);
|
||||
|
|
|
@ -12,7 +12,7 @@ import {BrowserModule, BrowserTransferStateModule, TransferState} from '@angular
|
|||
import {StateKey, escapeHtml, makeStateKey, unescapeHtml} from '@angular/platform-browser/src/browser/transfer_state';
|
||||
import {DOCUMENT} from '@angular/platform-browser/src/dom/dom_tokens';
|
||||
|
||||
(function(){
|
||||
(function() {
|
||||
function removeScriptTag(doc: Document, id: string) {
|
||||
const existing = doc.getElementById(id);
|
||||
if (existing) {
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library", "ts_web_test")
|
||||
load("@build_bazel_rules_nodejs//:defs.bzl", "jasmine_node_test")
|
||||
|
||||
ts_library(
|
||||
name = "test_lib",
|
||||
testonly = 1,
|
||||
srcs = glob(["**/*.ts"]),
|
||||
tsconfig = "//packages:tsconfig",
|
||||
deps = [
|
||||
"//packages:types",
|
||||
"//packages/animations",
|
||||
"//packages/common",
|
||||
"//packages/common/http",
|
||||
"//packages/common/http/testing",
|
||||
"//packages/compiler",
|
||||
"//packages/core",
|
||||
"//packages/core/testing",
|
||||
"//packages/http",
|
||||
"//packages/http/testing",
|
||||
"//packages/platform-browser",
|
||||
"//packages/platform-server",
|
||||
"@rxjs",
|
||||
],
|
||||
)
|
||||
|
||||
jasmine_node_test(
|
||||
name = "test",
|
||||
bootstrap = ["angular_src/packages/_testing_init/init_node_spec.js"],
|
||||
deps = [
|
||||
":test_lib",
|
||||
"//packages/_testing_init:node",
|
||||
],
|
||||
)
|
|
@ -298,7 +298,7 @@ class TransferStoreModule {
|
|||
class EscapedTransferStoreModule {
|
||||
}
|
||||
|
||||
(function(){
|
||||
(function() {
|
||||
if (getDOM().supportsDOMEvents()) return; // NODE only
|
||||
|
||||
describe('platform-server integration', () => {
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load("@angular//:index.bzl", "ng_module")
|
||||
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
|
||||
|
||||
ts_library(
|
||||
name = "platform-webworker-dynamic",
|
||||
srcs = glob(
|
||||
[
|
||||
"*.ts",
|
||||
"src/**/*.ts",
|
||||
],
|
||||
),
|
||||
module_name = "@angular/platform-webworker-dynamic",
|
||||
tsconfig = "//packages:tsconfig",
|
||||
deps = [
|
||||
"//packages:types",
|
||||
"//packages/common",
|
||||
"//packages/compiler",
|
||||
"//packages/core",
|
||||
"//packages/platform-browser-dynamic",
|
||||
],
|
||||
)
|
|
@ -0,0 +1,23 @@
|
|||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load("@angular//:index.bzl", "ng_module")
|
||||
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
|
||||
|
||||
ts_library(
|
||||
name = "platform-webworker",
|
||||
srcs = glob(
|
||||
[
|
||||
"*.ts",
|
||||
"src/**/*.ts",
|
||||
],
|
||||
),
|
||||
module_name = "@angular/platform-webworker",
|
||||
tsconfig = "//packages:tsconfig",
|
||||
deps = [
|
||||
"//packages:types",
|
||||
"//packages/common",
|
||||
"//packages/compiler",
|
||||
"//packages/core",
|
||||
"//packages/platform-browser",
|
||||
],
|
||||
)
|
|
@ -0,0 +1,20 @@
|
|||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
|
||||
|
||||
ts_library(
|
||||
name = "testing",
|
||||
testonly = 1,
|
||||
srcs = glob(["**/*.ts"]),
|
||||
module_name = "@angular/platform-browser-dynamic/testing",
|
||||
tsconfig = "//packages:tsconfig",
|
||||
deps = [
|
||||
"//packages/compiler",
|
||||
"//packages/compiler/testing",
|
||||
"//packages/core",
|
||||
"//packages/core/testing",
|
||||
"//packages/platform-browser",
|
||||
"//packages/platform-browser-dynamic",
|
||||
"//packages/platform-browser/testing",
|
||||
],
|
||||
)
|
|
@ -0,0 +1,41 @@
|
|||
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library", "ts_web_test")
|
||||
load("@build_bazel_rules_nodejs//:defs.bzl", "jasmine_node_test")
|
||||
|
||||
ts_library(
|
||||
name = "test_lib",
|
||||
testonly = 1,
|
||||
srcs = glob(["**/*.ts"]),
|
||||
tsconfig = "//packages:tsconfig",
|
||||
deps = [
|
||||
"//packages:types",
|
||||
"//packages/compiler",
|
||||
"//packages/core",
|
||||
"//packages/core/testing",
|
||||
"//packages/platform-browser",
|
||||
"//packages/platform-browser-dynamic",
|
||||
"//packages/platform-browser-dynamic/testing",
|
||||
"//packages/platform-browser/testing",
|
||||
"//packages/platform-webworker",
|
||||
],
|
||||
)
|
||||
|
||||
jasmine_node_test(
|
||||
name = "test",
|
||||
bootstrap = ["angular_src/packages/_testing_init/init_node_spec.js"],
|
||||
deps = [
|
||||
":test_lib",
|
||||
"//packages/_testing_init:node",
|
||||
],
|
||||
)
|
||||
|
||||
ts_web_test(
|
||||
name = "test_web",
|
||||
bootstrap = [
|
||||
"//:angular_bootstrap_scripts",
|
||||
],
|
||||
# do not sort
|
||||
deps = [
|
||||
"//packages/_testing_init:browser",
|
||||
":test_lib",
|
||||
],
|
||||
)
|
|
@ -34,9 +34,10 @@ import {createPairedMessageBuses} from './web_worker_test_util';
|
|||
});
|
||||
it('should call registered method with correct arguments',
|
||||
inject([Serializer], (serializer: Serializer) => {
|
||||
const broker = new ServiceMessageBroker(messageBuses.ui, serializer, CHANNEL);
|
||||
const broker = new (ServiceMessageBroker as any)(messageBuses.ui, serializer, CHANNEL);
|
||||
broker.registerMethod(
|
||||
TEST_METHOD, [SerializerTypes.PRIMITIVE, SerializerTypes.PRIMITIVE], (arg1, arg2) => {
|
||||
TEST_METHOD, [SerializerTypes.PRIMITIVE, SerializerTypes.PRIMITIVE],
|
||||
(arg1: any, arg2: any) => {
|
||||
expect(arg1).toEqual(PASSED_ARG_1);
|
||||
expect(arg2).toEqual(PASSED_ARG_2);
|
||||
});
|
||||
|
@ -47,8 +48,8 @@ import {createPairedMessageBuses} from './web_worker_test_util';
|
|||
}));
|
||||
|
||||
it('should return promises to the worker', inject([Serializer], (serializer: Serializer) => {
|
||||
const broker = new ServiceMessageBroker(messageBuses.ui, serializer, CHANNEL);
|
||||
broker.registerMethod(TEST_METHOD, [SerializerTypes.PRIMITIVE], (arg1) => {
|
||||
const broker = new (ServiceMessageBroker as any)(messageBuses.ui, serializer, CHANNEL);
|
||||
broker.registerMethod(TEST_METHOD, [SerializerTypes.PRIMITIVE], (arg1: any) => {
|
||||
expect(arg1).toEqual(PASSED_ARG_1);
|
||||
return new Promise((res, rej) => {
|
||||
try {
|
||||
|
|
|
@ -130,7 +130,9 @@ export class MockMessageBus extends MessageBus {
|
|||
attachToZone(zone: NgZone) {}
|
||||
}
|
||||
|
||||
export class MockMessageBrokerFactory extends ClientMessageBrokerFactory {
|
||||
export const _ClientMessageBrokerFactory: {new (a: any, b: any): ClientMessageBrokerFactory} =
|
||||
ClientMessageBrokerFactory;
|
||||
export class MockMessageBrokerFactory extends _ClientMessageBrokerFactory {
|
||||
constructor(private _messageBroker: ClientMessageBroker) { super(null !, null !); }
|
||||
createMessageBroker(channel: string, runInZone = true) { return this._messageBroker; }
|
||||
}
|
||||
|
|
|
@ -67,18 +67,18 @@ import {SpyMessageBroker} from './spies';
|
|||
it('should get location on init', () => {
|
||||
const platformLocation = createWebWorkerPlatformLocation(null !);
|
||||
expectBrokerCall(broker, 'getLocation');
|
||||
platformLocation.init();
|
||||
(platformLocation as any).init();
|
||||
});
|
||||
|
||||
it('should throw if set pathname is called before init finishes', () => {
|
||||
const platformLocation = createWebWorkerPlatformLocation(null !);
|
||||
platformLocation.init();
|
||||
(platformLocation as any).init();
|
||||
expect(() => platformLocation.pathname = 'TEST').toThrowError();
|
||||
});
|
||||
|
||||
it('should send pathname to render thread', done => {
|
||||
const platformLocation = createWebWorkerPlatformLocation(TEST_LOCATION);
|
||||
platformLocation.init().then((_) => {
|
||||
(platformLocation as any).init().then((_: any) => {
|
||||
const PATHNAME = '/test';
|
||||
expectBrokerCall(broker, 'setPathname', [PATHNAME]);
|
||||
platformLocation.pathname = PATHNAME;
|
||||
|
|
|
@ -184,10 +184,10 @@ function createWebWorkerBrokerFactory(
|
|||
const wwMessageBus = messageBuses.worker;
|
||||
|
||||
// set up the worker side
|
||||
const wwBrokerFactory = new ClientMessageBrokerFactory(wwMessageBus, wwSerializer);
|
||||
const wwBrokerFactory = new (ClientMessageBrokerFactory as any)(wwMessageBus, wwSerializer);
|
||||
|
||||
// set up the ui side
|
||||
const uiBrokerFactory = new ServiceMessageBrokerFactory(uiMessageBus, uiSerializer);
|
||||
const uiBrokerFactory = new (ServiceMessageBrokerFactory as any)(uiMessageBus, uiSerializer);
|
||||
const renderer = new MessageBasedRenderer2(
|
||||
uiBrokerFactory, uiMessageBus, uiSerializer, uiRenderStore, domRendererFactory);
|
||||
renderer.start();
|
||||
|
|
|
@ -12,6 +12,9 @@ jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
|
|||
|
||||
__karma__.loaded = function() {};
|
||||
|
||||
window.isNode = false;
|
||||
window.isBrowser = true;
|
||||
|
||||
function isJsFile(path) {
|
||||
return path.slice(-3) == '.js';
|
||||
}
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library", "ts_web_test")
|
||||
load("@build_bazel_rules_nodejs//:defs.bzl", "jasmine_node_test")
|
||||
|
||||
ts_library(
|
||||
name = "test_lib",
|
||||
testonly = 1,
|
||||
srcs = glob(["**/*.ts"]),
|
||||
tsconfig = "//packages:tsconfig",
|
||||
deps = [
|
||||
"//packages/common",
|
||||
"//packages/common/testing",
|
||||
"//packages/core",
|
||||
"//packages/core/testing",
|
||||
"//packages/platform-browser",
|
||||
"//packages/platform-browser-dynamic",
|
||||
"//packages/platform-browser/testing",
|
||||
"//packages/router",
|
||||
"//packages/router/testing",
|
||||
"@rxjs",
|
||||
],
|
||||
)
|
||||
|
||||
jasmine_node_test(
|
||||
name = "test",
|
||||
bootstrap = ["angular_src/packages/_testing_init/init_node_spec.js"],
|
||||
# dissable since tests are running but not yet passing
|
||||
tags = ["manual"],
|
||||
deps = [
|
||||
":test_lib",
|
||||
"//packages/_testing_init:node",
|
||||
],
|
||||
)
|
||||
|
||||
ts_web_test(
|
||||
name = "test_web",
|
||||
bootstrap = [
|
||||
"//:angular_bootstrap_scripts",
|
||||
],
|
||||
# dissable since tests are running but not yet passing
|
||||
tags = ["manual"],
|
||||
# do not sort
|
||||
deps = [
|
||||
"//packages/_testing_init:browser",
|
||||
":test_lib",
|
||||
],
|
||||
)
|
|
@ -178,7 +178,7 @@ describe('applyRedirects', () => {
|
|||
applyRedirects(testModule.injector, <any>loader, serializer, tree('a/b'), config)
|
||||
.forEach(r => {
|
||||
expectTreeToBe(r, '/a/b');
|
||||
expect(config[0]._loadedConfig).toBe(loadedConfig);
|
||||
expect((config[0] as any)._loadedConfig).toBe(loadedConfig);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -304,7 +304,7 @@ describe('applyRedirects', () => {
|
|||
|
||||
applyRedirects(testModule.injector, <any>loader, serializer, tree(''), config).forEach(r => {
|
||||
expectTreeToBe(r, 'a');
|
||||
expect(config[1]._loadedConfig).toBe(loadedConfig);
|
||||
expect((config[1] as any)._loadedConfig).toBe(loadedConfig);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -329,7 +329,7 @@ describe('applyRedirects', () => {
|
|||
.subscribe(
|
||||
r => {
|
||||
expectTreeToBe(r, 'a?k2');
|
||||
expect(config[0]._loadedConfig).toBe(loadedConfig);
|
||||
expect((config[0] as any)._loadedConfig).toBe(loadedConfig);
|
||||
},
|
||||
(e) => { throw 'Should not reach'; });
|
||||
});
|
||||
|
@ -342,7 +342,7 @@ describe('applyRedirects', () => {
|
|||
const config: Routes = [{path: '**', loadChildren: 'children'}];
|
||||
|
||||
applyRedirects(testModule.injector, <any>loader, serializer, tree('xyz'), config)
|
||||
.forEach(r => { expect(config[0]._loadedConfig).toBe(loadedConfig); });
|
||||
.forEach(r => { expect((config[0] as any)._loadedConfig).toBe(loadedConfig); });
|
||||
});
|
||||
|
||||
it('should load the configuration after a local redirect from a wildcard route', () => {
|
||||
|
@ -354,7 +354,7 @@ describe('applyRedirects', () => {
|
|||
[{path: 'not-found', loadChildren: 'children'}, {path: '**', redirectTo: 'not-found'}];
|
||||
|
||||
applyRedirects(testModule.injector, <any>loader, serializer, tree('xyz'), config)
|
||||
.forEach(r => { expect(config[0]._loadedConfig).toBe(loadedConfig); });
|
||||
.forEach(r => { expect((config[0] as any)._loadedConfig).toBe(loadedConfig); });
|
||||
});
|
||||
|
||||
it('should load the configuration after an absolute redirect from a wildcard route', () => {
|
||||
|
@ -366,7 +366,7 @@ describe('applyRedirects', () => {
|
|||
[{path: 'not-found', loadChildren: 'children'}, {path: '**', redirectTo: '/not-found'}];
|
||||
|
||||
applyRedirects(testModule.injector, <any>loader, serializer, tree('xyz'), config)
|
||||
.forEach(r => { expect(config[0]._loadedConfig).toBe(loadedConfig); });
|
||||
.forEach(r => { expect((config[0] as any)._loadedConfig).toBe(loadedConfig); });
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -214,7 +214,7 @@ describe('bootstrap', () => {
|
|||
const appRef: ApplicationRef = res.injector.get(ApplicationRef);
|
||||
appRef.bootstrap(SecondRootCmp);
|
||||
|
||||
expect(router.resetRootComponentType).not.toHaveBeenCalled();
|
||||
expect((router as any).resetRootComponentType).not.toHaveBeenCalled();
|
||||
|
||||
done();
|
||||
});
|
||||
|
@ -240,7 +240,7 @@ describe('bootstrap', () => {
|
|||
const appRef: ApplicationRef = res.injector.get(ApplicationRef);
|
||||
appRef.components[0].onDestroy(() => {
|
||||
appRef.bootstrap(SecondRootCmp);
|
||||
expect(router.resetRootComponentType).toHaveBeenCalled();
|
||||
expect((router as any).resetRootComponentType).toHaveBeenCalled();
|
||||
done();
|
||||
});
|
||||
|
||||
|
|
|
@ -18,8 +18,8 @@ import {TreeNode} from '../src/utils/tree';
|
|||
describe('create router state', () => {
|
||||
const reuseStrategy = new DefaultRouteReuseStrategy();
|
||||
|
||||
const emptyState = () =>
|
||||
createEmptyState(new UrlTree(new UrlSegmentGroup([], {}), {}, null !), RootComponent);
|
||||
const emptyState = () => createEmptyState(
|
||||
new (UrlTree as any)(new UrlSegmentGroup([], {}), {}, null !), RootComponent);
|
||||
|
||||
it('should work create new state', () => {
|
||||
const state = createRouterState(
|
||||
|
@ -34,7 +34,7 @@ describe('create router state', () => {
|
|||
|
||||
checkActivatedRoute(state.root, RootComponent);
|
||||
|
||||
const c = state.children(state.root);
|
||||
const c = (state as any).children(state.root);
|
||||
checkActivatedRoute(c[0], ComponentA);
|
||||
checkActivatedRoute(c[1], ComponentB, 'left');
|
||||
checkActivatedRoute(c[2], ComponentC, 'right');
|
||||
|
@ -52,8 +52,8 @@ describe('create router state', () => {
|
|||
const state = createRouterState(reuseStrategy, createState(config, 'a(left:c)'), prevState);
|
||||
|
||||
expect(prevState.root).toBe(state.root);
|
||||
const prevC = prevState.children(prevState.root);
|
||||
const currC = state.children(state.root);
|
||||
const prevC = (prevState as any).children(prevState.root);
|
||||
const currC = (state as any).children(state.root);
|
||||
|
||||
expect(prevC[0]).toBe(currC[0]);
|
||||
expect(prevC[1]).not.toBe(currC[1]);
|
||||
|
@ -76,11 +76,11 @@ describe('create router state', () => {
|
|||
createRouterState(reuseStrategy, createState(config, 'a/2;p=22/(b//right:c)'), prevState);
|
||||
|
||||
expect(prevState.root).toBe(state.root);
|
||||
const prevP = prevState.firstChild(prevState.root) !;
|
||||
const currP = state.firstChild(state.root) !;
|
||||
const prevP = (prevState as any).firstChild(prevState.root) !;
|
||||
const currP = (state as any).firstChild(state.root) !;
|
||||
expect(prevP).toBe(currP);
|
||||
|
||||
const currC = state.children(currP);
|
||||
const currC = (state as any).children(currP);
|
||||
|
||||
expect(currP._futureSnapshot.params).toEqual({id: '2', p: '22'});
|
||||
expect(currP._futureSnapshot.paramMap.get('id')).toEqual('2');
|
||||
|
@ -91,7 +91,7 @@ describe('create router state', () => {
|
|||
});
|
||||
|
||||
function advanceState(state: RouterState): void {
|
||||
advanceNode(state._root);
|
||||
advanceNode((state as any)._root);
|
||||
}
|
||||
|
||||
function advanceNode(node: TreeNode<ActivatedRoute>): void {
|
||||
|
|
|
@ -243,10 +243,10 @@ describe('createUrlTree', () => {
|
|||
});
|
||||
|
||||
function createRoot(tree: UrlTree, commands: any[], queryParams?: Params, fragment?: string) {
|
||||
const s = new ActivatedRouteSnapshot(
|
||||
const s = new (ActivatedRouteSnapshot as any)(
|
||||
[], <any>{}, <any>{}, '', <any>{}, PRIMARY_OUTLET, 'someComponent', null, tree.root, -1,
|
||||
<any>null);
|
||||
const a = new ActivatedRoute(
|
||||
const a = new (ActivatedRoute as any)(
|
||||
new BehaviorSubject(null !), new BehaviorSubject(null !), new BehaviorSubject(null !),
|
||||
new BehaviorSubject(null !), new BehaviorSubject(null !), PRIMARY_OUTLET, 'someComponent', s);
|
||||
advanceActivatedRoute(a);
|
||||
|
@ -259,10 +259,10 @@ function create(
|
|||
if (!segment) {
|
||||
expect(segment).toBeDefined();
|
||||
}
|
||||
const s = new ActivatedRouteSnapshot(
|
||||
const s = new (ActivatedRouteSnapshot as any)(
|
||||
[], <any>{}, <any>{}, '', <any>{}, PRIMARY_OUTLET, 'someComponent', null, <any>segment,
|
||||
startIndex, <any>null);
|
||||
const a = new ActivatedRoute(
|
||||
const a = new (ActivatedRoute as any)(
|
||||
new BehaviorSubject(null !), new BehaviorSubject(null !), new BehaviorSubject(null !),
|
||||
new BehaviorSubject(null !), new BehaviorSubject(null !), PRIMARY_OUTLET, 'someComponent', s);
|
||||
advanceActivatedRoute(a);
|
||||
|
|
|
@ -42,7 +42,7 @@ export declare type ARSArgs = {
|
|||
};
|
||||
|
||||
export function createActivatedRouteSnapshot(args: ARSArgs): ActivatedRouteSnapshot {
|
||||
return new ActivatedRouteSnapshot(
|
||||
return new (ActivatedRouteSnapshot as any)(
|
||||
args.url || <any>[], args.params || {}, args.queryParams || <any>null,
|
||||
args.fragment || <any>null, args.data || <any>null, args.outlet || <any>null,
|
||||
<any>args.component, args.routeConfig || <any>{}, args.urlSegment || <any>null,
|
||||
|
|
|
@ -7,12 +7,12 @@
|
|||
*/
|
||||
|
||||
import {CommonModule, Location} from '@angular/common';
|
||||
import {SpyLocation} from '@angular/common/testing';
|
||||
import {ChangeDetectionStrategy, Component, Injectable, NgModule, NgModuleFactoryLoader, NgModuleRef} from '@angular/core';
|
||||
import {ComponentFixture, TestBed, fakeAsync, inject, tick} from '@angular/core/testing';
|
||||
import {By} from '@angular/platform-browser/src/dom/debug/by';
|
||||
import {expect} from '@angular/platform-browser/testing/src/matchers';
|
||||
import {ActivatedRoute, ActivatedRouteSnapshot, ActivationEnd, ActivationStart, CanActivate, CanDeactivate, ChildActivationEnd, ChildActivationStart, DetachedRouteHandle, Event, GuardsCheckEnd, GuardsCheckStart, NavigationCancel, NavigationEnd, NavigationError, NavigationStart, PRIMARY_OUTLET, ParamMap, Params, PreloadAllModules, PreloadingStrategy, Resolve, ResolveEnd, ResolveStart, RouteConfigLoadEnd, RouteConfigLoadStart, RouteReuseStrategy, Router, RouterEvent, RouterModule, RouterPreloader, RouterStateSnapshot, RoutesRecognized, RunGuardsAndResolvers, UrlHandlingStrategy, UrlSegmentGroup, UrlTree} from '@angular/router';
|
||||
import {SpyLocation} from 'common/testing';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import {Observer} from 'rxjs/Observer';
|
||||
import {of } from 'rxjs/observable/of';
|
||||
|
@ -3527,7 +3527,7 @@ describe('Integration', () => {
|
|||
router.navigateByUrl('/blank');
|
||||
advance(fixture);
|
||||
|
||||
const config = router.config;
|
||||
const config = router.config as any;
|
||||
const firstConfig = config[1]._loadedConfig !;
|
||||
|
||||
expect(firstConfig).toBeDefined();
|
||||
|
@ -3553,7 +3553,7 @@ describe('Integration', () => {
|
|||
children[PRIMARY_OUTLET] = oldRoot.children[PRIMARY_OUTLET];
|
||||
}
|
||||
const root = new UrlSegmentGroup(oldRoot.segments, children);
|
||||
return new UrlTree(root, url.queryParams, url.fragment);
|
||||
return new (UrlTree as any)(root, url.queryParams, url.fragment);
|
||||
}
|
||||
|
||||
merge(newUrlPart: UrlTree, wholeUrl: UrlTree): UrlTree {
|
||||
|
@ -3571,7 +3571,7 @@ describe('Integration', () => {
|
|||
v.parent = this;
|
||||
});
|
||||
const root = new UrlSegmentGroup(oldRoot.segments, children);
|
||||
return new UrlTree(root, newUrlPart.queryParams, newUrlPart.fragment);
|
||||
return new (UrlTree as any)(root, newUrlPart.queryParams, newUrlPart.fragment);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3992,7 +3992,7 @@ class ComponentRecordingRoutePathAndUrl {
|
|||
private url: any;
|
||||
|
||||
constructor(router: Router, route: ActivatedRoute) {
|
||||
this.path = router.routerState.pathFromRoot(route);
|
||||
this.path = (router.routerState as any).pathFromRoot(route);
|
||||
this.url = router.url.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,13 +8,13 @@
|
|||
|
||||
import {Routes} from '../src/config';
|
||||
import {recognize} from '../src/recognize';
|
||||
import {ActivatedRouteSnapshot, ParamsInheritanceStrategy, RouterStateSnapshot, inheritedParamsDataResolve} from '../src/router_state';
|
||||
import {ActivatedRouteSnapshot, RouterStateSnapshot} from '../src/router_state';
|
||||
import {PRIMARY_OUTLET, Params} from '../src/shared';
|
||||
import {DefaultUrlSerializer, UrlTree} from '../src/url_tree';
|
||||
|
||||
describe('recognize', () => {
|
||||
it('should work', () => {
|
||||
checkRecognize([{path: 'a', component: ComponentA}], 'a', (s: RouterStateSnapshot) => {
|
||||
checkRecognize([{path: 'a', component: ComponentA}], 'a', (s: any) => {
|
||||
checkActivatedRoute(s.root, '', {}, RootComponent);
|
||||
checkActivatedRoute(s.firstChild(s.root) !, 'a', {}, ComponentA);
|
||||
});
|
||||
|
@ -23,7 +23,7 @@ describe('recognize', () => {
|
|||
it('should freeze params object', () => {
|
||||
checkRecognize([{path: 'a/:id', component: ComponentA}], 'a/10', (s: RouterStateSnapshot) => {
|
||||
checkActivatedRoute(s.root, '', {}, RootComponent);
|
||||
const child = s.firstChild(s.root) !;
|
||||
const child = (s as any).firstChild(s.root) !;
|
||||
expect(Object.isFrozen(child.params)).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
@ -35,7 +35,7 @@ describe('recognize', () => {
|
|||
{path: 'c', component: ComponentC, outlet: 'right'}
|
||||
],
|
||||
'a(left:b//right:c)', (s: RouterStateSnapshot) => {
|
||||
const c = s.children(s.root);
|
||||
const c = (s as any).children(s.root);
|
||||
checkActivatedRoute(c[0], 'a', {}, ComponentA);
|
||||
checkActivatedRoute(c[1], 'b', {}, ComponentB, 'left');
|
||||
checkActivatedRoute(c[2], 'c', {}, ComponentC, 'right');
|
||||
|
@ -51,18 +51,18 @@ describe('recognize', () => {
|
|||
{path: 'c', component: ComponentC, outlet: 'right'}
|
||||
],
|
||||
url, 'a(left:b//right:c)')
|
||||
.subscribe((s) => {
|
||||
.subscribe((s: any) => {
|
||||
expect(s.root._urlSegment).toBe(url.root);
|
||||
expect(s.root._lastPathIndex).toBe(-1);
|
||||
|
||||
const c = s.children(s.root);
|
||||
expect(c[0]._urlSegment).toBe(url.root.children[PRIMARY_OUTLET]);
|
||||
const c = (s as any).children(s.root);
|
||||
expect(c[0]._urlSegment).toBe((url.root as any).children[PRIMARY_OUTLET]);
|
||||
expect(c[0]._lastPathIndex).toBe(0);
|
||||
|
||||
expect(c[1]._urlSegment).toBe(url.root.children['left']);
|
||||
expect(c[1]._urlSegment).toBe((url.root as any).children['left']);
|
||||
expect(c[1]._lastPathIndex).toBe(0);
|
||||
|
||||
expect(c[2]._urlSegment).toBe(url.root.children['right']);
|
||||
expect(c[2]._urlSegment).toBe((url.root as any).children['right']);
|
||||
expect(c[2]._lastPathIndex).toBe(0);
|
||||
});
|
||||
});
|
||||
|
@ -76,15 +76,15 @@ describe('recognize', () => {
|
|||
],
|
||||
url, 'a/b/c')
|
||||
.subscribe((s: RouterStateSnapshot) => {
|
||||
expect(s.root._urlSegment).toBe(url.root);
|
||||
expect(s.root._lastPathIndex).toBe(-1);
|
||||
expect((s.root as any)._urlSegment).toBe(url.root);
|
||||
expect((s.root as any)._lastPathIndex).toBe(-1);
|
||||
|
||||
const compA = s.firstChild(s.root) !;
|
||||
expect(compA._urlSegment).toBe(url.root.children[PRIMARY_OUTLET]);
|
||||
const compA = (s as any).firstChild(s.root) !;
|
||||
expect(compA._urlSegment).toBe((url.root as any).children[PRIMARY_OUTLET]);
|
||||
expect(compA._lastPathIndex).toBe(1);
|
||||
|
||||
const compC = s.firstChild(<any>compA) !;
|
||||
expect(compC._urlSegment).toBe(url.root.children[PRIMARY_OUTLET]);
|
||||
const compC = (s as any).firstChild(<any>compA) !;
|
||||
expect(compC._urlSegment).toBe((url.root as any).children[PRIMARY_OUTLET]);
|
||||
expect(compC._lastPathIndex).toBe(2);
|
||||
});
|
||||
});
|
||||
|
@ -97,16 +97,16 @@ describe('recognize', () => {
|
|||
{path: 'a', component: ComponentA, children: [{path: '**', component: ComponentB}]},
|
||||
],
|
||||
url, 'a/b/c')
|
||||
.subscribe((s: RouterStateSnapshot) => {
|
||||
.subscribe((s: any) => {
|
||||
expect(s.root._urlSegment).toBe(url.root);
|
||||
expect(s.root._lastPathIndex).toBe(-1);
|
||||
|
||||
const compA = s.firstChild(s.root) !;
|
||||
expect(compA._urlSegment).toBe(url.root.children[PRIMARY_OUTLET]);
|
||||
const compA = (s as any).firstChild(s.root) !;
|
||||
expect(compA._urlSegment).toBe((url as any).root.children[PRIMARY_OUTLET]);
|
||||
expect(compA._lastPathIndex).toBe(0);
|
||||
|
||||
const compC = s.firstChild(<any>compA) !;
|
||||
expect(compC._urlSegment).toBe(url.root.children[PRIMARY_OUTLET]);
|
||||
const compC = (s as any).firstChild(<any>compA) !;
|
||||
expect(compC._urlSegment).toBe((url as any).root.children[PRIMARY_OUTLET]);
|
||||
expect(compC._lastPathIndex).toBe(2);
|
||||
});
|
||||
});
|
||||
|
@ -119,16 +119,18 @@ describe('recognize', () => {
|
|||
],
|
||||
'a/paramA', (s: RouterStateSnapshot) => {
|
||||
checkActivatedRoute(s.root, '', {}, RootComponent);
|
||||
checkActivatedRoute(s.firstChild(s.root) !, 'a', {}, ComponentA);
|
||||
checkActivatedRoute((s as any).firstChild(s.root) !, 'a', {}, ComponentA);
|
||||
checkActivatedRoute(
|
||||
s.firstChild(<any>s.firstChild(s.root)) !, 'paramA', {id: 'paramA'}, ComponentB);
|
||||
(s as any).firstChild(<any>(s as any).firstChild(s.root)) !, 'paramA', {id: 'paramA'},
|
||||
ComponentB);
|
||||
});
|
||||
|
||||
checkRecognize(
|
||||
[{path: 'a', component: ComponentA}, {path: 'a/:id', component: ComponentC}], 'a/paramA',
|
||||
(s: RouterStateSnapshot) => {
|
||||
checkActivatedRoute(s.root, '', {}, RootComponent);
|
||||
checkActivatedRoute(s.firstChild(s.root) !, 'a/paramA', {id: 'paramA'}, ComponentC);
|
||||
checkActivatedRoute(
|
||||
(s as any).firstChild(s.root) !, 'a/paramA', {id: 'paramA'}, ComponentC);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -139,7 +141,7 @@ describe('recognize', () => {
|
|||
{path: 'b', component: ComponentC, outlet: 'right'}
|
||||
],
|
||||
'a(right:b)', (s: RouterStateSnapshot) => {
|
||||
const c = s.children(s.root);
|
||||
const c = (s as any).children(s.root);
|
||||
checkActivatedRoute(c[0], 'a', {}, ComponentA);
|
||||
checkActivatedRoute(c[1], 'b', {}, ComponentC, 'right');
|
||||
});
|
||||
|
@ -158,7 +160,7 @@ describe('recognize', () => {
|
|||
},
|
||||
],
|
||||
'a/(b//left:c)', (s: RouterStateSnapshot) => {
|
||||
const c = s.children(<any>s.firstChild(s.root));
|
||||
const c = (s as any).children(<any>(s as any).firstChild(s.root));
|
||||
checkActivatedRoute(c[0], 'b', {}, ComponentB, PRIMARY_OUTLET);
|
||||
checkActivatedRoute(c[1], 'c', {}, ComponentC, 'left');
|
||||
});
|
||||
|
@ -171,7 +173,7 @@ describe('recognize', () => {
|
|||
{path: 'b', component: ComponentB, outlet: 'b'}
|
||||
],
|
||||
'a(c:c//b:b)', (s: RouterStateSnapshot) => {
|
||||
const c = s.children(s.root);
|
||||
const c = (s as any).children(s.root);
|
||||
checkActivatedRoute(c[0], 'a', {}, ComponentA);
|
||||
checkActivatedRoute(c[1], 'b', {}, ComponentB, 'b');
|
||||
checkActivatedRoute(c[2], 'c', {}, ComponentC, 'c');
|
||||
|
@ -185,9 +187,10 @@ describe('recognize', () => {
|
|||
{path: 'c', component: ComponentC, outlet: 'left'}
|
||||
],
|
||||
'a;a1=11;a2=22/b;b1=111;b2=222(left:c;c1=1111;c2=2222)', (s: RouterStateSnapshot) => {
|
||||
const c = s.children(s.root);
|
||||
const c = (s as any).children(s.root);
|
||||
checkActivatedRoute(c[0], 'a', {a1: '11', a2: '22'}, ComponentA);
|
||||
checkActivatedRoute(s.firstChild(<any>c[0]) !, 'b', {b1: '111', b2: '222'}, ComponentB);
|
||||
checkActivatedRoute(
|
||||
(s as any).firstChild(<any>c[0]) !, 'b', {b1: '111', b2: '222'}, ComponentB);
|
||||
checkActivatedRoute(c[1], 'c', {c1: '1111', c2: '2222'}, ComponentC, 'left');
|
||||
});
|
||||
});
|
||||
|
@ -196,7 +199,7 @@ describe('recognize', () => {
|
|||
it('should set static data', () => {
|
||||
checkRecognize(
|
||||
[{path: 'a', data: {one: 1}, component: ComponentA}], 'a', (s: RouterStateSnapshot) => {
|
||||
const r: ActivatedRouteSnapshot = s.firstChild(s.root) !;
|
||||
const r: ActivatedRouteSnapshot = (s as any).firstChild(s.root) !;
|
||||
expect(r.data).toEqual({one: 1});
|
||||
});
|
||||
});
|
||||
|
@ -209,7 +212,8 @@ describe('recognize', () => {
|
|||
children: [{path: 'b', data: {two: 2}, component: ComponentB}]
|
||||
}],
|
||||
'a/b', (s: RouterStateSnapshot) => {
|
||||
const r: ActivatedRouteSnapshot = s.firstChild(<any>s.firstChild(s.root)) !;
|
||||
const r: ActivatedRouteSnapshot =
|
||||
(s as any).firstChild(<any>(s as any).firstChild(s.root)) !;
|
||||
expect(r.data).toEqual({one: 1, two: 2});
|
||||
});
|
||||
});
|
||||
|
@ -222,7 +226,7 @@ describe('recognize', () => {
|
|||
data: {one: 1},
|
||||
children: [{path: 'b', data: {two: 2}, component: ComponentB}]
|
||||
}],
|
||||
'a/b', (s: RouterStateSnapshot) => {
|
||||
'a/b', (s: any /* RouterStateSnapshot */) => {
|
||||
const r: ActivatedRouteSnapshot = s.firstChild(<any>s.firstChild(s.root)) !;
|
||||
expect(r.data).toEqual({two: 2});
|
||||
});
|
||||
|
@ -236,7 +240,7 @@ describe('recognize', () => {
|
|||
data: {one: 1},
|
||||
children: [{path: 'b', data: {two: 2}, component: ComponentB}]
|
||||
}],
|
||||
'a/b', (s: RouterStateSnapshot) => {
|
||||
'a/b', (s: any /* RouterStateSnapshot */) => {
|
||||
const r: ActivatedRouteSnapshot = s.firstChild(<any>s.firstChild(s.root)) !;
|
||||
expect(r.data).toEqual({one: 1, two: 2});
|
||||
}, 'always');
|
||||
|
@ -244,9 +248,8 @@ describe('recognize', () => {
|
|||
|
||||
it('should set resolved data', () => {
|
||||
checkRecognize(
|
||||
[{path: 'a', resolve: {one: 'some-token'}, component: ComponentA}], 'a',
|
||||
(s: RouterStateSnapshot) => {
|
||||
const r: ActivatedRouteSnapshot = s.firstChild(s.root) !;
|
||||
[{path: 'a', resolve: {one: 'some-token'}, component: ComponentA}], 'a', (s: any) => {
|
||||
const r: any = s.firstChild(s.root) !;
|
||||
expect(r._resolve).toEqual({one: 'some-token'});
|
||||
});
|
||||
});
|
||||
|
@ -256,7 +259,7 @@ describe('recognize', () => {
|
|||
describe('root', () => {
|
||||
it('should work', () => {
|
||||
checkRecognize([{path: '', component: ComponentA}], '', (s: RouterStateSnapshot) => {
|
||||
checkActivatedRoute(s.firstChild(s.root) !, '', {}, ComponentA);
|
||||
checkActivatedRoute((s as any).firstChild(s.root) !, '', {}, ComponentA);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -264,7 +267,7 @@ describe('recognize', () => {
|
|||
checkRecognize(
|
||||
[{path: '', pathMatch: 'full', component: ComponentA}], '',
|
||||
(s: RouterStateSnapshot) => {
|
||||
checkActivatedRoute(s.firstChild(s.root) !, '', {}, ComponentA);
|
||||
checkActivatedRoute((s as any).firstChild(s.root) !, '', {}, ComponentA);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -272,18 +275,19 @@ describe('recognize', () => {
|
|||
checkRecognize(
|
||||
[{path: '', component: ComponentA, children: [{path: '', component: ComponentB}]}], '',
|
||||
(s: RouterStateSnapshot) => {
|
||||
checkActivatedRoute(s.firstChild(s.root) !, '', {}, ComponentA);
|
||||
checkActivatedRoute(s.firstChild(<any>s.firstChild(s.root)) !, '', {}, ComponentB);
|
||||
checkActivatedRoute((s as any).firstChild(s.root) !, '', {}, ComponentA);
|
||||
checkActivatedRoute(
|
||||
(s as any).firstChild(<any>(s as any).firstChild(s.root)) !, '', {}, ComponentB);
|
||||
});
|
||||
});
|
||||
|
||||
it('should set url segment and index properly', () => {
|
||||
const url = tree('');
|
||||
const url = tree('') as any;
|
||||
recognize(
|
||||
RootComponent,
|
||||
[{path: '', component: ComponentA, children: [{path: '', component: ComponentB}]}], url,
|
||||
'')
|
||||
.forEach((s: RouterStateSnapshot) => {
|
||||
.forEach((s: any) => {
|
||||
expect(s.root._urlSegment).toBe(url.root);
|
||||
expect(s.root._lastPathIndex).toBe(-1);
|
||||
|
||||
|
@ -307,10 +311,13 @@ describe('recognize', () => {
|
|||
]
|
||||
}],
|
||||
'/a;p=1', (s: RouterStateSnapshot) => {
|
||||
checkActivatedRoute(s.firstChild(s.root) !, 'a', {p: '1'}, ComponentA);
|
||||
checkActivatedRoute(s.firstChild(s.firstChild(s.root) !) !, '', {p: '1'}, ComponentB);
|
||||
checkActivatedRoute((s as any).firstChild(s.root) !, 'a', {p: '1'}, ComponentA);
|
||||
checkActivatedRoute(
|
||||
s.firstChild(s.firstChild(s.firstChild(s.root) !) !) !, '', {p: '1'}, ComponentC);
|
||||
(s as any).firstChild((s as any).firstChild(s.root) !) !, '', {p: '1'},
|
||||
ComponentB);
|
||||
checkActivatedRoute(
|
||||
(s as any).firstChild((s as any).firstChild((s as any).firstChild(s.root) !) !) !,
|
||||
'', {p: '1'}, ComponentC);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -327,9 +334,9 @@ describe('recognize', () => {
|
|||
]
|
||||
}],
|
||||
'a/b', (s: RouterStateSnapshot) => {
|
||||
checkActivatedRoute(s.firstChild(s.root) !, 'a', {}, ComponentA);
|
||||
checkActivatedRoute((s as any).firstChild(s.root) !, 'a', {}, ComponentA);
|
||||
|
||||
const c = s.children(s.firstChild(s.root) !);
|
||||
const c = (s as any).children((s as any).firstChild(s.root) !);
|
||||
checkActivatedRoute(c[0], 'b', {}, ComponentB);
|
||||
checkActivatedRoute(c[1], '', {}, ComponentC, 'aux');
|
||||
});
|
||||
|
@ -358,13 +365,13 @@ describe('recognize', () => {
|
|||
|
||||
checkRecognize(config, 'parent/b', (s: RouterStateSnapshot) => {
|
||||
checkActivatedRoute(s.root, '', {}, RootComponent);
|
||||
checkActivatedRoute(s.firstChild(s.root) !, 'parent', {}, undefined !);
|
||||
checkActivatedRoute((s as any).firstChild(s.root) !, 'parent', {}, undefined !);
|
||||
|
||||
const cc = s.children(s.firstChild(s.root) !);
|
||||
const cc = (s as any).children((s as any).firstChild(s.root) !);
|
||||
checkActivatedRoute(cc[0], '', {}, ComponentA);
|
||||
checkActivatedRoute(cc[1], '', {}, ComponentD, 'secondary');
|
||||
|
||||
checkActivatedRoute(s.firstChild(cc[0]) !, 'b', {}, ComponentB);
|
||||
checkActivatedRoute((s as any).firstChild(cc[0]) !, 'b', {}, ComponentB);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -379,16 +386,16 @@ describe('recognize', () => {
|
|||
]
|
||||
}],
|
||||
'a/b', (s: RouterStateSnapshot) => {
|
||||
checkActivatedRoute(s.firstChild(s.root) !, 'a', {}, ComponentA);
|
||||
checkActivatedRoute((s as any).firstChild(s.root) !, 'a', {}, ComponentA);
|
||||
|
||||
const c = s.children(s.firstChild(s.root) !);
|
||||
const c = (s as any).children((s as any).firstChild(s.root) !);
|
||||
expect(c.length).toEqual(1);
|
||||
checkActivatedRoute(c[0], 'b', {}, ComponentB);
|
||||
});
|
||||
});
|
||||
|
||||
it('should set url segment and index properly', () => {
|
||||
const url = tree('a/b');
|
||||
const url = tree('a/b') as any;
|
||||
recognize(
|
||||
RootComponent, [{
|
||||
path: 'a',
|
||||
|
@ -399,7 +406,7 @@ describe('recognize', () => {
|
|||
]
|
||||
}],
|
||||
url, 'a/b')
|
||||
.forEach((s: RouterStateSnapshot) => {
|
||||
.forEach((s: any) => {
|
||||
expect(s.root._urlSegment).toBe(url.root);
|
||||
expect(s.root._lastPathIndex).toBe(-1);
|
||||
|
||||
|
@ -418,7 +425,7 @@ describe('recognize', () => {
|
|||
});
|
||||
|
||||
it('should set url segment and index properly when nested empty-path segments', () => {
|
||||
const url = tree('a');
|
||||
const url = tree('a') as any;
|
||||
recognize(
|
||||
RootComponent, [{
|
||||
path: 'a',
|
||||
|
@ -427,7 +434,7 @@ describe('recognize', () => {
|
|||
]
|
||||
}],
|
||||
url, 'a')
|
||||
.forEach((s: RouterStateSnapshot) => {
|
||||
.forEach((s: any) => {
|
||||
expect(s.root._urlSegment).toBe(url.root);
|
||||
expect(s.root._lastPathIndex).toBe(-1);
|
||||
|
||||
|
@ -455,19 +462,19 @@ describe('recognize', () => {
|
|||
]
|
||||
}],
|
||||
url, '')
|
||||
.forEach((s: RouterStateSnapshot) => {
|
||||
.forEach((s: any) => {
|
||||
expect(s.root._urlSegment).toBe(url.root);
|
||||
expect(s.root._lastPathIndex).toBe(-1);
|
||||
|
||||
const a = s.firstChild(s.root) !;
|
||||
const a = (s as any).firstChild(s.root) !;
|
||||
expect(a._urlSegment).toBe(url.root);
|
||||
expect(a._lastPathIndex).toBe(-1);
|
||||
|
||||
const b = s.firstChild(a) !;
|
||||
const b = (s as any).firstChild(a) !;
|
||||
expect(b._urlSegment).toBe(url.root);
|
||||
expect(b._lastPathIndex).toBe(-1);
|
||||
|
||||
const c = s.firstChild(b) !;
|
||||
const c = (s as any).firstChild(b) !;
|
||||
expect(c._urlSegment).toBe(url.root);
|
||||
expect(c._lastPathIndex).toBe(-1);
|
||||
});
|
||||
|
@ -486,9 +493,9 @@ describe('recognize', () => {
|
|||
]
|
||||
}],
|
||||
'a', (s: RouterStateSnapshot) => {
|
||||
checkActivatedRoute(s.firstChild(s.root) !, 'a', {}, ComponentA);
|
||||
checkActivatedRoute((s as any).firstChild(s.root) !, 'a', {}, ComponentA);
|
||||
|
||||
const c = s.children(s.firstChild(s.root) !);
|
||||
const c = (s as any).children((s as any).firstChild(s.root) !);
|
||||
checkActivatedRoute(c[0], '', {}, ComponentB);
|
||||
checkActivatedRoute(c[1], '', {}, ComponentC, 'aux');
|
||||
});
|
||||
|
@ -505,9 +512,9 @@ describe('recognize', () => {
|
|||
]
|
||||
}],
|
||||
'a', (s: RouterStateSnapshot) => {
|
||||
checkActivatedRoute(s.firstChild(s.root) !, 'a', {}, ComponentA);
|
||||
checkActivatedRoute((s as any).firstChild(s.root) !, 'a', {}, ComponentA);
|
||||
|
||||
const c = s.children(s.firstChild(s.root) !);
|
||||
const c = (s as any).children((s as any).firstChild(s.root) !);
|
||||
checkActivatedRoute(c[0], '', {}, ComponentB);
|
||||
checkActivatedRoute(c[1], '', {}, ComponentC, 'aux');
|
||||
});
|
||||
|
@ -524,9 +531,9 @@ describe('recognize', () => {
|
|||
]
|
||||
}],
|
||||
'a/(aux:c)', (s: RouterStateSnapshot) => {
|
||||
checkActivatedRoute(s.firstChild(s.root) !, 'a', {}, ComponentA);
|
||||
checkActivatedRoute((s as any).firstChild(s.root) !, 'a', {}, ComponentA);
|
||||
|
||||
const c = s.children(s.firstChild(s.root) !);
|
||||
const c = (s as any).children((s as any).firstChild(s.root) !);
|
||||
checkActivatedRoute(c[0], '', {}, ComponentB);
|
||||
checkActivatedRoute(c[1], 'c', {}, ComponentC, 'aux');
|
||||
});
|
||||
|
@ -541,7 +548,7 @@ describe('recognize', () => {
|
|||
'(aux:c)', (s: RouterStateSnapshot) => {
|
||||
checkActivatedRoute(s.root, '', {}, RootComponent);
|
||||
|
||||
const children = s.children(s.root);
|
||||
const children = (s as any).children(s.root);
|
||||
expect(children.length).toEqual(2);
|
||||
checkActivatedRoute(children[0], '', {}, ComponentA);
|
||||
checkActivatedRoute(children[1], 'c', {}, ComponentC, 'aux');
|
||||
|
@ -566,13 +573,13 @@ describe('recognize', () => {
|
|||
]
|
||||
}],
|
||||
'a/(d//aux:e)', (s: RouterStateSnapshot) => {
|
||||
checkActivatedRoute(s.firstChild(s.root) !, 'a', {}, ComponentA);
|
||||
checkActivatedRoute((s as any).firstChild(s.root) !, 'a', {}, ComponentA);
|
||||
|
||||
const c = s.children(s.firstChild(s.root) !);
|
||||
const c = (s as any).children((s as any).firstChild(s.root) !);
|
||||
checkActivatedRoute(c[0], '', {}, ComponentB);
|
||||
checkActivatedRoute(s.firstChild(c[0]) !, 'd', {}, ComponentD);
|
||||
checkActivatedRoute((s as any).firstChild(c[0]) !, 'd', {}, ComponentD);
|
||||
checkActivatedRoute(c[1], '', {}, ComponentC, 'aux');
|
||||
checkActivatedRoute(s.firstChild(c[1]) !, 'e', {}, ComponentE);
|
||||
checkActivatedRoute((s as any).firstChild(c[1]) !, 'e', {}, ComponentE);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -582,7 +589,7 @@ describe('recognize', () => {
|
|||
it('should support simple wildcards', () => {
|
||||
checkRecognize(
|
||||
[{path: '**', component: ComponentA}], 'a/b/c/d;a1=11', (s: RouterStateSnapshot) => {
|
||||
checkActivatedRoute(s.firstChild(s.root) !, 'a/b/c/d', {a1: '11'}, ComponentA);
|
||||
checkActivatedRoute((s as any).firstChild(s.root) !, 'a/b/c/d', {a1: '11'}, ComponentA);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -598,10 +605,10 @@ describe('recognize', () => {
|
|||
]
|
||||
}],
|
||||
'p/11;pp=22/(a;pa=33//aux:b;pb=44)', (s: RouterStateSnapshot) => {
|
||||
const p = s.firstChild(s.root) !;
|
||||
const p = (s as any).firstChild(s.root) !;
|
||||
checkActivatedRoute(p, 'p/11', {id: '11', pp: '22'}, undefined !);
|
||||
|
||||
const c = s.children(p);
|
||||
const c = (s as any).children(p);
|
||||
checkActivatedRoute(c[0], 'a', {id: '11', pp: '22', pa: '33'}, ComponentA);
|
||||
checkActivatedRoute(c[1], 'b', {id: '11', pp: '22', pb: '44'}, ComponentB, 'aux');
|
||||
});
|
||||
|
@ -621,16 +628,16 @@ describe('recognize', () => {
|
|||
}]
|
||||
}],
|
||||
'p/11/a/victor/b/c', (s: RouterStateSnapshot) => {
|
||||
const p = s.firstChild(s.root) !;
|
||||
const p = (s as any).firstChild(s.root) !;
|
||||
checkActivatedRoute(p, 'p/11', {id: '11'}, undefined !);
|
||||
|
||||
const a = s.firstChild(p) !;
|
||||
const a = (s as any).firstChild(p) !;
|
||||
checkActivatedRoute(a, 'a/victor', {id: '11', name: 'victor'}, undefined !);
|
||||
|
||||
const b = s.firstChild(a) !;
|
||||
const b = (s as any).firstChild(a) !;
|
||||
checkActivatedRoute(b, 'b', {id: '11', name: 'victor'}, ComponentB);
|
||||
|
||||
const c = s.firstChild(b) !;
|
||||
const c = (s as any).firstChild(b) !;
|
||||
checkActivatedRoute(c, 'c', {}, ComponentC);
|
||||
});
|
||||
});
|
||||
|
@ -648,7 +655,7 @@ describe('recognize', () => {
|
|||
}]
|
||||
}]
|
||||
}],
|
||||
'p/11/a/victor/b/c', (s: RouterStateSnapshot) => {
|
||||
'p/11/a/victor/b/c', (s: any /* RouterStateSnapshot */) => {
|
||||
const c = s.firstChild(s.firstChild(s.firstChild(s.firstChild(s.root) !) !) !) !;
|
||||
checkActivatedRoute(c, 'c', {id: '11', name: 'victor'}, ComponentC);
|
||||
}, 'always');
|
||||
|
@ -660,7 +667,7 @@ describe('recognize', () => {
|
|||
checkRecognize(
|
||||
[{path: 'a', component: ComponentA, children: [{path: 'b', component: ComponentB}]}],
|
||||
'/a', (s: RouterStateSnapshot) => {
|
||||
const a = s.firstChild(s.root);
|
||||
const a = (s as any).firstChild(s.root);
|
||||
checkActivatedRoute(a !, 'a', {}, ComponentA);
|
||||
});
|
||||
});
|
||||
|
@ -676,9 +683,9 @@ describe('recognize', () => {
|
|||
]
|
||||
}],
|
||||
'/a', (s: RouterStateSnapshot) => {
|
||||
const a = s.firstChild(s.root) !;
|
||||
const a = (s as any).firstChild(s.root) !;
|
||||
checkActivatedRoute(a, 'a', {}, ComponentA);
|
||||
checkActivatedRoute(a.children[0], '', {}, ComponentC, 'aux');
|
||||
checkActivatedRoute((a as any).children[0], '', {}, ComponentC, 'aux');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -700,9 +707,9 @@ describe('recognize', () => {
|
|||
children: [{path: 'b', component: ComponentB}]
|
||||
}] as any,
|
||||
'/a/1;p=99/b', (s: RouterStateSnapshot) => {
|
||||
const a = s.root.firstChild !;
|
||||
const a = (s as any).root.firstChild !;
|
||||
checkActivatedRoute(a, 'a/1', {id: '1', p: '99'}, ComponentA);
|
||||
checkActivatedRoute(a.firstChild !, 'b', {}, ComponentB);
|
||||
checkActivatedRoute((a as any).firstChild !, 'b', {}, ComponentB);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -710,7 +717,7 @@ describe('recognize', () => {
|
|||
const matcher = (s: any, g: any, r: any) => s.length === 0 ? ({consumed: s}) : null;
|
||||
|
||||
checkRecognize([{matcher, component: ComponentA}] as any, '', (s: RouterStateSnapshot) => {
|
||||
const a = s.root.firstChild !;
|
||||
const a = (s as any).root.firstChild !;
|
||||
checkActivatedRoute(a, '', {}, ComponentA);
|
||||
});
|
||||
});
|
||||
|
@ -721,7 +728,7 @@ describe('recognize', () => {
|
|||
checkRecognize(
|
||||
[{path: 'a', component: ComponentA, children: [{matcher, component: ComponentB}]}] as any,
|
||||
'a', (s: RouterStateSnapshot) => {
|
||||
const a = s.root.firstChild !;
|
||||
const a = (s as any).root.firstChild !;
|
||||
checkActivatedRoute(a, 'a', {}, ComponentA);
|
||||
});
|
||||
});
|
||||
|
@ -771,7 +778,7 @@ describe('recognize', () => {
|
|||
|
||||
function checkRecognize(
|
||||
config: Routes, url: string, callback: any,
|
||||
paramsInheritanceStrategy?: ParamsInheritanceStrategy): void {
|
||||
paramsInheritanceStrategy?: 'emptyOnly' | 'always'): void {
|
||||
recognize(RootComponent, config, tree(url), url, paramsInheritanceStrategy)
|
||||
.subscribe(callback, e => { throw e; });
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ describe('Router', () => {
|
|||
const r: Router = TestBed.get(Router);
|
||||
const root = r.routerState.root;
|
||||
|
||||
r.resetRootComponentType(NewRootComponent);
|
||||
(r as any).resetRootComponentType(NewRootComponent);
|
||||
|
||||
expect(r.routerState.root).toBe(root);
|
||||
});
|
||||
|
@ -103,7 +103,7 @@ describe('Router', () => {
|
|||
let result = false;
|
||||
const childSnapshot =
|
||||
createActivatedRouteSnapshot({component: 'child', routeConfig: {path: 'child'}});
|
||||
const futureState = new RouterStateSnapshot(
|
||||
const futureState = new (RouterStateSnapshot as any)(
|
||||
'url', new TreeNode(empty.root, [new TreeNode(childSnapshot, [])]));
|
||||
|
||||
const p = new PreActivation(futureState, empty, TestBed, (evt) => { events.push(evt); });
|
||||
|
@ -132,7 +132,7 @@ describe('Router', () => {
|
|||
{component: 'grandchild', routeConfig: {path: 'grandchild'}});
|
||||
const greatGrandchildSnapshot = createActivatedRouteSnapshot(
|
||||
{component: 'great-grandchild', routeConfig: {path: 'great-grandchild'}});
|
||||
const futureState = new RouterStateSnapshot(
|
||||
const futureState = new (RouterStateSnapshot as any)(
|
||||
'url',
|
||||
new TreeNode(
|
||||
empty.root, [new TreeNode(childSnapshot, [
|
||||
|
@ -164,9 +164,9 @@ describe('Router', () => {
|
|||
createActivatedRouteSnapshot({component: 'child', routeConfig: {path: 'child'}});
|
||||
const grandchildSnapshot = createActivatedRouteSnapshot(
|
||||
{component: 'grandchild', routeConfig: {path: 'grandchild'}});
|
||||
const currentState = new RouterStateSnapshot(
|
||||
const currentState = new (RouterStateSnapshot as any)(
|
||||
'url', new TreeNode(empty.root, [new TreeNode(childSnapshot, [])]));
|
||||
const futureState = new RouterStateSnapshot(
|
||||
const futureState = new (RouterStateSnapshot as any)(
|
||||
'url',
|
||||
new TreeNode(
|
||||
empty.root, [new TreeNode(childSnapshot, [new TreeNode(grandchildSnapshot, [])])]));
|
||||
|
@ -203,11 +203,11 @@ describe('Router', () => {
|
|||
{component: 'greatgrandchild', routeConfig: {path: 'greatgrandchild'}});
|
||||
const greatGreatGrandchildSnapshot = createActivatedRouteSnapshot(
|
||||
{component: 'great-greatgrandchild', routeConfig: {path: 'great-greatgrandchild'}});
|
||||
const currentState = new RouterStateSnapshot(
|
||||
const currentState = new (RouterStateSnapshot as any)(
|
||||
'url',
|
||||
new TreeNode(
|
||||
empty.root, [new TreeNode(childSnapshot, [new TreeNode(grandchildSnapshot, [])])]));
|
||||
const futureState = new RouterStateSnapshot(
|
||||
const futureState = new (RouterStateSnapshot as any)(
|
||||
'url',
|
||||
new TreeNode(
|
||||
empty.root,
|
||||
|
@ -252,7 +252,7 @@ describe('Router', () => {
|
|||
const grandchildSnapshot = createActivatedRouteSnapshot(
|
||||
{component: 'grandchild', routeConfig: {canActivate: [CA_GRANDCHILD]}});
|
||||
|
||||
const futureState = new RouterStateSnapshot(
|
||||
const futureState = new (RouterStateSnapshot as any)(
|
||||
'url',
|
||||
new TreeNode(
|
||||
empty.root, [new TreeNode(childSnapshot, [new TreeNode(grandchildSnapshot, [])])]));
|
||||
|
@ -279,7 +279,7 @@ describe('Router', () => {
|
|||
const grandchildSnapshot = createActivatedRouteSnapshot(
|
||||
{component: 'grandchild', routeConfig: {canActivate: [CA_GRANDCHILD]}});
|
||||
|
||||
const futureState = new RouterStateSnapshot(
|
||||
const futureState = new (RouterStateSnapshot as any)(
|
||||
'url',
|
||||
new TreeNode(
|
||||
empty.root, [new TreeNode(childSnapshot, [new TreeNode(grandchildSnapshot, [])])]));
|
||||
|
@ -306,7 +306,7 @@ describe('Router', () => {
|
|||
const grandchildSnapshot = createActivatedRouteSnapshot(
|
||||
{component: 'grandchild', routeConfig: {canActivate: [CA_GRANDCHILD]}});
|
||||
|
||||
const futureState = new RouterStateSnapshot(
|
||||
const futureState = new (RouterStateSnapshot as any)(
|
||||
'url',
|
||||
new TreeNode(
|
||||
empty.root, [new TreeNode(childSnapshot, [new TreeNode(grandchildSnapshot, [])])]));
|
||||
|
@ -337,10 +337,10 @@ describe('Router', () => {
|
|||
const grandchildSnapshot = createActivatedRouteSnapshot(
|
||||
{component: 'grandchild', routeConfig: {canActivate: [CA_GRANDCHILD]}});
|
||||
|
||||
const currentState = new RouterStateSnapshot(
|
||||
const currentState = new (RouterStateSnapshot as any)(
|
||||
'prev', new TreeNode(empty.root, [new TreeNode(prevSnapshot, [])]));
|
||||
|
||||
const futureState = new RouterStateSnapshot(
|
||||
const futureState = new (RouterStateSnapshot as any)(
|
||||
'url',
|
||||
new TreeNode(
|
||||
empty.root, [new TreeNode(childSnapshot, [new TreeNode(grandchildSnapshot, [])])]));
|
||||
|
@ -368,9 +368,9 @@ describe('Router', () => {
|
|||
const grandchildSnapshot = createActivatedRouteSnapshot(
|
||||
{component: 'grandchild', routeConfig: {canActivate: [CA_GRANDCHILD]}});
|
||||
|
||||
const currentState = new RouterStateSnapshot(
|
||||
const currentState = new (RouterStateSnapshot as any)(
|
||||
'prev', new TreeNode(empty.root, [new TreeNode(prevSnapshot, [])]));
|
||||
const futureState = new RouterStateSnapshot(
|
||||
const futureState = new (RouterStateSnapshot as any)(
|
||||
'url',
|
||||
new TreeNode(
|
||||
empty.root, [new TreeNode(childSnapshot, [new TreeNode(grandchildSnapshot, [])])]));
|
||||
|
@ -400,12 +400,12 @@ describe('Router', () => {
|
|||
const grandchildSnapshot = createActivatedRouteSnapshot(
|
||||
{component: 'grandchild', routeConfig: {canActivate: [CA_GRANDCHILD]}});
|
||||
|
||||
const currentState = new RouterStateSnapshot(
|
||||
const currentState = new (RouterStateSnapshot as any)(
|
||||
'prev', new TreeNode(empty.root, [
|
||||
new TreeNode(prevChildSnapshot, [new TreeNode(prevGrandchildSnapshot, [])])
|
||||
]));
|
||||
|
||||
const futureState = new RouterStateSnapshot(
|
||||
const futureState = new (RouterStateSnapshot as any)(
|
||||
'url',
|
||||
new TreeNode(
|
||||
empty.root, [new TreeNode(childSnapshot, [new TreeNode(grandchildSnapshot, [])])]));
|
||||
|
@ -435,7 +435,8 @@ describe('Router', () => {
|
|||
*/
|
||||
const r = {data: 'resolver'};
|
||||
const n = createActivatedRouteSnapshot({component: 'a', resolve: r});
|
||||
const s = new RouterStateSnapshot('url', new TreeNode(empty.root, [new TreeNode(n, [])]));
|
||||
const s = new (RouterStateSnapshot as any)(
|
||||
'url', new TreeNode(empty.root, [new TreeNode(n, [])]));
|
||||
|
||||
checkResolveData(s, empty, inj, () => {
|
||||
expect(s.root.firstChild !.data).toEqual({data: 'resolver_value'});
|
||||
|
@ -456,7 +457,7 @@ describe('Router', () => {
|
|||
const parent = createActivatedRouteSnapshot({component: null !, resolve: parentResolve});
|
||||
const child = createActivatedRouteSnapshot({component: 'b', resolve: childResolve});
|
||||
|
||||
const s = new RouterStateSnapshot(
|
||||
const s = new (RouterStateSnapshot as any)(
|
||||
'url', new TreeNode(empty.root, [new TreeNode(parent, [new TreeNode(child, [])])]));
|
||||
|
||||
const inj = {get: (token: any) => () => Promise.resolve(`${token}_value`)};
|
||||
|
@ -478,12 +479,13 @@ describe('Router', () => {
|
|||
const r2 = {data: 'resolver2'};
|
||||
|
||||
const n1 = createActivatedRouteSnapshot({component: 'a', resolve: r1});
|
||||
const s1 = new RouterStateSnapshot('url', new TreeNode(empty.root, [new TreeNode(n1, [])]));
|
||||
const s1 = new (RouterStateSnapshot as any)(
|
||||
'url', new TreeNode(empty.root, [new TreeNode(n1, [])]));
|
||||
checkResolveData(s1, empty, inj, () => {});
|
||||
|
||||
const n21 = createActivatedRouteSnapshot({component: 'a', resolve: r1});
|
||||
const n22 = createActivatedRouteSnapshot({component: 'b', resolve: r2});
|
||||
const s2 = new RouterStateSnapshot(
|
||||
const s2 = new (RouterStateSnapshot as any)(
|
||||
'url', new TreeNode(empty.root, [new TreeNode(n21, [new TreeNode(n22, [])])]));
|
||||
checkResolveData(s2, s1, inj, () => {
|
||||
expect(s2.root.firstChild !.data).toEqual({data: 'resolver1_value'});
|
||||
|
|
|
@ -46,7 +46,7 @@ describe('RouterPreloader', () => {
|
|||
tick();
|
||||
|
||||
const c = router.config;
|
||||
expect(c[0]._loadedConfig).not.toBeDefined();
|
||||
expect((c[0] as any)._loadedConfig).not.toBeDefined();
|
||||
})));
|
||||
});
|
||||
|
||||
|
@ -97,12 +97,13 @@ describe('RouterPreloader', () => {
|
|||
const c = router.config;
|
||||
expect(c[0].loadChildren).toEqual('expected');
|
||||
|
||||
const loadedConfig: LoadedRouterConfig = c[0]._loadedConfig !;
|
||||
const loadedConfig: LoadedRouterConfig = (c[0] as any)._loadedConfig !;
|
||||
const module: any = loadedConfig.module;
|
||||
expect(loadedConfig.routes[0].path).toEqual('LoadedModule1');
|
||||
expect(module._parent).toBe(testModule);
|
||||
|
||||
const loadedConfig2: LoadedRouterConfig = loadedConfig.routes[0]._loadedConfig !;
|
||||
const loadedConfig2: LoadedRouterConfig =
|
||||
(loadedConfig.routes[0] as any)._loadedConfig !;
|
||||
const module2: any = loadedConfig2.module;
|
||||
expect(loadedConfig2.routes[0].path).toEqual('LoadedModule2');
|
||||
expect(module2._parent).toBe(module);
|
||||
|
@ -124,56 +125,57 @@ describe('RouterPreloader', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should work',
|
||||
fakeAsync(inject(
|
||||
[NgModuleFactoryLoader, RouterPreloader, Router, NgModuleRef, Compiler],
|
||||
(loader: SpyNgModuleFactoryLoader, preloader: RouterPreloader, router: Router,
|
||||
testModule: NgModuleRef<any>, compiler: Compiler) => {
|
||||
@NgModule()
|
||||
class LoadedModule2 {
|
||||
}
|
||||
it('should work', fakeAsync(inject(
|
||||
[NgModuleFactoryLoader, RouterPreloader, Router, NgModuleRef, Compiler],
|
||||
(loader: SpyNgModuleFactoryLoader, preloader: RouterPreloader,
|
||||
router: Router, testModule: NgModuleRef<any>, compiler: Compiler) => {
|
||||
@NgModule()
|
||||
class LoadedModule2 {
|
||||
}
|
||||
|
||||
const module2 = compiler.compileModuleSync(LoadedModule2).create(null);
|
||||
const module2 = compiler.compileModuleSync(LoadedModule2).create(null);
|
||||
|
||||
@NgModule({
|
||||
imports: [RouterModule.forChild([
|
||||
<Route>{
|
||||
path: 'LoadedModule2',
|
||||
loadChildren: 'no',
|
||||
_loadedConfig: {
|
||||
routes: [{path: 'LoadedModule3', loadChildren: 'expected3'}],
|
||||
module: module2,
|
||||
}
|
||||
},
|
||||
])]
|
||||
})
|
||||
class LoadedModule1 {
|
||||
}
|
||||
@NgModule({
|
||||
imports: [RouterModule.forChild([
|
||||
<Route>{
|
||||
path: 'LoadedModule2',
|
||||
loadChildren: 'no',
|
||||
_loadedConfig: {
|
||||
routes: [{path: 'LoadedModule3', loadChildren: 'expected3'}],
|
||||
module: module2,
|
||||
}
|
||||
},
|
||||
])]
|
||||
})
|
||||
class LoadedModule1 {
|
||||
}
|
||||
|
||||
@NgModule({imports: [RouterModule.forChild([])]})
|
||||
class LoadedModule3 {
|
||||
}
|
||||
@NgModule({imports: [RouterModule.forChild([])]})
|
||||
class LoadedModule3 {
|
||||
}
|
||||
|
||||
loader.stubbedModules = {
|
||||
expected: LoadedModule1,
|
||||
expected3: LoadedModule3,
|
||||
};
|
||||
loader.stubbedModules = {
|
||||
expected: LoadedModule1,
|
||||
expected3: LoadedModule3,
|
||||
};
|
||||
|
||||
preloader.preload().subscribe(() => {});
|
||||
preloader.preload().subscribe(() => {});
|
||||
|
||||
tick();
|
||||
tick();
|
||||
|
||||
const c = router.config;
|
||||
const c = router.config;
|
||||
|
||||
const loadedConfig: LoadedRouterConfig = c[0]._loadedConfig !;
|
||||
const module: any = loadedConfig.module;
|
||||
expect(module._parent).toBe(testModule);
|
||||
const loadedConfig: LoadedRouterConfig = (c[0] as any)._loadedConfig !;
|
||||
const module: any = loadedConfig.module;
|
||||
expect(module._parent).toBe(testModule);
|
||||
|
||||
const loadedConfig2: LoadedRouterConfig = loadedConfig.routes[0]._loadedConfig !;
|
||||
const loadedConfig3: LoadedRouterConfig = loadedConfig2.routes[0]._loadedConfig !;
|
||||
const module3: any = loadedConfig3.module;
|
||||
expect(module3._parent).toBe(module2);
|
||||
})));
|
||||
const loadedConfig2: LoadedRouterConfig =
|
||||
(loadedConfig.routes[0] as any)._loadedConfig !;
|
||||
const loadedConfig3: LoadedRouterConfig =
|
||||
(loadedConfig2.routes[0] as any)._loadedConfig !;
|
||||
const module3: any = loadedConfig3.module;
|
||||
expect(module3._parent).toBe(module2);
|
||||
})));
|
||||
});
|
||||
|
||||
describe('should ignore errors', () => {
|
||||
|
@ -204,8 +206,8 @@ describe('RouterPreloader', () => {
|
|||
tick();
|
||||
|
||||
const c = router.config;
|
||||
expect(c[0]._loadedConfig).not.toBeDefined();
|
||||
expect(c[1]._loadedConfig).toBeDefined();
|
||||
expect((c[0] as any)._loadedConfig).not.toBeDefined();
|
||||
expect((c[1] as any)._loadedConfig).toBeDefined();
|
||||
})));
|
||||
});
|
||||
});
|
||||
|
|
|
@ -27,7 +27,7 @@ describe('RouterState & Snapshot', () => {
|
|||
|
||||
const root = new TreeNode(a, [new TreeNode(b, []), new TreeNode(c, [])]);
|
||||
|
||||
state = new RouterStateSnapshot('url', root);
|
||||
state = new (RouterStateSnapshot as any)('url', root);
|
||||
});
|
||||
|
||||
it('should return first child', () => { expect(state.root.firstChild).toBe(b); });
|
||||
|
@ -69,7 +69,7 @@ describe('RouterState & Snapshot', () => {
|
|||
|
||||
const root = new TreeNode(a, [new TreeNode(b, []), new TreeNode(c, [])]);
|
||||
|
||||
state = new RouterState(root, <any>null);
|
||||
state = new (RouterState as any)(root, <any>null);
|
||||
});
|
||||
|
||||
it('should return first child', () => { expect(state.root.firstChild).toBe(b); });
|
||||
|
@ -100,10 +100,10 @@ describe('RouterState & Snapshot', () => {
|
|||
|
||||
describe('equalParamsAndUrlSegments', () => {
|
||||
function createSnapshot(params: Params, url: UrlSegment[]): ActivatedRouteSnapshot {
|
||||
const snapshot = new ActivatedRouteSnapshot(
|
||||
const snapshot = new (ActivatedRouteSnapshot as any)(
|
||||
url, params, <any>null, <any>null, <any>null, <any>null, <any>null, <any>null, <any>null,
|
||||
-1, null !);
|
||||
snapshot._routerState = new RouterStateSnapshot('', new TreeNode(snapshot, []));
|
||||
snapshot._routerState = new (RouterStateSnapshot as any)('', new TreeNode(snapshot, []));
|
||||
return snapshot;
|
||||
}
|
||||
|
||||
|
@ -116,10 +116,10 @@ describe('RouterState & Snapshot', () => {
|
|||
const snapshot1Parent = createSnapshot(parentParams[0], [new UrlSegment(urls[0], {})]);
|
||||
const snapshot2Parent = createSnapshot(parentParams[1], [new UrlSegment(urls[1], {})]);
|
||||
|
||||
snapshot1._routerState =
|
||||
new RouterStateSnapshot('', new TreeNode(snapshot1Parent, [new TreeNode(snapshot1, [])]));
|
||||
snapshot2._routerState =
|
||||
new RouterStateSnapshot('', new TreeNode(snapshot2Parent, [new TreeNode(snapshot2, [])]));
|
||||
(snapshot1 as any)._routerState = new (RouterStateSnapshot as any)(
|
||||
'', new TreeNode(snapshot1Parent, [new TreeNode(snapshot1, [])]));
|
||||
(snapshot2 as any)._routerState = new (RouterStateSnapshot as any)(
|
||||
'', new TreeNode(snapshot2Parent, [new TreeNode(snapshot2, [])]));
|
||||
|
||||
return [snapshot1, snapshot2];
|
||||
}
|
||||
|
@ -175,10 +175,10 @@ describe('RouterState & Snapshot', () => {
|
|||
const queryParams = {};
|
||||
const fragment = '';
|
||||
const data = {};
|
||||
const snapshot = new ActivatedRouteSnapshot(
|
||||
const snapshot = new (ActivatedRouteSnapshot as any)(
|
||||
url, params, queryParams, fragment, data, <any>null, <any>null, <any>null, <any>null, -1,
|
||||
null !);
|
||||
const state = new RouterStateSnapshot('', new TreeNode(snapshot, []));
|
||||
const state = new (RouterStateSnapshot as any)('', new TreeNode(snapshot, []));
|
||||
snapshot._routerState = state;
|
||||
return snapshot;
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ describe('RouterState & Snapshot', () => {
|
|||
const firstPlace = createSnapshot({a: 1}, []);
|
||||
const secondPlace = createSnapshot({a: 2}, []);
|
||||
route.snapshot = firstPlace;
|
||||
route._futureSnapshot = secondPlace;
|
||||
(route as any)._futureSnapshot = secondPlace;
|
||||
|
||||
let hasSeenDataChange = false;
|
||||
route.data.forEach((data) => { hasSeenDataChange = true; });
|
||||
|
@ -198,13 +198,13 @@ describe('RouterState & Snapshot', () => {
|
|||
});
|
||||
|
||||
function createActivatedRouteSnapshot(cmp: string) {
|
||||
return new ActivatedRouteSnapshot(
|
||||
return new (ActivatedRouteSnapshot as any)(
|
||||
<any>null, <any>null, <any>null, <any>null, <any>null, <any>null, <any>cmp, <any>null,
|
||||
<any>null, -1, null !);
|
||||
}
|
||||
|
||||
function createActivatedRoute(cmp: string) {
|
||||
return new ActivatedRoute(
|
||||
return new (ActivatedRoute as any)(
|
||||
new BehaviorSubject([new UrlSegment('', {})]), new BehaviorSubject({}), <any>null, <any>null,
|
||||
new BehaviorSubject({}), <any>null, <any>cmp, <any>null);
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ describe('SpyNgModuleFactoryLoader', () => {
|
|||
const r = new SpyNgModuleFactoryLoader(<any>null);
|
||||
|
||||
let error: any = null;
|
||||
r.load('two').catch(e => error = e);
|
||||
r.load('two').catch((e: any) => error = e);
|
||||
|
||||
tick();
|
||||
|
||||
|
|
|
@ -10,44 +10,44 @@ import {Tree, TreeNode} from '../../src/utils/tree';
|
|||
|
||||
describe('tree', () => {
|
||||
it('should return the root of the tree', () => {
|
||||
const t = new Tree<any>(new TreeNode<number>(1, []));
|
||||
const t = new Tree<any>(new TreeNode<number>(1, [])) as any;
|
||||
expect(t.root).toEqual(1);
|
||||
});
|
||||
|
||||
it('should return the parent of a node', () => {
|
||||
const t = new Tree<any>(new TreeNode<number>(1, [new TreeNode<number>(2, [])]));
|
||||
const t = new Tree<any>(new TreeNode<number>(1, [new TreeNode<number>(2, [])])) as any;
|
||||
expect(t.parent(1)).toEqual(null);
|
||||
expect(t.parent(2)).toEqual(1);
|
||||
});
|
||||
|
||||
it('should return the parent of a node (second child)', () => {
|
||||
const t = new Tree<any>(
|
||||
new TreeNode<number>(1, [new TreeNode<number>(2, []), new TreeNode<number>(3, [])]));
|
||||
new TreeNode<number>(1, [new TreeNode<number>(2, []), new TreeNode<number>(3, [])])) as any;
|
||||
expect(t.parent(1)).toEqual(null);
|
||||
expect(t.parent(3)).toEqual(1);
|
||||
});
|
||||
|
||||
it('should return the children of a node', () => {
|
||||
const t = new Tree<any>(new TreeNode<number>(1, [new TreeNode<number>(2, [])]));
|
||||
const t = new Tree<any>(new TreeNode<number>(1, [new TreeNode<number>(2, [])])) as any;
|
||||
expect(t.children(1)).toEqual([2]);
|
||||
expect(t.children(2)).toEqual([]);
|
||||
});
|
||||
|
||||
it('should return the first child of a node', () => {
|
||||
const t = new Tree<any>(new TreeNode<number>(1, [new TreeNode<number>(2, [])]));
|
||||
const t = new Tree<any>(new TreeNode<number>(1, [new TreeNode<number>(2, [])])) as any;
|
||||
expect(t.firstChild(1)).toEqual(2);
|
||||
expect(t.firstChild(2)).toEqual(null);
|
||||
});
|
||||
|
||||
it('should return the siblings of a node', () => {
|
||||
const t = new Tree<any>(
|
||||
new TreeNode<number>(1, [new TreeNode<number>(2, []), new TreeNode<number>(3, [])]));
|
||||
new TreeNode<number>(1, [new TreeNode<number>(2, []), new TreeNode<number>(3, [])])) as any;
|
||||
expect(t.siblings(2)).toEqual([3]);
|
||||
expect(t.siblings(1)).toEqual([]);
|
||||
});
|
||||
|
||||
it('should return the path to the root', () => {
|
||||
const t = new Tree<any>(new TreeNode<number>(1, [new TreeNode<number>(2, [])]));
|
||||
const t = new Tree<any>(new TreeNode<number>(1, [new TreeNode<number>(2, [])])) as any;
|
||||
expect(t.pathFromRoot(2)).toEqual([1, 2]);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library", "ts_web_test")
|
||||
load("@build_bazel_rules_nodejs//:defs.bzl", "jasmine_node_test")
|
||||
|
||||
ts_library(
|
||||
name = "test_lib",
|
||||
testonly = 1,
|
||||
srcs = glob(["**/*.ts"]),
|
||||
tsconfig = "//packages:tsconfig",
|
||||
deps = [
|
||||
"//packages:types",
|
||||
"//packages/core",
|
||||
"//packages/core/testing",
|
||||
"//packages/service-worker",
|
||||
"//packages/service-worker/testing",
|
||||
"//packages/service-worker/worker",
|
||||
"//packages/service-worker/worker/testing",
|
||||
"@rxjs",
|
||||
],
|
||||
)
|
||||
|
||||
jasmine_node_test(
|
||||
name = "test",
|
||||
bootstrap = ["angular_src/packages/_testing_init/init_node_spec.js"],
|
||||
deps = [
|
||||
":test_lib",
|
||||
"//packages/_testing_init:node",
|
||||
],
|
||||
)
|
||||
|
||||
ts_web_test(
|
||||
name = "test_web",
|
||||
bootstrap = [
|
||||
"//:angular_bootstrap_scripts",
|
||||
],
|
||||
# dissable since tests are running but not yet passing
|
||||
tags = ["manual"],
|
||||
# do not sort
|
||||
deps = [
|
||||
"//packages/_testing_init:browser",
|
||||
":test_lib",
|
||||
],
|
||||
)
|
|
@ -30,14 +30,14 @@ import {MockServiceWorkerContainer, MockServiceWorkerRegistration} from '../test
|
|||
|
||||
mock.setupSw();
|
||||
|
||||
comm.registration.subscribe(reg => { done(); });
|
||||
(comm as any).registration.subscribe((reg: any) => { done(); });
|
||||
});
|
||||
it('can access the registration when it comes after subscription', (done: DoneFn) => {
|
||||
const mock = new MockServiceWorkerContainer();
|
||||
const comm = new NgswCommChannel(mock as any, 'browser');
|
||||
const regPromise = mock.getRegistration() as any as MockServiceWorkerRegistration;
|
||||
|
||||
comm.registration.subscribe(reg => { done(); });
|
||||
(comm as any).registration.subscribe((reg: any) => { done(); });
|
||||
|
||||
mock.setupSw();
|
||||
});
|
||||
|
|
|
@ -65,7 +65,7 @@ const server = new MockServerStateBuilder().withStaticFiles(dist).withManifest(m
|
|||
const serverUpdate =
|
||||
new MockServerStateBuilder().withStaticFiles(distUpdate).withManifest(manifestUpdate).build();
|
||||
|
||||
(function(){
|
||||
(function() {
|
||||
// Skip environments that don't support the minimum APIs needed to run the SW tests.
|
||||
if (!SwTestHarness.envIsSupported()) {
|
||||
return;
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
|
||||
|
||||
ts_library(
|
||||
name = "testing",
|
||||
testonly = 1,
|
||||
srcs = glob(["**/*.ts"]),
|
||||
module_name = "@angular/service-worker/testing",
|
||||
tsconfig = "//packages:tsconfig",
|
||||
deps = [
|
||||
],
|
||||
)
|
|
@ -18,8 +18,6 @@ ts_library(
|
|||
jasmine_node_test(
|
||||
name = "test",
|
||||
srcs = [],
|
||||
# TODO(alxhub): re-enable when need for main() is removed
|
||||
tags = ["manual"],
|
||||
deps = [
|
||||
":test_lib",
|
||||
],
|
||||
|
|
|
@ -114,7 +114,7 @@ function asyncWrap(fn: () => Promise<void>): (done: DoneFn) => void {
|
|||
return (done: DoneFn) => { fn().then(() => done(), err => done.fail(err)); };
|
||||
}
|
||||
|
||||
(function(){
|
||||
(function() {
|
||||
// Skip environments that don't support the minimum APIs needed to run the SW tests.
|
||||
if (!SwTestHarness.envIsSupported()) {
|
||||
return;
|
||||
|
|
|
@ -139,7 +139,7 @@ const scope = new SwTestHarnessBuilder().withServerState(server).build();
|
|||
const manifestHash = sha1(JSON.stringify(manifest));
|
||||
const manifestUpdateHash = sha1(JSON.stringify(manifestUpdate));
|
||||
|
||||
(function(){
|
||||
(function() {
|
||||
// Skip environments that don't support the minimum APIs needed to run the SW tests.
|
||||
if (!SwTestHarness.envIsSupported()) {
|
||||
return;
|
||||
|
|
|
@ -10,7 +10,7 @@ import {IdleScheduler} from '../src/idle';
|
|||
import {SwTestHarness, SwTestHarnessBuilder} from '../testing/scope';
|
||||
import {async_beforeEach, async_fit, async_it} from './async';
|
||||
|
||||
(function(){
|
||||
(function() {
|
||||
// Skip environments that don't support the minimum APIs needed to run the SW tests.
|
||||
if (!SwTestHarness.envIsSupported()) {
|
||||
return;
|
||||
|
|
|
@ -29,7 +29,7 @@ const db = new CacheDatabase(scope, scope);
|
|||
|
||||
|
||||
|
||||
(function(){
|
||||
(function() {
|
||||
// Skip environments that don't support the minimum APIs needed to run the SW tests.
|
||||
if (!SwTestHarness.envIsSupported()) {
|
||||
return;
|
||||
|
|
|
@ -16,3 +16,6 @@
|
|||
/// <reference path="./es6-subset.d.ts" />
|
||||
/// <reference path="./system.d.ts" />
|
||||
/// <reference path="./goog.d.ts" />
|
||||
|
||||
declare let isNode: boolean;
|
||||
declare let isBrowser: boolean;
|
|
@ -0,0 +1,20 @@
|
|||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
|
||||
|
||||
ts_library(
|
||||
name = "upgrade",
|
||||
srcs = glob(
|
||||
[
|
||||
"*.ts",
|
||||
"src/**/*.ts",
|
||||
],
|
||||
),
|
||||
module_name = "@angular/upgrade",
|
||||
tsconfig = "//packages:tsconfig",
|
||||
deps = [
|
||||
"//packages/core",
|
||||
"//packages/platform-browser",
|
||||
"//packages/platform-browser-dynamic",
|
||||
],
|
||||
)
|
|
@ -0,0 +1,35 @@
|
|||
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library", "ts_web_test")
|
||||
load("@build_bazel_rules_nodejs//:defs.bzl", "jasmine_node_test")
|
||||
|
||||
ts_library(
|
||||
name = "test_lib",
|
||||
testonly = 1,
|
||||
srcs = glob(["**/*.ts"]),
|
||||
tsconfig = "//packages:tsconfig",
|
||||
deps = [
|
||||
"//packages:types",
|
||||
"//packages/core",
|
||||
"//packages/core/testing",
|
||||
"//packages/platform-browser",
|
||||
"//packages/platform-browser-dynamic",
|
||||
"//packages/platform-browser/testing",
|
||||
"//packages/upgrade",
|
||||
"//packages/upgrade/static",
|
||||
"@rxjs",
|
||||
],
|
||||
)
|
||||
|
||||
ts_web_test(
|
||||
name = "test_web",
|
||||
bootstrap = [
|
||||
"//:angular_bootstrap_scripts",
|
||||
"//:node_modules/angular/angular.js",
|
||||
],
|
||||
# dissable since tests are running but not yet passing
|
||||
tags = ["manual"],
|
||||
# do not sort
|
||||
deps = [
|
||||
"//packages/_testing_init:browser",
|
||||
":test_lib",
|
||||
],
|
||||
)
|
|
@ -14,6 +14,10 @@ import * as angular from '@angular/upgrade/src/common/angular1';
|
|||
import {UpgradeAdapter, UpgradeAdapterRef} from '@angular/upgrade/src/dynamic/upgrade_adapter';
|
||||
import {$digest, html, multiTrim} from './test_helpers';
|
||||
|
||||
declare global {
|
||||
export var inject: Function;
|
||||
}
|
||||
|
||||
{
|
||||
describe('adapter: ng1 to ng2', () => {
|
||||
beforeEach(() => destroyPlatform());
|
||||
|
|
|
@ -15,6 +15,9 @@ jasmine.DEFAULT_TIMEOUT_INTERVAL = 100;
|
|||
// we will call `__karma__.start()` later, once all the specs are loaded.
|
||||
__karma__.loaded = function() {};
|
||||
|
||||
window.isNode = false;
|
||||
window.isBrowser = true;
|
||||
|
||||
System.config({
|
||||
baseURL: '/base',
|
||||
defaultJSExtensions: true,
|
||||
|
|
|
@ -45,6 +45,9 @@ if (globsIndex < 0) {
|
|||
args = process.argv.slice(globsIndex + 1);
|
||||
}
|
||||
|
||||
(global as any).isNode = true;
|
||||
(global as any).isBrowser = false;
|
||||
|
||||
var specFiles: any =
|
||||
args.map(function(globstr: string):
|
||||
string[] {
|
||||
|
|
Loading…
Reference in New Issue