chore(tests): enable lint, make it green. (#10224)
This commit is contained in:
parent
27b87ef535
commit
00aa7a76b6
|
@ -97,7 +97,7 @@ gulp.task('lint', ['format:enforce', 'tools:build'], () => {
|
|||
// Built-in rules are at
|
||||
// https://github.com/palantir/tslint#supported-rules
|
||||
const tslintConfig = require('./tslint.json');
|
||||
return gulp.src(['modules/@angular/**/*.ts', '!modules/@angular/*/test/**'])
|
||||
return gulp.src(['modules/@angular/**/*.ts'])
|
||||
.pipe(tslint({
|
||||
tslint: require('tslint').default,
|
||||
configuration: tslintConfig,
|
||||
|
|
|
@ -581,7 +581,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
});
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
@Component({selector: 'test-cmp', directives: [NgClass, NgFor], template: ''})
|
||||
|
|
|
@ -6,8 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {beforeEach, beforeEachProviders, ddescribe, describe, iit, inject, it, xit,} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter, beforeEach, beforeEachProviders, ddescribe, describe, iit, inject, it, xit,} from '@angular/core/testing/testing_internal';
|
||||
import {TestComponentBuilder} from '@angular/core/testing';
|
||||
import {ListWrapper} from '../../src/facade/collection';
|
||||
import {IS_DART} from '../../src/facade/lang';
|
||||
|
@ -182,7 +181,7 @@ export function main() {
|
|||
.then((fixture) => {
|
||||
fixture.debugElement.componentInstance.items = 'whaaa';
|
||||
try {
|
||||
fixture.detectChanges()
|
||||
fixture.detectChanges();
|
||||
} catch (e) {
|
||||
expect(e.message).toContain(
|
||||
`Cannot find a differ supporting object 'whaaa' of type 'string'. NgFor only supports binding to Iterables such as Arrays.`);
|
||||
|
|
|
@ -6,9 +6,8 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {beforeEach, ddescribe, describe, iit, inject, it, xit,} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter, beforeEach, ddescribe, describe, iit, inject, it, xit,} from '@angular/core/testing/testing_internal';
|
||||
import {TestComponentBuilder} from '@angular/core/testing';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
import {expect} from '@angular/platform-browser/testing/matchers';
|
||||
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
||||
|
||||
|
|
|
@ -6,8 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {beforeEachProviders, beforeEach, ddescribe, describe, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter, beforeEachProviders, beforeEach, ddescribe, describe, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal';
|
||||
import {TestComponentBuilder} from '@angular/core/testing';
|
||||
|
||||
import {Component, Injectable} from '@angular/core';
|
||||
|
|
|
@ -6,9 +6,8 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {beforeEach, beforeEachProviders, ddescribe, xdescribe, describe, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter, beforeEach, beforeEachProviders, ddescribe, xdescribe, describe, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal';
|
||||
import {TestComponentBuilder} from '@angular/core/testing';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
|
||||
import {StringMapWrapper} from '../../src/facade/collection';
|
||||
|
||||
|
@ -191,7 +190,7 @@ export function main() {
|
|||
async.done();
|
||||
});
|
||||
}));
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
@Component({selector: 'test-cmp', directives: [NgStyle], template: ''})
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {beforeEach, ddescribe, describe, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter, beforeEach, ddescribe, describe, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal';
|
||||
|
||||
import {Component} from '@angular/core';
|
||||
import {TestComponentBuilder} from '@angular/core/testing';
|
||||
|
||||
|
|
|
@ -6,9 +6,8 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {beforeEach, ddescribe, describe, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter, beforeEach, ddescribe, describe, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal';
|
||||
import {TestComponentBuilder} from '@angular/core/testing';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
import {Component, Directive, TemplateRef, ContentChildren, QueryList} from '@angular/core';
|
||||
import {NgTemplateOutlet} from '@angular/common';
|
||||
|
||||
|
|
|
@ -6,12 +6,11 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {beforeEach, ddescribe, describe, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter, beforeEach, ddescribe, describe, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal';
|
||||
import {TestComponentBuilder} from '@angular/core/testing';
|
||||
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
||||
import {Component, Directive} from '@angular/core';
|
||||
import {ElementRef} from '@angular/core/src/linker/element_ref';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
|
||||
export function main() {
|
||||
describe('non-bindable', () => {
|
||||
|
@ -61,7 +60,7 @@ export function main() {
|
|||
async.done();
|
||||
});
|
||||
}));
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
@Directive({selector: '[test-dec]'})
|
||||
|
|
|
@ -8,11 +8,9 @@
|
|||
|
||||
import {NgFor, NgIf} from '@angular/common';
|
||||
import {Control, ControlGroup, ControlValueAccessor, DeprecatedFormsModule, NG_ASYNC_VALIDATORS, NG_VALIDATORS, NgControl, NgForm, RadioButtonState, Validator, Validators} from '@angular/common/src/forms-deprecated';
|
||||
import {Component, Directive, EventEmitter, Output} from '@angular/core';
|
||||
import {Input, Provider, forwardRef} from '@angular/core';
|
||||
import {Component, Directive, EventEmitter, Input, Output, Provider, forwardRef} from '@angular/core';
|
||||
import {ComponentFixture, TestComponentBuilder, configureModule, fakeAsync, flushMicrotasks, tick} from '@angular/core/testing';
|
||||
import {afterEach, beforeEach, ddescribe, describe, expect, iit, inject, it, xit} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter, afterEach, beforeEach, ddescribe, describe, expect, iit, inject, it, xit} from '@angular/core/testing/testing_internal';
|
||||
import {By} from '@angular/platform-browser/src/dom/debug/by';
|
||||
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
||||
import {dispatchEvent} from '@angular/platform-browser/testing/browser_util';
|
||||
|
@ -24,7 +22,7 @@ import {PromiseWrapper} from '../../src/facade/promise';
|
|||
export function main() {
|
||||
describe('integration tests', () => {
|
||||
|
||||
beforeEach(() => {configureModule({modules: [DeprecatedFormsModule]})});
|
||||
beforeEach(() => { configureModule({modules: [DeprecatedFormsModule]}); });
|
||||
|
||||
it('should initialize DOM elements with the given form object',
|
||||
inject(
|
||||
|
|
|
@ -6,9 +6,8 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {ddescribe, describe, it, iit, xit, expect, beforeEach, afterEach, inject,} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter, ddescribe, describe, it, iit, xit, expect, beforeEach, afterEach, inject,} from '@angular/core/testing/testing_internal';
|
||||
import {fakeAsync, flushMicrotasks, tick} from '@angular/core/testing';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
import {ControlGroup, Control, ControlArray, Validators} from '@angular/common/src/forms-deprecated';
|
||||
import {IS_DART, isPresent} from '../../src/facade/lang';
|
||||
import {PromiseWrapper} from '../../src/facade/promise';
|
||||
|
@ -430,7 +429,7 @@ export function main() {
|
|||
|
||||
// rename contains into has
|
||||
it('should return false when the component is not included',
|
||||
() => { expect(group.contains('optional')).toEqual(false); })
|
||||
() => { expect(group.contains('optional')).toEqual(false); });
|
||||
|
||||
it('should return false when there is no component with the given name',
|
||||
() => { expect(group.contains('something else')).toEqual(false); });
|
||||
|
@ -605,7 +604,7 @@ export function main() {
|
|||
expect(g.errors).toEqual({'async': true});
|
||||
expect(g.find(['one']).errors).toEqual({'async': true});
|
||||
}));
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
describe('ControlArray', () => {
|
||||
|
@ -829,7 +828,7 @@ export function main() {
|
|||
expect(g.errors).toEqual({'async': true});
|
||||
expect(g.pending).toEqual(false);
|
||||
}));
|
||||
})
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -19,9 +19,9 @@ export function main() {
|
|||
function validator(key: string, error: any) {
|
||||
return function(c: AbstractControl) {
|
||||
var r = {};
|
||||
(r as any /** TODO #9100 */)[key] = error;
|
||||
(r as any)[key] = error;
|
||||
return r;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
class AsyncValidatorDirective {
|
||||
|
|
|
@ -6,8 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {ddescribe, describe, it, iit, xit, expect, beforeEach, afterEach, inject,} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter, ddescribe, describe, it, iit, xit, expect, beforeEach, afterEach, inject,} from '@angular/core/testing/testing_internal';
|
||||
import {SpyChangeDetectorRef} from '../spies';
|
||||
import {isBlank} from '../../src/facade/lang';
|
||||
import {AsyncPipe} from '@angular/common';
|
||||
|
@ -45,7 +44,7 @@ export function main() {
|
|||
TimerWrapper.setTimeout(() => {
|
||||
expect(pipe.transform(emitter)).toEqual(new WrappedValue(message));
|
||||
async.done();
|
||||
}, 0)
|
||||
}, 0);
|
||||
}));
|
||||
|
||||
|
||||
|
@ -58,7 +57,7 @@ export function main() {
|
|||
pipe.transform(emitter);
|
||||
expect(pipe.transform(emitter)).toBe(message);
|
||||
async.done();
|
||||
}, 0)
|
||||
}, 0);
|
||||
}));
|
||||
|
||||
it('should dispose of the existing subscription when subscribing to a new observable',
|
||||
|
@ -74,7 +73,7 @@ export function main() {
|
|||
TimerWrapper.setTimeout(() => {
|
||||
expect(pipe.transform(newEmitter)).toBe(null);
|
||||
async.done();
|
||||
}, 0)
|
||||
}, 0);
|
||||
}));
|
||||
|
||||
it('should request a change detection check upon receiving a new value',
|
||||
|
@ -85,7 +84,7 @@ export function main() {
|
|||
TimerWrapper.setTimeout(() => {
|
||||
expect(ref.spy('markForCheck')).toHaveBeenCalled();
|
||||
async.done();
|
||||
}, 10)
|
||||
}, 10);
|
||||
}));
|
||||
});
|
||||
|
||||
|
@ -103,7 +102,7 @@ export function main() {
|
|||
TimerWrapper.setTimeout(() => {
|
||||
expect(pipe.transform(emitter)).toBe(null);
|
||||
async.done();
|
||||
}, 0)
|
||||
}, 0);
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
@ -135,7 +134,7 @@ export function main() {
|
|||
TimerWrapper.setTimeout(() => {
|
||||
expect(pipe.transform(completer.promise)).toEqual(new WrappedValue(message));
|
||||
async.done();
|
||||
}, timer)
|
||||
}, timer);
|
||||
}));
|
||||
|
||||
it('should return unwrapped value when nothing has changed since the last call',
|
||||
|
@ -147,7 +146,7 @@ export function main() {
|
|||
pipe.transform(completer.promise);
|
||||
expect(pipe.transform(completer.promise)).toBe(message);
|
||||
async.done();
|
||||
}, timer)
|
||||
}, timer);
|
||||
}));
|
||||
|
||||
it('should dispose of the existing subscription when subscribing to a new promise',
|
||||
|
@ -163,7 +162,7 @@ export function main() {
|
|||
TimerWrapper.setTimeout(() => {
|
||||
expect(pipe.transform(newCompleter.promise)).toBe(null);
|
||||
async.done();
|
||||
}, timer)
|
||||
}, timer);
|
||||
}));
|
||||
|
||||
it('should request a change detection check upon receiving a new value',
|
||||
|
@ -175,7 +174,7 @@ export function main() {
|
|||
TimerWrapper.setTimeout(() => {
|
||||
expect(markForCheck).toHaveBeenCalled();
|
||||
async.done();
|
||||
}, timer)
|
||||
}, timer);
|
||||
}));
|
||||
|
||||
describe('ngOnDestroy', () => {
|
||||
|
@ -186,7 +185,7 @@ export function main() {
|
|||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
pipe.transform(completer.promise);
|
||||
expect(pipe.transform(completer.promise)).toBe(null);
|
||||
completer.resolve(message)
|
||||
completer.resolve(message);
|
||||
|
||||
|
||||
TimerWrapper.setTimeout(() => {
|
||||
|
|
|
@ -6,8 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {ddescribe, describe, it, iit, xit, expect, beforeEach, afterEach, inject,} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter, ddescribe, describe, it, iit, xit, expect, beforeEach, afterEach, inject,} from '@angular/core/testing/testing_internal';
|
||||
import {TestComponentBuilder} from '@angular/core/testing';
|
||||
import {Json, StringWrapper} from '../../src/facade/lang';
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
*/
|
||||
|
||||
import {ddescribe, describe, it, iit, xit, expect, beforeEach, afterEach, inject,} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
|
||||
import {ReplacePipe} from '@angular/common';
|
||||
import {RegExpWrapper, StringJoiner} from '../../src/facade/lang';
|
||||
|
|
|
@ -6,9 +6,8 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {ddescribe, describe, it, iit, xit, expect, beforeEach, afterEach, inject,} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter, ddescribe, describe, it, iit, xit, expect, beforeEach, afterEach, inject,} from '@angular/core/testing/testing_internal';
|
||||
import {TestComponentBuilder} from '@angular/core/testing';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
import {browserDetection} from '@angular/platform-browser/testing/browser_util';
|
||||
|
||||
import {Component} from '@angular/core';
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
import * as ts from 'typescript';
|
||||
|
||||
import {ReflectorHost, ReflectorHostContext} from '../src/reflector_host';
|
||||
import {ReflectorHostContext} from '../src/reflector_host';
|
||||
|
||||
export type Entry = string | Directory;
|
||||
|
||||
|
@ -19,7 +19,7 @@ export class MockContext implements ReflectorHostContext {
|
|||
|
||||
fileExists(fileName: string): boolean { return typeof this.getEntry(fileName) === 'string'; }
|
||||
|
||||
directoryExists(path: string): boolean { return typeof this.getEntry(path) === 'object' }
|
||||
directoryExists(path: string): boolean { return typeof this.getEntry(path) === 'object'; }
|
||||
|
||||
readFile(fileName: string): string|undefined {
|
||||
let data = this.getEntry(fileName);
|
||||
|
|
|
@ -21,7 +21,7 @@ describe('reflector_host', () => {
|
|||
|
||||
beforeEach(() => {
|
||||
context = new MockContext('/tmp/src', clone(FILES));
|
||||
host = new MockCompilerHost(context)
|
||||
host = new MockCompilerHost(context);
|
||||
program = ts.createProgram(
|
||||
['main.ts'], {
|
||||
module: ts.ModuleKind.CommonJS,
|
||||
|
@ -93,10 +93,10 @@ describe('reflector_host', () => {
|
|||
expect(reflectorHost.getStaticSymbol('angularjs', 'SomeAngularSymbol')).toBeDefined();
|
||||
});
|
||||
|
||||
it('should be able to read a metadata file',
|
||||
() => {
|
||||
expect(reflectorHost.getMetadataFor('node_modules/@angular/core.d.ts'))
|
||||
.toEqual({__symbolic: 'module', version: 1, metadata: {foo: {__symbolic: 'class'}}})});
|
||||
it('should be able to read a metadata file', () => {
|
||||
expect(reflectorHost.getMetadataFor('node_modules/@angular/core.d.ts'))
|
||||
.toEqual({__symbolic: 'module', version: 1, metadata: {foo: {__symbolic: 'class'}}});
|
||||
});
|
||||
|
||||
it('should be able to read metadata from an otherwise unused .d.ts file ', () => {
|
||||
expect(reflectorHost.getMetadataFor('node_modules/@angular/unused.d.ts')).toBeUndefined();
|
||||
|
@ -107,7 +107,8 @@ describe('reflector_host', () => {
|
|||
});
|
||||
});
|
||||
|
||||
const dummyModule = 'export let foo: any[];'
|
||||
const dummyModule = 'export let foo: any[];';
|
||||
|
||||
const FILES: Entry = {
|
||||
'tmp': {
|
||||
'src': {
|
||||
|
@ -134,7 +135,7 @@ const FILES: Entry = {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function clone(entry: Entry): Entry {
|
||||
if (typeof entry === 'string') {
|
||||
|
|
|
@ -51,7 +51,7 @@ export function main() {
|
|||
};
|
||||
|
||||
var getAnimationAstFromEntryAst =
|
||||
(ast: AnimationEntryAst) => { return ast.stateTransitions[0].animation; }
|
||||
(ast: AnimationEntryAst) => { return ast.stateTransitions[0].animation; };
|
||||
|
||||
var parseAnimationAst = (data: AnimationMetadata[]) => {
|
||||
return getAnimationAstFromEntryAst(parseAnimation(data).ast);
|
||||
|
|
|
@ -176,7 +176,7 @@ export function main() {
|
|||
describe('CompileAnimationAnimateMetadata', () => {
|
||||
it('should serialize with full data', () => {
|
||||
let full = new CompileAnimationAnimateMetadata(
|
||||
'1s linear', new CompileAnimationStyleMetadata(0, [{'opacity': 0.5, 'color': 'blue'}]))
|
||||
'1s linear', new CompileAnimationStyleMetadata(0, [{'opacity': 0.5, 'color': 'blue'}]));
|
||||
expect(CompileAnimationAnimateMetadata.fromJson(full.toJson())).toEqual(full);
|
||||
});
|
||||
|
||||
|
|
|
@ -22,6 +22,9 @@ function _assertTokens(tokens: CssToken[], valuesArr: string[]): void {
|
|||
class MyVisitor implements CssAstVisitor {
|
||||
captures: {[key: string]: any[]} = {};
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_capture(method: string, ast: CssAst, context: any) {
|
||||
this.captures[method] = isPresent(this.captures[method]) ? this.captures[method] : [];
|
||||
this.captures[method].push([ast, context]);
|
||||
|
|
|
@ -13,8 +13,7 @@ import {XHR} from '@angular/compiler/src/xhr';
|
|||
import {MockXHR} from '@angular/compiler/testing/xhr_mock';
|
||||
import {ViewEncapsulation} from '@angular/core/src/metadata/view';
|
||||
import {configureCompiler} from '@angular/core/testing';
|
||||
import {beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xit} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xit} from '@angular/core/testing/testing_internal';
|
||||
|
||||
import {SpyXHR} from './spies';
|
||||
import {TEST_COMPILER_PROVIDERS} from './test_bindings';
|
||||
|
@ -53,7 +52,7 @@ export function main() {
|
|||
templateUrl: null,
|
||||
styles: [],
|
||||
styleUrls: []
|
||||
}))
|
||||
}));
|
||||
expect(template.template).toEqual('a');
|
||||
expect(template.templateUrl).toEqual('package:some/module/a.js');
|
||||
}));
|
||||
|
@ -66,7 +65,7 @@ export function main() {
|
|||
templateUrl: null,
|
||||
styles: [],
|
||||
styleUrls: ['test.css']
|
||||
}))
|
||||
}));
|
||||
expect(template.styleUrls).toEqual(['package:some/module/test.css']);
|
||||
}));
|
||||
|
||||
|
@ -79,7 +78,7 @@ export function main() {
|
|||
templateUrl: null,
|
||||
styles: [],
|
||||
styleUrls: []
|
||||
}))
|
||||
}));
|
||||
expect(template.styleUrls).toEqual(['package:some/module/test.css']);
|
||||
}));
|
||||
|
||||
|
@ -91,7 +90,7 @@ export function main() {
|
|||
templateUrl: null,
|
||||
styles: [],
|
||||
styleUrls: ['test.css']
|
||||
}))
|
||||
}));
|
||||
expect(template.encapsulation).toEqual(ViewEncapsulation.Emulated);
|
||||
}));
|
||||
|
||||
|
@ -107,7 +106,7 @@ export function main() {
|
|||
templateUrl: null,
|
||||
styles: [],
|
||||
styleUrls: ['test.css']
|
||||
}))
|
||||
}));
|
||||
expect(template.encapsulation).toEqual(ViewEncapsulation.None);
|
||||
}));
|
||||
});
|
||||
|
@ -277,7 +276,7 @@ export function main() {
|
|||
dirType,
|
||||
new CompileTemplateMetadata({encapsulation: null, styles: [], styleUrls: []}), 'a',
|
||||
'package:some/module/');
|
||||
expect(template.template).toEqual('a')
|
||||
expect(template.template).toEqual('a');
|
||||
}));
|
||||
|
||||
it('should collect ngContent',
|
||||
|
|
|
@ -312,7 +312,7 @@ export function main() {
|
|||
if (binding.keyIsVar) {
|
||||
return 'let ' + binding.key + (isBlank(binding.name) ? '=null' : '=' + binding.name);
|
||||
} else {
|
||||
return binding.key + (isBlank(binding.expression) ? '' : `=${binding.expression}`)
|
||||
return binding.key + (isBlank(binding.expression) ? '' : `=${binding.expression}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -550,7 +550,7 @@ export function main() {
|
|||
it('should be able to recover from a missing ]', () => recover('[a,b', '[a, b]'));
|
||||
it('should be able to recover from a missing selector', () => recover('a.'));
|
||||
it('should be able to recover from a missing selector in a array literal',
|
||||
() => recover('[[a.], b, c]'))
|
||||
() => recover('[[a.], b, c]'));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
/**
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {AST, Binary, BindingPipe, Chain, Conditional, EmptyExpr, FunctionCall, ImplicitReceiver, Interpolation, KeyedRead, KeyedWrite, LiteralArray, LiteralMap, LiteralPrimitive, MethodCall, ParseSpan, PrefixNot, PropertyRead, PropertyWrite, Quote, RecursiveAstVisitor, SafeMethodCall, SafePropertyRead} from '../../src/expression_parser/ast';
|
||||
|
||||
import {unparse} from './unparser';
|
||||
|
|
|
@ -65,13 +65,14 @@ export function main() {
|
|||
]);
|
||||
});
|
||||
|
||||
it('should store the locations',
|
||||
() => {expect(tokenizeAndHumanizeSourceSpans('<!--t\ne\rs\r\nt-->')).toEqual([
|
||||
[HtmlTokenType.COMMENT_START, '<!--'],
|
||||
[HtmlTokenType.RAW_TEXT, 't\ne\rs\r\nt'],
|
||||
[HtmlTokenType.COMMENT_END, '-->'],
|
||||
[HtmlTokenType.EOF, ''],
|
||||
])});
|
||||
it('should store the locations', () => {
|
||||
expect(tokenizeAndHumanizeSourceSpans('<!--t\ne\rs\r\nt-->')).toEqual([
|
||||
[HtmlTokenType.COMMENT_START, '<!--'],
|
||||
[HtmlTokenType.RAW_TEXT, 't\ne\rs\r\nt'],
|
||||
[HtmlTokenType.COMMENT_END, '-->'],
|
||||
[HtmlTokenType.EOF, ''],
|
||||
]);
|
||||
});
|
||||
|
||||
it('should report <!- without -', () => {
|
||||
expect(tokenizeAndHumanizeErrors('<!-a')).toEqual([
|
||||
|
|
|
@ -8,28 +8,27 @@
|
|||
|
||||
import {beforeEach, ddescribe, describe, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal';
|
||||
|
||||
import {IS_DART} from '../../src/facade/lang';
|
||||
|
||||
import * as typed from './output_emitter_codegen_typed';
|
||||
import * as untyped from './output_emitter_codegen_untyped';
|
||||
import {jitStatements} from '@angular/compiler/src/output/output_jit';
|
||||
import {interpretStatements} from '@angular/compiler/src/output/output_interpreter';
|
||||
import {codegenStmts, ExternalClass} from './output_emitter_util';
|
||||
import {EventEmitter} from '@angular/core';
|
||||
import {BaseException, EventEmitter} from '@angular/core';
|
||||
import {ViewType} from '@angular/core/src/linker/view_type';
|
||||
import {BaseException} from '@angular/core';
|
||||
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
||||
import {browserDetection} from '@angular/platform-browser/testing/browser_util'
|
||||
import {browserDetection} from '@angular/platform-browser/testing/browser_util';
|
||||
|
||||
export function main() {
|
||||
var outputDefs: any[] /** TODO #9100 */ = []; outputDefs.push({
|
||||
var outputDefs: any[] /** TODO #9100 */ = [];
|
||||
outputDefs.push({
|
||||
'getExpressions': () => interpretStatements(codegenStmts, 'getExpressions'),
|
||||
'name': 'interpreted'
|
||||
});
|
||||
if (IS_DART || !getDOM().supportsDOMEvents()) {
|
||||
// Our generator only works on node.js and Dart...
|
||||
|
||||
if (!getDOM().supportsDOMEvents()) {
|
||||
// Our generator only works on node.js
|
||||
outputDefs.push({'getExpressions': () => typed.getExpressions, 'name': 'typed'});
|
||||
} if (!IS_DART) {
|
||||
} else {
|
||||
// Our generator only works on node.js and Dart...
|
||||
if (!getDOM().supportsDOMEvents()) {
|
||||
outputDefs.push({'getExpressions': () => untyped.getExpressions, 'name': 'untyped'});
|
||||
|
@ -40,166 +39,155 @@ export function main() {
|
|||
});
|
||||
}
|
||||
|
||||
describe(
|
||||
'output emitter',
|
||||
() => {
|
||||
outputDefs.forEach((outputDef) => {
|
||||
describe(`${outputDef['name']}`, () => {
|
||||
var expressions: any /** TODO #9100 */;
|
||||
beforeEach(() => { expressions = outputDef['getExpressions']()(); });
|
||||
describe('output emitter', () => {
|
||||
outputDefs.forEach((outputDef) => {
|
||||
describe(`${outputDef['name']}`, () => {
|
||||
var expressions: any /** TODO #9100 */;
|
||||
beforeEach(() => { expressions = outputDef['getExpressions']()(); });
|
||||
|
||||
it('should support literals', () => {
|
||||
expect(expressions['stringLiteral']).toEqual('Hello World!');
|
||||
expect(expressions['intLiteral']).toEqual(42);
|
||||
expect(expressions['boolLiteral']).toEqual(true);
|
||||
expect(expressions['arrayLiteral']).toEqual([0]);
|
||||
expect(expressions['mapLiteral']).toEqual({'key0': 0});
|
||||
});
|
||||
it('should support literals', () => {
|
||||
expect(expressions['stringLiteral']).toEqual('Hello World!');
|
||||
expect(expressions['intLiteral']).toEqual(42);
|
||||
expect(expressions['boolLiteral']).toEqual(true);
|
||||
expect(expressions['arrayLiteral']).toEqual([0]);
|
||||
expect(expressions['mapLiteral']).toEqual({'key0': 0});
|
||||
});
|
||||
|
||||
it('should support reading vars/keys/props', () => {
|
||||
expect(expressions['readVar']).toEqual('someValue');
|
||||
expect(expressions['readKey']).toEqual('someValue');
|
||||
expect(expressions['readPropExternalInstance']).toEqual('someValue');
|
||||
expect(expressions['readPropDynamicInstance']).toEqual('dynamicValue');
|
||||
expect(expressions['readGetterDynamicInstance'])
|
||||
.toEqual({'data': 'someValue', 'dynamicProp': 'dynamicValue'});
|
||||
});
|
||||
it('should support reading vars/keys/props', () => {
|
||||
expect(expressions['readVar']).toEqual('someValue');
|
||||
expect(expressions['readKey']).toEqual('someValue');
|
||||
expect(expressions['readPropExternalInstance']).toEqual('someValue');
|
||||
expect(expressions['readPropDynamicInstance']).toEqual('dynamicValue');
|
||||
expect(expressions['readGetterDynamicInstance'])
|
||||
.toEqual({'data': 'someValue', 'dynamicProp': 'dynamicValue'});
|
||||
});
|
||||
|
||||
it('should support writing to vars / keys / props', () => {
|
||||
expect(expressions['changedVar']).toEqual('changedValue');
|
||||
expect(expressions['changedKey']).toEqual('changedValue');
|
||||
expect(expressions['changedPropExternalInstance']).toEqual('changedValue');
|
||||
expect(expressions['changedPropDynamicInstance']).toEqual('changedValue');
|
||||
});
|
||||
it('should support writing to vars / keys / props', () => {
|
||||
expect(expressions['changedVar']).toEqual('changedValue');
|
||||
expect(expressions['changedKey']).toEqual('changedValue');
|
||||
expect(expressions['changedPropExternalInstance']).toEqual('changedValue');
|
||||
expect(expressions['changedPropDynamicInstance']).toEqual('changedValue');
|
||||
});
|
||||
|
||||
it('should support declaring functions with parameters and return', () => {
|
||||
expect(expressions['fn']('someParam')).toEqual({'param': 'someParam'});
|
||||
expect(expressions['closureInDynamicInstance']('someParam')).toEqual({
|
||||
'param': 'someParam',
|
||||
'data': 'someValue',
|
||||
'dynamicProp': 'dynamicValue'
|
||||
});
|
||||
});
|
||||
it('should support declaring functions with parameters and return', () => {
|
||||
expect(expressions['fn']('someParam')).toEqual({'param': 'someParam'});
|
||||
expect(expressions['closureInDynamicInstance']('someParam'))
|
||||
.toEqual({'param': 'someParam', 'data': 'someValue', 'dynamicProp': 'dynamicValue'});
|
||||
});
|
||||
|
||||
it('should support invoking functions and methods', () => {
|
||||
expect(expressions['invokeFn']).toEqual({'param': 'someParam'});
|
||||
expect(expressions['concatedArray']).toEqual([0, 1]);
|
||||
expect(expressions['invokeMethodExternalInstance'])
|
||||
.toEqual({'data': 'someValue', 'param': 'someParam'});
|
||||
expect(expressions['invokeMethodExternalInstanceViaBind'])
|
||||
.toEqual({'data': 'someValue', 'param': 'someParam'});
|
||||
expect(expressions['invokeMethodDynamicInstance']).toEqual({
|
||||
'data': 'someValue',
|
||||
'dynamicProp': 'dynamicValue',
|
||||
'param': 'someParam'
|
||||
});
|
||||
expect(expressions['invokeMethodDynamicInstanceViaBind']).toEqual({
|
||||
'data': 'someValue',
|
||||
'dynamicProp': 'dynamicValue',
|
||||
'param': 'someParam'
|
||||
});
|
||||
});
|
||||
it('should support invoking functions and methods', () => {
|
||||
expect(expressions['invokeFn']).toEqual({'param': 'someParam'});
|
||||
expect(expressions['concatedArray']).toEqual([0, 1]);
|
||||
expect(expressions['invokeMethodExternalInstance'])
|
||||
.toEqual({'data': 'someValue', 'param': 'someParam'});
|
||||
expect(expressions['invokeMethodExternalInstanceViaBind'])
|
||||
.toEqual({'data': 'someValue', 'param': 'someParam'});
|
||||
expect(expressions['invokeMethodDynamicInstance'])
|
||||
.toEqual({'data': 'someValue', 'dynamicProp': 'dynamicValue', 'param': 'someParam'});
|
||||
expect(expressions['invokeMethodDynamicInstanceViaBind'])
|
||||
.toEqual({'data': 'someValue', 'dynamicProp': 'dynamicValue', 'param': 'someParam'});
|
||||
});
|
||||
|
||||
it('should support conditionals', () => {
|
||||
expect(expressions['conditionalTrue']).toEqual('true');
|
||||
expect(expressions['conditionalFalse']).toEqual('false');
|
||||
});
|
||||
it('should support conditionals', () => {
|
||||
expect(expressions['conditionalTrue']).toEqual('true');
|
||||
expect(expressions['conditionalFalse']).toEqual('false');
|
||||
});
|
||||
|
||||
it('should support not', () => { expect(expressions['not']).toEqual(true); });
|
||||
it('should support not', () => { expect(expressions['not']).toEqual(true); });
|
||||
|
||||
it('should support reading external identifiers', () => {
|
||||
expect(expressions['externalTestIdentifier']).toBe(ExternalClass);
|
||||
expect(expressions['externalSrcIdentifier']).toBe(EventEmitter);
|
||||
expect(expressions['externalEnumIdentifier']).toBe(ViewType.HOST);
|
||||
});
|
||||
it('should support reading external identifiers', () => {
|
||||
expect(expressions['externalTestIdentifier']).toBe(ExternalClass);
|
||||
expect(expressions['externalSrcIdentifier']).toBe(EventEmitter);
|
||||
expect(expressions['externalEnumIdentifier']).toBe(ViewType.HOST);
|
||||
});
|
||||
|
||||
it('should support instantiating classes', () => {
|
||||
expect(expressions['externalInstance']).toBeAnInstanceOf(ExternalClass);
|
||||
// Note: toBeAnInstanceOf does not check super classes in Dart...
|
||||
expect(expressions['dynamicInstance'] instanceof ExternalClass).toBe(true);
|
||||
});
|
||||
it('should support instantiating classes', () => {
|
||||
expect(expressions['externalInstance']).toBeAnInstanceOf(ExternalClass);
|
||||
// Note: toBeAnInstanceOf does not check super classes in Dart...
|
||||
expect(expressions['dynamicInstance'] instanceof ExternalClass).toBe(true);
|
||||
});
|
||||
|
||||
describe('operators', () => {
|
||||
var ops: any /** TODO #9100 */;
|
||||
var aObj: any /** TODO #9100 */, bObj: any /** TODO #9100 */;
|
||||
beforeEach(() => {
|
||||
ops = expressions['operators'];
|
||||
aObj = new Object();
|
||||
bObj = new Object();
|
||||
});
|
||||
it('should support ==', () => {
|
||||
expect(ops['=='](aObj, aObj)).toBe(true);
|
||||
expect(ops['=='](aObj, bObj)).toBe(false);
|
||||
expect(ops['=='](1, 1)).toBe(true);
|
||||
expect(ops['=='](0, 1)).toBe(false);
|
||||
expect(ops['==']('a', 'a')).toBe(true);
|
||||
expect(ops['==']('a', 'b')).toBe(false);
|
||||
});
|
||||
it('should support !=', () => {
|
||||
expect(ops['!='](aObj, aObj)).toBe(false);
|
||||
expect(ops['!='](aObj, bObj)).toBe(true);
|
||||
expect(ops['!='](1, 1)).toBe(false);
|
||||
expect(ops['!='](0, 1)).toBe(true);
|
||||
expect(ops['!=']('a', 'a')).toBe(false);
|
||||
expect(ops['!=']('a', 'b')).toBe(true);
|
||||
});
|
||||
it('should support ===', () => {
|
||||
expect(ops['==='](aObj, aObj)).toBe(true);
|
||||
expect(ops['==='](aObj, bObj)).toBe(false);
|
||||
expect(ops['==='](1, 1)).toBe(true);
|
||||
expect(ops['==='](0, 1)).toBe(false);
|
||||
});
|
||||
it('should support !==', () => {
|
||||
expect(ops['!=='](aObj, aObj)).toBe(false);
|
||||
expect(ops['!=='](aObj, bObj)).toBe(true);
|
||||
expect(ops['!=='](1, 1)).toBe(false);
|
||||
expect(ops['!=='](0, 1)).toBe(true);
|
||||
});
|
||||
it('should support -', () => { expect(ops['-'](3, 2)).toEqual(1); });
|
||||
it('should support +', () => { expect(ops['+'](1, 2)).toEqual(3); });
|
||||
it('should support /', () => { expect(ops['/'](6, 2)).toEqual(3); });
|
||||
it('should support *', () => { expect(ops['*'](2, 3)).toEqual(6); });
|
||||
it('should support %', () => { expect(ops['%'](3, 2)).toEqual(1); });
|
||||
it('should support &&', () => {
|
||||
expect(ops['&&'](true, true)).toBe(true);
|
||||
expect(ops['&&'](true, false)).toBe(false);
|
||||
});
|
||||
it('should support ||', () => {
|
||||
expect(ops['||'](true, false)).toBe(true);
|
||||
expect(ops['||'](false, false)).toBe(false);
|
||||
});
|
||||
it('should support <', () => {
|
||||
expect(ops['<'](1, 2)).toBe(true);
|
||||
expect(ops['<'](1, 1)).toBe(false);
|
||||
});
|
||||
it('should support <=', () => {
|
||||
expect(ops['<='](1, 2)).toBe(true);
|
||||
expect(ops['<='](1, 1)).toBe(true);
|
||||
});
|
||||
it('should support >', () => {
|
||||
expect(ops['>'](2, 1)).toBe(true);
|
||||
expect(ops['>'](1, 1)).toBe(false);
|
||||
});
|
||||
it('should support >=', () => {
|
||||
expect(ops['>='](2, 1)).toBe(true);
|
||||
expect(ops['>='](1, 1)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
it('should support throwing errors',
|
||||
() => { expect(expressions['throwError']).toThrowError('someError'); });
|
||||
|
||||
it('should support catching errors', () => {
|
||||
function someOperation() { throw new BaseException('Boom!'); }
|
||||
|
||||
var errorAndStack = expressions['catchError'](someOperation);
|
||||
expect(errorAndStack[0].message).toEqual('Boom!');
|
||||
// Somehow we don't get stacktraces on ios7...
|
||||
if (!browserDetection.isIOS7 && !browserDetection.isIE) {
|
||||
expect(errorAndStack[1].toString()).toContain('someOperation');
|
||||
}
|
||||
});
|
||||
describe('operators', () => {
|
||||
var ops: any /** TODO #9100 */;
|
||||
var aObj: any /** TODO #9100 */, bObj: any /** TODO #9100 */;
|
||||
beforeEach(() => {
|
||||
ops = expressions['operators'];
|
||||
aObj = new Object();
|
||||
bObj = new Object();
|
||||
});
|
||||
it('should support ==', () => {
|
||||
expect(ops['=='](aObj, aObj)).toBe(true);
|
||||
expect(ops['=='](aObj, bObj)).toBe(false);
|
||||
expect(ops['=='](1, 1)).toBe(true);
|
||||
expect(ops['=='](0, 1)).toBe(false);
|
||||
expect(ops['==']('a', 'a')).toBe(true);
|
||||
expect(ops['==']('a', 'b')).toBe(false);
|
||||
});
|
||||
it('should support !=', () => {
|
||||
expect(ops['!='](aObj, aObj)).toBe(false);
|
||||
expect(ops['!='](aObj, bObj)).toBe(true);
|
||||
expect(ops['!='](1, 1)).toBe(false);
|
||||
expect(ops['!='](0, 1)).toBe(true);
|
||||
expect(ops['!=']('a', 'a')).toBe(false);
|
||||
expect(ops['!=']('a', 'b')).toBe(true);
|
||||
});
|
||||
it('should support ===', () => {
|
||||
expect(ops['==='](aObj, aObj)).toBe(true);
|
||||
expect(ops['==='](aObj, bObj)).toBe(false);
|
||||
expect(ops['==='](1, 1)).toBe(true);
|
||||
expect(ops['==='](0, 1)).toBe(false);
|
||||
});
|
||||
it('should support !==', () => {
|
||||
expect(ops['!=='](aObj, aObj)).toBe(false);
|
||||
expect(ops['!=='](aObj, bObj)).toBe(true);
|
||||
expect(ops['!=='](1, 1)).toBe(false);
|
||||
expect(ops['!=='](0, 1)).toBe(true);
|
||||
});
|
||||
it('should support -', () => { expect(ops['-'](3, 2)).toEqual(1); });
|
||||
it('should support +', () => { expect(ops['+'](1, 2)).toEqual(3); });
|
||||
it('should support /', () => { expect(ops['/'](6, 2)).toEqual(3); });
|
||||
it('should support *', () => { expect(ops['*'](2, 3)).toEqual(6); });
|
||||
it('should support %', () => { expect(ops['%'](3, 2)).toEqual(1); });
|
||||
it('should support &&', () => {
|
||||
expect(ops['&&'](true, true)).toBe(true);
|
||||
expect(ops['&&'](true, false)).toBe(false);
|
||||
});
|
||||
it('should support ||', () => {
|
||||
expect(ops['||'](true, false)).toBe(true);
|
||||
expect(ops['||'](false, false)).toBe(false);
|
||||
});
|
||||
it('should support <', () => {
|
||||
expect(ops['<'](1, 2)).toBe(true);
|
||||
expect(ops['<'](1, 1)).toBe(false);
|
||||
});
|
||||
it('should support <=', () => {
|
||||
expect(ops['<='](1, 2)).toBe(true);
|
||||
expect(ops['<='](1, 1)).toBe(true);
|
||||
});
|
||||
it('should support >', () => {
|
||||
expect(ops['>'](2, 1)).toBe(true);
|
||||
expect(ops['>'](1, 1)).toBe(false);
|
||||
});
|
||||
it('should support >=', () => {
|
||||
expect(ops['>='](2, 1)).toBe(true);
|
||||
expect(ops['>='](1, 1)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
it('should support throwing errors',
|
||||
() => { expect(expressions['throwError']).toThrowError('someError'); });
|
||||
|
||||
it('should support catching errors', () => {
|
||||
function someOperation() { throw new BaseException('Boom!'); }
|
||||
|
||||
var errorAndStack = expressions['catchError'](someOperation);
|
||||
expect(errorAndStack[0].message).toEqual('Boom!');
|
||||
// Somehow we don't get stacktraces on ios7...
|
||||
if (!browserDetection.isIOS7 && !browserDetection.isIE) {
|
||||
expect(errorAndStack[1].toString()).toContain('someOperation');
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
/**
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {beforeEach, ddescribe, xdescribe, describe, expect, iit, inject, beforeEachProviders, it, xit,} from '@angular/core/testing/testing_internal';
|
||||
import {Injectable, Component, Input, ViewMetadata, Compiler, ComponentFactory, Injector, AppModule, AppModuleMetadata, AppModuleFactory} from '@angular/core';
|
||||
import {ConcreteType, stringify} from '../src/facade/lang';
|
||||
|
|
|
@ -6,8 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {SelectorMatcher} from '@angular/compiler/src/selector';
|
||||
import {CssSelector} from '@angular/compiler/src/selector';
|
||||
import {CssSelector, SelectorMatcher} from '@angular/compiler/src/selector';
|
||||
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
||||
import {el} from '@angular/platform-browser/testing/browser_util';
|
||||
|
||||
|
|
|
@ -1065,15 +1065,15 @@ Reference "#a" is defined several times ("<div #a></div><div [ERROR ->]#a></div>
|
|||
type:
|
||||
new CompileTypeMetadata({moduleUrl: someModuleUrl, name: `SomeComp${compCounter++}`}),
|
||||
template: new CompileTemplateMetadata({ngContentSelectors: ngContentSelectors})
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
function createDir(selector: string): CompileDirectiveMetadata {
|
||||
return CompileDirectiveMetadata.create({
|
||||
selector: selector,
|
||||
type:
|
||||
new CompileTypeMetadata({moduleUrl: someModuleUrl, name: `SomeDir${compCounter++}`})
|
||||
})
|
||||
type: new CompileTypeMetadata(
|
||||
{moduleUrl: someModuleUrl, name: `SomeDir${compCounter++}`})
|
||||
});
|
||||
}
|
||||
|
||||
describe('project text nodes', () => {
|
||||
|
|
|
@ -6,13 +6,11 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {beforeEach, ddescribe, xdescribe, describe, expect, iit, inject, beforeEachProviders, it, xit,} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter, beforeEach, ddescribe, xdescribe, describe, expect, iit, inject, beforeEachProviders, it, xit,} from '@angular/core/testing/testing_internal';
|
||||
import {TestComponentBuilder, ComponentFixtureAutoDetect, ComponentFixtureNoNgZone, withProviders} from '@angular/core/testing';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
import {Injectable, Component, Input, ViewMetadata} from '@angular/core';
|
||||
import {NgIf} from '@angular/common';
|
||||
import {TimerWrapper} from '../src/facade/async';
|
||||
import {IS_DART} from '../src/facade/lang';
|
||||
import {PromiseWrapper} from '../src/facade/promise';
|
||||
import {dispatchEvent} from '@angular/platform-browser/testing/browser_util';
|
||||
|
||||
|
@ -328,291 +326,289 @@ export function main() {
|
|||
expect(componentFixture.nativeElement).toHaveText('Mock');
|
||||
}));
|
||||
|
||||
if (!IS_DART) {
|
||||
describe('ComponentFixture', () => {
|
||||
it('should auto detect changes if autoDetectChanges is called',
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
describe('ComponentFixture', () => {
|
||||
it('should auto detect changes if autoDetectChanges is called',
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
|
||||
tcb.createAsync(AutoDetectComp).then((componentFixture) => {
|
||||
expect(componentFixture.ngZone).not.toBeNull();
|
||||
componentFixture.autoDetectChanges();
|
||||
tcb.createAsync(AutoDetectComp).then((componentFixture) => {
|
||||
expect(componentFixture.ngZone).not.toBeNull();
|
||||
componentFixture.autoDetectChanges();
|
||||
expect(componentFixture.nativeElement).toHaveText('1');
|
||||
|
||||
let element = componentFixture.debugElement.children[0];
|
||||
dispatchEvent(element.nativeElement, 'click');
|
||||
|
||||
expect(componentFixture.isStable()).toBe(true);
|
||||
expect(componentFixture.nativeElement).toHaveText('11');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should auto detect changes if ComponentFixtureAutoDetect is provided as true',
|
||||
withProviders(() => [{provide: ComponentFixtureAutoDetect, useValue: true}])
|
||||
.inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
|
||||
tcb.createAsync(AutoDetectComp).then((componentFixture) => {
|
||||
expect(componentFixture.nativeElement).toHaveText('1');
|
||||
|
||||
let element = componentFixture.debugElement.children[0];
|
||||
dispatchEvent(element.nativeElement, 'click');
|
||||
|
||||
expect(componentFixture.nativeElement).toHaveText('11');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should signal through whenStable when the fixture is stable (autoDetectChanges)',
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
|
||||
tcb.createAsync(AsyncComp).then((componentFixture) => {
|
||||
componentFixture.autoDetectChanges();
|
||||
expect(componentFixture.nativeElement).toHaveText('1');
|
||||
|
||||
let element = componentFixture.debugElement.children[0];
|
||||
dispatchEvent(element.nativeElement, 'click');
|
||||
expect(componentFixture.nativeElement).toHaveText('1');
|
||||
|
||||
// Component is updated asynchronously. Wait for the fixture to become stable
|
||||
// before checking for new value.
|
||||
expect(componentFixture.isStable()).toBe(false);
|
||||
componentFixture.whenStable().then((waited) => {
|
||||
expect(waited).toBe(true);
|
||||
expect(componentFixture.nativeElement).toHaveText('11');
|
||||
async.done();
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
it('should signal through isStable when the fixture is stable (no autoDetectChanges)',
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
|
||||
tcb.createAsync(AsyncComp).then((componentFixture) => {
|
||||
componentFixture.detectChanges();
|
||||
expect(componentFixture.nativeElement).toHaveText('1');
|
||||
|
||||
let element = componentFixture.debugElement.children[0];
|
||||
dispatchEvent(element.nativeElement, 'click');
|
||||
expect(componentFixture.nativeElement).toHaveText('1');
|
||||
|
||||
// Component is updated asynchronously. Wait for the fixture to become stable
|
||||
// before checking.
|
||||
componentFixture.whenStable().then((waited) => {
|
||||
expect(waited).toBe(true);
|
||||
componentFixture.detectChanges();
|
||||
expect(componentFixture.nativeElement).toHaveText('11');
|
||||
async.done();
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
it('should wait for macroTask(setTimeout) while checking for whenStable ' +
|
||||
'(autoDetectChanges)',
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
|
||||
tcb.createAsync(AsyncTimeoutComp).then((componentFixture) => {
|
||||
componentFixture.autoDetectChanges();
|
||||
expect(componentFixture.nativeElement).toHaveText('1');
|
||||
|
||||
let element = componentFixture.debugElement.children[0];
|
||||
dispatchEvent(element.nativeElement, 'click');
|
||||
expect(componentFixture.nativeElement).toHaveText('1');
|
||||
|
||||
// Component is updated asynchronously. Wait for the fixture to become
|
||||
// stable before checking for new value.
|
||||
expect(componentFixture.isStable()).toBe(false);
|
||||
componentFixture.whenStable().then((waited) => {
|
||||
expect(waited).toBe(true);
|
||||
expect(componentFixture.nativeElement).toHaveText('11');
|
||||
async.done();
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
it('should wait for macroTask(setTimeout) while checking for whenStable ' +
|
||||
'(no autoDetectChanges)',
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
|
||||
tcb.createAsync(AsyncTimeoutComp).then((componentFixture) => {
|
||||
componentFixture.detectChanges();
|
||||
expect(componentFixture.nativeElement).toHaveText('1');
|
||||
|
||||
let element = componentFixture.debugElement.children[0];
|
||||
dispatchEvent(element.nativeElement, 'click');
|
||||
expect(componentFixture.nativeElement).toHaveText('1');
|
||||
|
||||
// Component is updated asynchronously. Wait for the fixture to become
|
||||
// stable before checking for new value.
|
||||
expect(componentFixture.isStable()).toBe(false);
|
||||
componentFixture.whenStable().then((waited) => {
|
||||
expect(waited).toBe(true);
|
||||
componentFixture.detectChanges();
|
||||
expect(componentFixture.nativeElement).toHaveText('11');
|
||||
async.done();
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
it('should wait for nested macroTasks(setTimeout) while checking for whenStable ' +
|
||||
'(autoDetectChanges)',
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
|
||||
tcb.createAsync(NestedAsyncTimeoutComp).then((componentFixture) => {
|
||||
componentFixture.autoDetectChanges();
|
||||
expect(componentFixture.nativeElement).toHaveText('1');
|
||||
|
||||
let element = componentFixture.debugElement.children[0];
|
||||
dispatchEvent(element.nativeElement, 'click');
|
||||
expect(componentFixture.nativeElement).toHaveText('1');
|
||||
|
||||
// Component is updated asynchronously. Wait for the fixture to become
|
||||
// stable before checking for new value.
|
||||
expect(componentFixture.isStable()).toBe(false);
|
||||
componentFixture.whenStable().then((waited) => {
|
||||
expect(waited).toBe(true);
|
||||
expect(componentFixture.nativeElement).toHaveText('11');
|
||||
async.done();
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
it('should wait for nested macroTasks(setTimeout) while checking for whenStable ' +
|
||||
'(no autoDetectChanges)',
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
|
||||
tcb.createAsync(NestedAsyncTimeoutComp).then((componentFixture) => {
|
||||
componentFixture.detectChanges();
|
||||
expect(componentFixture.nativeElement).toHaveText('1');
|
||||
|
||||
let element = componentFixture.debugElement.children[0];
|
||||
dispatchEvent(element.nativeElement, 'click');
|
||||
expect(componentFixture.nativeElement).toHaveText('1');
|
||||
|
||||
// Component is updated asynchronously. Wait for the fixture to become
|
||||
// stable before checking for new value.
|
||||
expect(componentFixture.isStable()).toBe(false);
|
||||
componentFixture.whenStable().then((waited) => {
|
||||
expect(waited).toBe(true);
|
||||
componentFixture.detectChanges();
|
||||
expect(componentFixture.nativeElement).toHaveText('11');
|
||||
async.done();
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
it('should stabilize after async task in change detection (autoDetectChanges)',
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
|
||||
tcb.createAsync(AsyncChangeComp).then((componentFixture) => {
|
||||
componentFixture.autoDetectChanges();
|
||||
componentFixture.whenStable().then((_) => {
|
||||
expect(componentFixture.nativeElement).toHaveText('1');
|
||||
|
||||
let element = componentFixture.debugElement.children[0];
|
||||
dispatchEvent(element.nativeElement, 'click');
|
||||
|
||||
expect(componentFixture.isStable()).toBe(true);
|
||||
expect(componentFixture.nativeElement).toHaveText('11');
|
||||
componentFixture.whenStable().then((_) => {
|
||||
expect(componentFixture.nativeElement).toHaveText('11');
|
||||
async.done();
|
||||
});
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
it('should stabilize after async task in change detection(no autoDetectChanges)',
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
|
||||
tcb.createAsync(AsyncChangeComp).then((componentFixture) => {
|
||||
componentFixture.detectChanges();
|
||||
componentFixture.whenStable().then((_) => {
|
||||
// Run detectChanges again so that stabilized value is reflected in the
|
||||
// DOM.
|
||||
componentFixture.detectChanges();
|
||||
expect(componentFixture.nativeElement).toHaveText('1');
|
||||
|
||||
let element = componentFixture.debugElement.children[0];
|
||||
dispatchEvent(element.nativeElement, 'click');
|
||||
componentFixture.detectChanges();
|
||||
|
||||
componentFixture.whenStable().then((_) => {
|
||||
// Run detectChanges again so that stabilized value is reflected in
|
||||
// the DOM.
|
||||
componentFixture.detectChanges();
|
||||
expect(componentFixture.nativeElement).toHaveText('11');
|
||||
async.done();
|
||||
});
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
describe('No NgZone', () => {
|
||||
beforeEachProviders(() => [{provide: ComponentFixtureNoNgZone, useValue: true}]);
|
||||
|
||||
it('calling autoDetectChanges raises an error', () => {
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
tcb.createAsync(ChildComp).then((componentFixture) => {
|
||||
expect(() => { componentFixture.autoDetectChanges(); })
|
||||
.toThrow(
|
||||
'Cannot call autoDetectChanges when ComponentFixtureNoNgZone is set!!');
|
||||
async.done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should instantiate a component with valid DOM',
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
|
||||
tcb.createAsync(ChildComp).then((componentFixture) => {
|
||||
expect(componentFixture.ngZone).toBeNull();
|
||||
componentFixture.detectChanges();
|
||||
expect(componentFixture.nativeElement).toHaveText('Original Child');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should auto detect changes if ComponentFixtureAutoDetect is provided as true',
|
||||
withProviders(() => [{provide: ComponentFixtureAutoDetect, useValue: true}])
|
||||
.inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
|
||||
tcb.createAsync(AutoDetectComp).then((componentFixture) => {
|
||||
expect(componentFixture.nativeElement).toHaveText('1');
|
||||
|
||||
let element = componentFixture.debugElement.children[0];
|
||||
dispatchEvent(element.nativeElement, 'click');
|
||||
|
||||
expect(componentFixture.nativeElement).toHaveText('11');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should signal through whenStable when the fixture is stable (autoDetectChanges)',
|
||||
it('should allow changing members of the component',
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
|
||||
tcb.createAsync(AsyncComp).then((componentFixture) => {
|
||||
componentFixture.autoDetectChanges();
|
||||
expect(componentFixture.nativeElement).toHaveText('1');
|
||||
|
||||
let element = componentFixture.debugElement.children[0];
|
||||
dispatchEvent(element.nativeElement, 'click');
|
||||
expect(componentFixture.nativeElement).toHaveText('1');
|
||||
|
||||
// Component is updated asynchronously. Wait for the fixture to become stable
|
||||
// before checking for new value.
|
||||
expect(componentFixture.isStable()).toBe(false);
|
||||
componentFixture.whenStable().then((waited) => {
|
||||
expect(waited).toBe(true);
|
||||
expect(componentFixture.nativeElement).toHaveText('11');
|
||||
async.done();
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
it('should signal through isStable when the fixture is stable (no autoDetectChanges)',
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
|
||||
tcb.createAsync(AsyncComp).then((componentFixture) => {
|
||||
tcb.createAsync(MyIfComp).then((componentFixture) => {
|
||||
componentFixture.detectChanges();
|
||||
expect(componentFixture.nativeElement).toHaveText('1');
|
||||
expect(componentFixture.nativeElement).toHaveText('MyIf()');
|
||||
|
||||
let element = componentFixture.debugElement.children[0];
|
||||
dispatchEvent(element.nativeElement, 'click');
|
||||
expect(componentFixture.nativeElement).toHaveText('1');
|
||||
|
||||
// Component is updated asynchronously. Wait for the fixture to become stable
|
||||
// before checking.
|
||||
componentFixture.whenStable().then((waited) => {
|
||||
expect(waited).toBe(true);
|
||||
componentFixture.detectChanges();
|
||||
expect(componentFixture.nativeElement).toHaveText('11');
|
||||
async.done();
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
it('should wait for macroTask(setTimeout) while checking for whenStable ' +
|
||||
'(autoDetectChanges)',
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
|
||||
tcb.createAsync(AsyncTimeoutComp).then((componentFixture) => {
|
||||
componentFixture.autoDetectChanges();
|
||||
expect(componentFixture.nativeElement).toHaveText('1');
|
||||
|
||||
let element = componentFixture.debugElement.children[0];
|
||||
dispatchEvent(element.nativeElement, 'click');
|
||||
expect(componentFixture.nativeElement).toHaveText('1');
|
||||
|
||||
// Component is updated asynchronously. Wait for the fixture to become
|
||||
// stable before checking for new value.
|
||||
expect(componentFixture.isStable()).toBe(false);
|
||||
componentFixture.whenStable().then((waited) => {
|
||||
expect(waited).toBe(true);
|
||||
expect(componentFixture.nativeElement).toHaveText('11');
|
||||
async.done();
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
it('should wait for macroTask(setTimeout) while checking for whenStable ' +
|
||||
'(no autoDetectChanges)',
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
|
||||
tcb.createAsync(AsyncTimeoutComp).then((componentFixture) => {
|
||||
componentFixture.componentInstance.showMore = true;
|
||||
componentFixture.detectChanges();
|
||||
expect(componentFixture.nativeElement).toHaveText('1');
|
||||
expect(componentFixture.nativeElement).toHaveText('MyIf(More)');
|
||||
|
||||
let element = componentFixture.debugElement.children[0];
|
||||
dispatchEvent(element.nativeElement, 'click');
|
||||
expect(componentFixture.nativeElement).toHaveText('1');
|
||||
|
||||
// Component is updated asynchronously. Wait for the fixture to become
|
||||
// stable before checking for new value.
|
||||
expect(componentFixture.isStable()).toBe(false);
|
||||
componentFixture.whenStable().then((waited) => {
|
||||
expect(waited).toBe(true);
|
||||
componentFixture.detectChanges();
|
||||
expect(componentFixture.nativeElement).toHaveText('11');
|
||||
async.done();
|
||||
});
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should wait for nested macroTasks(setTimeout) while checking for whenStable ' +
|
||||
'(autoDetectChanges)',
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
|
||||
tcb.createAsync(NestedAsyncTimeoutComp).then((componentFixture) => {
|
||||
componentFixture.autoDetectChanges();
|
||||
expect(componentFixture.nativeElement).toHaveText('1');
|
||||
|
||||
let element = componentFixture.debugElement.children[0];
|
||||
dispatchEvent(element.nativeElement, 'click');
|
||||
expect(componentFixture.nativeElement).toHaveText('1');
|
||||
|
||||
// Component is updated asynchronously. Wait for the fixture to become
|
||||
// stable before checking for new value.
|
||||
expect(componentFixture.isStable()).toBe(false);
|
||||
componentFixture.whenStable().then((waited) => {
|
||||
expect(waited).toBe(true);
|
||||
expect(componentFixture.nativeElement).toHaveText('11');
|
||||
async.done();
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
it('should wait for nested macroTasks(setTimeout) while checking for whenStable ' +
|
||||
'(no autoDetectChanges)',
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
|
||||
tcb.createAsync(NestedAsyncTimeoutComp).then((componentFixture) => {
|
||||
componentFixture.detectChanges();
|
||||
expect(componentFixture.nativeElement).toHaveText('1');
|
||||
|
||||
let element = componentFixture.debugElement.children[0];
|
||||
dispatchEvent(element.nativeElement, 'click');
|
||||
expect(componentFixture.nativeElement).toHaveText('1');
|
||||
|
||||
// Component is updated asynchronously. Wait for the fixture to become
|
||||
// stable before checking for new value.
|
||||
expect(componentFixture.isStable()).toBe(false);
|
||||
componentFixture.whenStable().then((waited) => {
|
||||
expect(waited).toBe(true);
|
||||
componentFixture.detectChanges();
|
||||
expect(componentFixture.nativeElement).toHaveText('11');
|
||||
async.done();
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
it('should stabilize after async task in change detection (autoDetectChanges)',
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
|
||||
tcb.createAsync(AsyncChangeComp).then((componentFixture) => {
|
||||
componentFixture.autoDetectChanges();
|
||||
componentFixture.whenStable().then((_) => {
|
||||
expect(componentFixture.nativeElement).toHaveText('1');
|
||||
|
||||
let element = componentFixture.debugElement.children[0];
|
||||
dispatchEvent(element.nativeElement, 'click');
|
||||
|
||||
componentFixture.whenStable().then((_) => {
|
||||
expect(componentFixture.nativeElement).toHaveText('11');
|
||||
async.done();
|
||||
});
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
it('should stabilize after async task in change detection(no autoDetectChanges)',
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
|
||||
tcb.createAsync(AsyncChangeComp).then((componentFixture) => {
|
||||
componentFixture.detectChanges();
|
||||
componentFixture.whenStable().then((_) => {
|
||||
// Run detectChanges again so that stabilized value is reflected in the
|
||||
// DOM.
|
||||
componentFixture.detectChanges();
|
||||
expect(componentFixture.nativeElement).toHaveText('1');
|
||||
|
||||
let element = componentFixture.debugElement.children[0];
|
||||
dispatchEvent(element.nativeElement, 'click');
|
||||
componentFixture.detectChanges();
|
||||
|
||||
componentFixture.whenStable().then((_) => {
|
||||
// Run detectChanges again so that stabilized value is reflected in
|
||||
// the DOM.
|
||||
componentFixture.detectChanges();
|
||||
expect(componentFixture.nativeElement).toHaveText('11');
|
||||
async.done();
|
||||
});
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
describe('No NgZone', () => {
|
||||
beforeEachProviders(() => [{provide: ComponentFixtureNoNgZone, useValue: true}]);
|
||||
|
||||
it('calling autoDetectChanges raises an error', () => {
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
tcb.createAsync(ChildComp).then((componentFixture) => {
|
||||
expect(() => { componentFixture.autoDetectChanges(); })
|
||||
.toThrow(
|
||||
'Cannot call autoDetectChanges when ComponentFixtureNoNgZone is set!!');
|
||||
async.done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should instantiate a component with valid DOM',
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
|
||||
tcb.createAsync(ChildComp).then((componentFixture) => {
|
||||
expect(componentFixture.ngZone).toBeNull();
|
||||
componentFixture.detectChanges();
|
||||
expect(componentFixture.nativeElement).toHaveText('Original Child');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should allow changing members of the component',
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
|
||||
tcb.createAsync(MyIfComp).then((componentFixture) => {
|
||||
componentFixture.detectChanges();
|
||||
expect(componentFixture.nativeElement).toHaveText('MyIf()');
|
||||
|
||||
componentFixture.componentInstance.showMore = true;
|
||||
componentFixture.detectChanges();
|
||||
expect(componentFixture.nativeElement).toHaveText('MyIf(More)');
|
||||
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {fakeAsync, flushMicrotasks} from '@angular/core/testing/fake_async';
|
||||
import {fakeAsync} from '@angular/core/testing/fake_async';
|
||||
import {beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xit} from '@angular/core/testing/testing_internal';
|
||||
|
||||
import {SyncAsyncResult} from '../src/util';
|
||||
|
@ -20,5 +20,5 @@ export function main() {
|
|||
sar.asyncResult.then((v: any) => expect(v).toBe(syncValue));
|
||||
}));
|
||||
});
|
||||
})
|
||||
});
|
||||
}
|
||||
|
|
|
@ -8,10 +8,9 @@
|
|||
|
||||
import {beforeEach, ddescribe, describe, expect, iit, it, inject,} from '@angular/core/testing/testing_internal';
|
||||
|
||||
import {stringify} from '../src/facade/lang';
|
||||
import {stringify, isBlank} from '../src/facade/lang';
|
||||
import {MockViewResolver} from '../testing';
|
||||
import {Component, ViewMetadata, Injector} from '@angular/core';
|
||||
import {isBlank} from '../src/facade/lang';
|
||||
|
||||
export function main() {
|
||||
describe('MockViewResolver', () => {
|
||||
|
|
|
@ -6,8 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {beforeEach, ddescribe, describe, expect, iit, inject, it,} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter, beforeEach, ddescribe, describe, expect, iit, inject, it,} from '@angular/core/testing/testing_internal';
|
||||
import {MockXHR} from '@angular/compiler/testing/xhr_mock';
|
||||
import {PromiseWrapper} from '../src/facade/async';
|
||||
import {isPresent} from '../src/facade/lang';
|
||||
|
@ -19,8 +18,7 @@ export function main() {
|
|||
beforeEach(() => { xhr = new MockXHR(); });
|
||||
|
||||
function expectResponse(
|
||||
request: Promise<string>, url: string, response: string,
|
||||
done: any /** TODO #9100 */ = null) {
|
||||
request: Promise<string>, url: string, response: string, done: () => void = null) {
|
||||
function onResponse(text: string): string {
|
||||
if (response === null) {
|
||||
throw `Unexpected response ${url} -> ${text}`;
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
*/
|
||||
|
||||
import {AnimationGroupPlayer} from '../../src/animation/animation_group_player';
|
||||
import {isPresent} from '../../src/facade/lang';
|
||||
import {fakeAsync, flushMicrotasks} from '../../testing';
|
||||
import {MockAnimationPlayer} from '../../testing/mock_animation_player';
|
||||
import {AsyncTestCompleter, beforeEach, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '../../testing/testing_internal';
|
||||
|
@ -32,7 +31,7 @@ export function main() {
|
|||
} else {
|
||||
expect(actual).not.toEqual(status);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var assertPlaying = (player: MockAnimationPlayer, isPlaying: boolean) => {
|
||||
assertLastStatus(player, 'play', isPlaying);
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
*/
|
||||
|
||||
import {NgIf} from '@angular/common';
|
||||
import {CompilerConfig} from '@angular/compiler';
|
||||
import {TestComponentBuilder} from '@angular/core/testing';
|
||||
import {AnimationDriver} from '@angular/platform-browser/src/dom/animation_driver';
|
||||
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
||||
|
@ -19,20 +18,15 @@ import {DEFAULT_STATE} from '../../src/animation/animation_constants';
|
|||
import {AnimationKeyframe} from '../../src/animation/animation_keyframe';
|
||||
import {AnimationPlayer} from '../../src/animation/animation_player';
|
||||
import {AnimationStyles} from '../../src/animation/animation_styles';
|
||||
import {AnimationEntryMetadata, animate, group, keyframes, sequence, state, style, transition, trigger} from '../../src/animation/metadata';
|
||||
import {AUTO_STYLE} from '../../src/animation/metadata';
|
||||
import {IS_DART, isArray, isPresent} from '../../src/facade/lang';
|
||||
import {AUTO_STYLE, AnimationEntryMetadata, animate, group, keyframes, sequence, state, style, transition, trigger} from '../../src/animation/metadata';
|
||||
import {isArray, isPresent} from '../../src/facade/lang';
|
||||
import {configureCompiler, configureModule, fakeAsync, flushMicrotasks, tick} from '../../testing';
|
||||
import {MockAnimationPlayer} from '../../testing/mock_animation_player';
|
||||
import {AsyncTestCompleter, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '../../testing/testing_internal';
|
||||
|
||||
export function main() {
|
||||
if (IS_DART) {
|
||||
declareTests({useJit: false});
|
||||
} else {
|
||||
describe('jit', () => { declareTests({useJit: true}); });
|
||||
describe('no jit', () => { declareTests({useJit: false}); });
|
||||
}
|
||||
describe('jit', () => { declareTests({useJit: true}); });
|
||||
describe('no jit', () => { declareTests({useJit: false}); });
|
||||
}
|
||||
|
||||
function declareTests({useJit}: {useJit: boolean}) {
|
||||
|
@ -254,18 +248,17 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
})));
|
||||
|
||||
describe('groups/sequences', () => {
|
||||
var assertPlaying =
|
||||
(player: MockAnimationDriver, isPlaying: any /** TODO #9100 */) => {
|
||||
var method = 'play';
|
||||
var lastEntry = player.log.length > 0 ? player.log[player.log.length - 1] : null;
|
||||
if (isPresent(lastEntry)) {
|
||||
if (isPlaying) {
|
||||
expect(lastEntry).toEqual(method);
|
||||
} else {
|
||||
expect(lastEntry).not.toEqual(method);
|
||||
}
|
||||
}
|
||||
var assertPlaying = (player: MockAnimationDriver, isPlaying: any /** TODO #9100 */) => {
|
||||
var method = 'play';
|
||||
var lastEntry = player.log.length > 0 ? player.log[player.log.length - 1] : null;
|
||||
if (isPresent(lastEntry)) {
|
||||
if (isPlaying) {
|
||||
expect(lastEntry).toEqual(method);
|
||||
} else {
|
||||
expect(lastEntry).not.toEqual(method);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
it('should run animations in sequence one by one if a top-level array is used',
|
||||
inject(
|
||||
|
|
|
@ -32,7 +32,7 @@ export function main() {
|
|||
} else {
|
||||
expect(actual).not.toEqual(status);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var assertPlaying = (player: MockAnimationPlayer, isPlaying: boolean) => {
|
||||
assertLastStatus(player, 'play', isPlaying);
|
||||
|
|
|
@ -23,7 +23,7 @@ export function main() {
|
|||
var newStyles = {background: 'red'};
|
||||
var flag = '*';
|
||||
var result = animationUtils.prepareFinalAnimationStyles(styles, newStyles, flag);
|
||||
expect(result).toEqual({opacity: flag, color: flag, background: 'red'})
|
||||
expect(result).toEqual({opacity: flag, color: flag, background: 'red'});
|
||||
});
|
||||
|
||||
it('should handle an empty set of styles', () => {
|
||||
|
@ -43,7 +43,7 @@ export function main() {
|
|||
var newStyles = {color: '*', border: '*'};
|
||||
var flag = '*';
|
||||
var result = animationUtils.prepareFinalAnimationStyles(styles, newStyles, null);
|
||||
expect(result).toEqual({opacity: null, color: null, border: null})
|
||||
expect(result).toEqual({opacity: null, color: null, border: null});
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -6,12 +6,10 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {ddescribe, describe, it, iit, xit, expect, beforeEach, afterEach, inject,} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
import {Type} from '@angular/core';
|
||||
import {AsyncTestCompleter, ddescribe, describe, it, iit, xit, expect, beforeEach, afterEach, inject,} from '@angular/core/testing/testing_internal';
|
||||
import {SpyChangeDetectorRef} from './spies';
|
||||
import {ApplicationRef_, ApplicationRef, PLATFORM_CORE_PROVIDERS, APPLICATION_CORE_PROVIDERS} from '@angular/core/src/application_ref';
|
||||
import {Injector, APP_INITIALIZER, Component, ReflectiveInjector, coreLoadAndBootstrap, PlatformRef, createPlatform, disposePlatform, ComponentResolver, ComponentFactoryResolver, ChangeDetectorRef} from '@angular/core';
|
||||
import {Type, Injector, APP_INITIALIZER, Component, ReflectiveInjector, coreLoadAndBootstrap, PlatformRef, createPlatform, disposePlatform, ComponentResolver, ComponentFactoryResolver, ChangeDetectorRef} from '@angular/core';
|
||||
import {Console} from '@angular/core/src/console';
|
||||
import {BaseException} from '../src/facade/exceptions';
|
||||
import {PromiseWrapper, PromiseCompleter, TimerWrapper} from '../src/facade/async';
|
||||
|
|
|
@ -17,13 +17,13 @@ import {iterableChangesAsString} from '../../change_detection/util';
|
|||
class ItemWithId {
|
||||
constructor(private id: string) {}
|
||||
|
||||
toString() { return `{id: ${this.id}}` }
|
||||
toString() { return `{id: ${this.id}}`; }
|
||||
}
|
||||
|
||||
class ComplexItem {
|
||||
constructor(private id: string, private color: string) {}
|
||||
|
||||
toString() { return `{id: ${this.id}, color: ${this.color}}` }
|
||||
toString() { return `{id: ${this.id}, color: ${this.color}}`; }
|
||||
}
|
||||
|
||||
// todo(vicb): UnmodifiableListView / frozen object when implemented
|
||||
|
@ -328,7 +328,7 @@ export function main() {
|
|||
var trackByItemId = (index: number, item: any): any => item.id;
|
||||
|
||||
var buildItemList =
|
||||
(list: string[]) => { return list.map((val) => {return new ItemWithId(val)}) };
|
||||
(list: string[]) => { return list.map((val) => { return new ItemWithId(val); }); };
|
||||
|
||||
beforeEach(() => { differ = new DefaultIterableDiffer(trackByItemId); });
|
||||
|
||||
|
|
|
@ -6,13 +6,12 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {beforeEach, ddescribe, xdescribe, describe, expect, iit, inject, beforeEachProviders, it, xit,} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter, beforeEach, ddescribe, xdescribe, describe, expect, iit, inject, beforeEachProviders, it, xit,} from '@angular/core/testing/testing_internal';
|
||||
import {TestComponentBuilder} from '@angular/core/testing';
|
||||
|
||||
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
||||
|
||||
import {PromiseWrapper, EventEmitter, ObservableWrapper} from '../../src/facade/async';
|
||||
import {EventEmitter} from '../../src/facade/async';
|
||||
|
||||
import {Injectable} from '@angular/core';
|
||||
import {NgFor, NgIf} from '@angular/common';
|
||||
|
|
|
@ -14,12 +14,14 @@ import {IS_DART} from '../../src/facade/lang';
|
|||
|
||||
export function main() {
|
||||
describe('Injector.NULL', () => {
|
||||
it('should throw if no arg is given', () => {expect(() => Injector.NULL.get('someToken'))
|
||||
.toThrowError('No provider for someToken!')});
|
||||
it('should throw if no arg is given', () => {
|
||||
expect(() => Injector.NULL.get('someToken')).toThrowError('No provider for someToken!');
|
||||
});
|
||||
|
||||
it('should throw if THROW_IF_NOT_FOUND is given',
|
||||
() => {expect(() => Injector.NULL.get('someToken', Injector.THROW_IF_NOT_FOUND))
|
||||
.toThrowError('No provider for someToken!')});
|
||||
it('should throw if THROW_IF_NOT_FOUND is given', () => {
|
||||
expect(() => Injector.NULL.get('someToken', Injector.THROW_IF_NOT_FOUND))
|
||||
.toThrowError('No provider for someToken!');
|
||||
});
|
||||
|
||||
it('should return the default value',
|
||||
() => { expect(Injector.NULL.get('someToken', 'notFound')).toEqual('notFound'); });
|
||||
|
|
|
@ -9,8 +9,7 @@
|
|||
import {AfterContentChecked, AfterContentInit, AfterViewChecked, AfterViewInit, DoCheck, OnChanges, OnInit} from '@angular/core';
|
||||
import {Component, Directive, ViewMetadata} from '@angular/core/src/metadata';
|
||||
import {TestComponentBuilder} from '@angular/core/testing';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
import {Log, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter, Log, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal';
|
||||
|
||||
export function main() {
|
||||
describe('directive lifecycle integration spec', () => {
|
||||
|
|
|
@ -6,10 +6,9 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {beforeEach, ddescribe, describe, expect, iit, inject, it, xit} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter, beforeEach, ddescribe, describe, expect, iit, inject, it, xit} from '@angular/core/testing/testing_internal';
|
||||
|
||||
import {EventEmitter, Observable, PromiseWrapper, Subject} from '../../src/facade/async';
|
||||
import {Observable} from '../../src/facade/async';
|
||||
|
||||
export function main() {
|
||||
describe('Observable', () => {
|
||||
|
|
|
@ -107,7 +107,7 @@ export function main() {
|
|||
describe('timers', () => {
|
||||
it('should run queued zero duration timer on zero tick', fakeAsync(() => {
|
||||
var ran = false;
|
||||
TimerWrapper.setTimeout(() => {ran = true}, 0);
|
||||
TimerWrapper.setTimeout(() => { ran = true; }, 0);
|
||||
|
||||
expect(ran).toEqual(false);
|
||||
|
||||
|
|
|
@ -7,11 +7,9 @@
|
|||
*/
|
||||
|
||||
import {NgFor} from '@angular/common';
|
||||
import {Component, Directive, Inject, Query, QueryList, bind, forwardRef, provide, resolveForwardRef} from '@angular/core';
|
||||
import {asNativeElements} from '@angular/core';
|
||||
import {Component, Directive, Inject, Query, QueryList, asNativeElements, bind, forwardRef, provide, resolveForwardRef} from '@angular/core';
|
||||
import {TestComponentBuilder} from '@angular/core/testing';
|
||||
import {beforeEach, ddescribe, describe, expect, iit, inject, it, xit} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter, beforeEach, ddescribe, describe, expect, iit, inject, it, xit} from '@angular/core/testing/testing_internal';
|
||||
|
||||
export function main() {
|
||||
describe('forwardRef integration', function() {
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
import {LowerCasePipe, NgIf} from '@angular/common';
|
||||
import {CompilerConfig} from '@angular/compiler';
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {ANALYZE_FOR_PRECOMPILE, AppModule, AppModuleMetadata, Compiler, Component, ComponentFactoryResolver, ComponentRef, ComponentResolver, DebugElement, Directive, Host, Inject, Injectable, Injector, Input, OpaqueToken, Optional, Pipe, Provider, ReflectiveInjector, SelfMetadata, SkipSelf, SkipSelfMetadata, forwardRef, getDebugNode, provide} from '@angular/core';
|
||||
import {ComponentFixture, configureCompiler} from '@angular/core/testing';
|
||||
import {AsyncTestCompleter, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal';
|
||||
|
|
|
@ -12,8 +12,7 @@ import {TEST_COMPILER_PROVIDERS} from '@angular/compiler/test/test_bindings';
|
|||
import {MockSchemaRegistry} from '@angular/compiler/testing';
|
||||
import {AfterContentChecked, AfterContentInit, AfterViewChecked, AfterViewInit, ChangeDetectionStrategy, ChangeDetectorRef, Component, DebugElement, Directive, DoCheck, Injectable, Input, OnChanges, OnDestroy, OnInit, Output, Pipe, PipeTransform, RenderComponentType, Renderer, RootRenderer, SimpleChange, SimpleChanges, TemplateRef, ViewContainerRef, ViewMetadata, WrappedValue, forwardRef} from '@angular/core';
|
||||
import {DebugDomRenderer} from '@angular/core/src/debug/debug_renderer';
|
||||
import {TestComponentBuilder} from '@angular/core/testing';
|
||||
import {ComponentFixture, configureCompiler, configureModule, fakeAsync, flushMicrotasks, tick} from '@angular/core/testing';
|
||||
import {ComponentFixture, TestComponentBuilder, configureCompiler, configureModule, fakeAsync, flushMicrotasks, tick} from '@angular/core/testing';
|
||||
import {afterEach, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xit} from '@angular/core/testing/testing_internal';
|
||||
import {By} from '@angular/platform-browser/src/dom/debug/by';
|
||||
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
||||
|
@ -597,8 +596,9 @@ export function main() {
|
|||
}));
|
||||
|
||||
it('should throw when trying to assign to a local', fakeAsync(() => {
|
||||
expect(() => {_bindSimpleProp('(event)="$event=1"')})
|
||||
.toThrowError(new RegExp('Cannot assign to a reference or variable!'));
|
||||
expect(() => {
|
||||
_bindSimpleProp('(event)="$event=1"');
|
||||
}).toThrowError(new RegExp('Cannot assign to a reference or variable!'));
|
||||
}));
|
||||
|
||||
it('should support short-circuiting', fakeAsync(() => {
|
||||
|
@ -625,7 +625,7 @@ export function main() {
|
|||
describe('reading directives', () => {
|
||||
it('should read directive properties', fakeAsync(() => {
|
||||
var ctx = createCompFixture(
|
||||
'<div testDirective [a]="42" ref-dir="testDirective" [someProp]="dir.a"></div>')
|
||||
'<div testDirective [a]="42" ref-dir="testDirective" [someProp]="dir.a"></div>');
|
||||
ctx.detectChanges(false);
|
||||
expect(renderLog.loggedValues).toEqual([42]);
|
||||
}));
|
||||
|
@ -1479,7 +1479,7 @@ class Address {
|
|||
|
||||
set zipcode(v) { this._zipcode = v; }
|
||||
|
||||
toString(): string { return isBlank(this.city) ? '-' : this.city }
|
||||
toString(): string { return this.city || '-'; }
|
||||
}
|
||||
|
||||
@Component({selector: 'root'})
|
||||
|
|
|
@ -6,12 +6,11 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {beforeEach, ddescribe, xdescribe, describe, expect, iit, inject, beforeEachProviders, it, xit,} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter, beforeEach, ddescribe, xdescribe, describe, expect, iit, inject, beforeEachProviders, it, xit,} from '@angular/core/testing/testing_internal';
|
||||
import {ComponentFixture, TestComponentBuilder} from '@angular/core/testing';
|
||||
import {Predicate} from '../../src/facade/collection';
|
||||
import {Injector, OnDestroy, DebugElement, Type, ViewContainerRef, ViewChild} from '@angular/core';
|
||||
import {Component, ViewMetadata} from '@angular/core/src/metadata';
|
||||
import {Injector, DebugElement, Type, ViewContainerRef, ViewChild} from '@angular/core';
|
||||
import {Component} from '@angular/core/src/metadata';
|
||||
import {DynamicComponentLoader} from '@angular/core/src/linker/dynamic_component_loader';
|
||||
import {ElementRef} from '@angular/core/src/linker/element_ref';
|
||||
import {DOCUMENT} from '@angular/platform-browser/src/dom/dom_tokens';
|
||||
|
|
|
@ -6,9 +6,8 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {beforeEach, ddescribe, xdescribe, describe, expect, iit, inject, beforeEachProviders, it, xit,} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter, beforeEach, ddescribe, xdescribe, describe, expect, iit, inject, beforeEachProviders, it, xit,} from '@angular/core/testing/testing_internal';
|
||||
import {fakeAsync, tick, ComponentFixture, configureCompiler, configureModule, TestComponentBuilder} from '@angular/core/testing';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
||||
import {isPresent, stringify, isBlank,} from '../../src/facade/lang';
|
||||
import {BaseException} from '../../src/facade/exceptions';
|
||||
|
@ -34,19 +33,14 @@ import {ElementRef} from '@angular/core/src/linker/element_ref';
|
|||
import {TemplateRef, TemplateRef_} from '@angular/core/src/linker/template_ref';
|
||||
|
||||
import {Renderer} from '@angular/core/src/render';
|
||||
import {IS_DART} from '../../src/facade/lang';
|
||||
import {el, dispatchEvent} from '@angular/platform-browser/testing/browser_util';
|
||||
|
||||
const ANCHOR_ELEMENT = /*@ts2dart_const*/ new OpaqueToken('AnchorElement');
|
||||
|
||||
export function main() {
|
||||
if (IS_DART) {
|
||||
declareTests({useJit: false});
|
||||
} else {
|
||||
describe('jit', () => { declareTests({useJit: true}); });
|
||||
describe('jit', () => { declareTests({useJit: true}); });
|
||||
|
||||
describe('no jit', () => { declareTests({useJit: false}); });
|
||||
}
|
||||
describe('no jit', () => { declareTests({useJit: false}); });
|
||||
}
|
||||
|
||||
function declareTests({useJit}: {useJit: boolean}) {
|
||||
|
@ -583,18 +577,18 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
tcb.overrideView(MyComp, new ViewMetadata({
|
||||
template: '<p><child-cmp ref-alice></child-cmp></p>',
|
||||
directives: [ChildComp]
|
||||
}))
|
||||
tcb.overrideView(MyComp, new ViewMetadata({
|
||||
template: '<p><child-cmp ref-alice></child-cmp></p>',
|
||||
directives: [ChildComp]
|
||||
}))
|
||||
.createAsync(MyComp)
|
||||
.then((fixture) => {
|
||||
expect(fixture.debugElement.children[0].children[0].references['alice'])
|
||||
.toBeAnInstanceOf(ChildComp);
|
||||
|
||||
.createAsync(MyComp)
|
||||
.then((fixture) => {
|
||||
expect(fixture.debugElement.children[0].children[0].references['alice'])
|
||||
.toBeAnInstanceOf(ChildComp);
|
||||
|
||||
async.done();
|
||||
})}));
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should assign a directive to a ref-',
|
||||
inject(
|
||||
|
@ -604,7 +598,6 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
template: '<div><div export-dir #localdir="dir"></div></div>',
|
||||
directives: [ExportDir]
|
||||
}))
|
||||
|
||||
.createAsync(MyComp)
|
||||
.then((fixture) => {
|
||||
expect(fixture.debugElement.children[0].children[0].references['localdir'])
|
||||
|
@ -618,97 +611,96 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
tcb.overrideView(
|
||||
MyComp, new ViewMetadata({
|
||||
template:
|
||||
'<template [ngIf]="true">{{alice.ctxProp}}</template>|{{alice.ctxProp}}|<child-cmp ref-alice></child-cmp>',
|
||||
directives: [ChildComp, NgIf]
|
||||
}))
|
||||
tcb.overrideView(
|
||||
MyComp, new ViewMetadata({
|
||||
template:
|
||||
'<template [ngIf]="true">{{alice.ctxProp}}</template>|{{alice.ctxProp}}|<child-cmp ref-alice></child-cmp>',
|
||||
directives: [ChildComp, NgIf]
|
||||
}))
|
||||
.createAsync(MyComp)
|
||||
.then((fixture) => {
|
||||
fixture.detectChanges();
|
||||
|
||||
.createAsync(MyComp)
|
||||
.then((fixture) => {
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(fixture.debugElement.nativeElement).toHaveText('hello|hello|hello');
|
||||
async.done();
|
||||
})}));
|
||||
expect(fixture.debugElement.nativeElement).toHaveText('hello|hello|hello');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should assign two component instances each with a ref-',
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
tcb.overrideView(
|
||||
MyComp, new ViewMetadata({
|
||||
template:
|
||||
'<p><child-cmp ref-alice></child-cmp><child-cmp ref-bob></child-cmp></p>',
|
||||
directives: [ChildComp]
|
||||
}))
|
||||
tcb.overrideView(
|
||||
MyComp, new ViewMetadata({
|
||||
template:
|
||||
'<p><child-cmp ref-alice></child-cmp><child-cmp ref-bob></child-cmp></p>',
|
||||
directives: [ChildComp]
|
||||
}))
|
||||
.createAsync(MyComp)
|
||||
.then((fixture) => {
|
||||
var pEl = fixture.debugElement.children[0];
|
||||
|
||||
.createAsync(MyComp)
|
||||
.then((fixture) => {
|
||||
var pEl = fixture.debugElement.children[0];
|
||||
var alice = pEl.children[0].references['alice'];
|
||||
var bob = pEl.children[1].references['bob'];
|
||||
expect(alice).toBeAnInstanceOf(ChildComp);
|
||||
expect(bob).toBeAnInstanceOf(ChildComp);
|
||||
expect(alice).not.toBe(bob);
|
||||
|
||||
var alice = pEl.children[0].references['alice'];
|
||||
var bob = pEl.children[1].references['bob'];
|
||||
expect(alice).toBeAnInstanceOf(ChildComp);
|
||||
expect(bob).toBeAnInstanceOf(ChildComp);
|
||||
expect(alice).not.toBe(bob);
|
||||
|
||||
async.done();
|
||||
})}));
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should assign the component instance to a ref- with shorthand syntax',
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
tcb.overrideView(MyComp, new ViewMetadata({
|
||||
template: '<child-cmp #alice></child-cmp>',
|
||||
directives: [ChildComp]
|
||||
}))
|
||||
tcb.overrideView(
|
||||
MyComp,
|
||||
new ViewMetadata(
|
||||
{template: '<child-cmp #alice></child-cmp>', directives: [ChildComp]}))
|
||||
.createAsync(MyComp)
|
||||
.then((fixture) => {
|
||||
|
||||
.createAsync(MyComp)
|
||||
.then((fixture) => {
|
||||
expect(fixture.debugElement.children[0].references['alice'])
|
||||
.toBeAnInstanceOf(ChildComp);
|
||||
|
||||
expect(fixture.debugElement.children[0].references['alice'])
|
||||
.toBeAnInstanceOf(ChildComp);
|
||||
|
||||
async.done();
|
||||
})}));
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should assign the element instance to a user-defined variable',
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
tcb.overrideView(
|
||||
MyComp, new ViewMetadata(
|
||||
{template: '<div><div ref-alice><i>Hello</i></div></div>'}))
|
||||
tcb.overrideView(
|
||||
MyComp, new ViewMetadata(
|
||||
{template: '<div><div ref-alice><i>Hello</i></div></div>'}))
|
||||
.createAsync(MyComp)
|
||||
.then((fixture) => {
|
||||
|
||||
.createAsync(MyComp)
|
||||
.then((fixture) => {
|
||||
var value = fixture.debugElement.children[0].children[0].references['alice'];
|
||||
expect(value).not.toBe(null);
|
||||
expect(value.tagName.toLowerCase()).toEqual('div');
|
||||
|
||||
var value =
|
||||
fixture.debugElement.children[0].children[0].references['alice'];
|
||||
expect(value).not.toBe(null);
|
||||
expect(value.tagName.toLowerCase()).toEqual('div');
|
||||
|
||||
async.done();
|
||||
})}));
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should assign the TemplateRef to a user-defined variable',
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
tcb.overrideView(
|
||||
MyComp, new ViewMetadata({template: '<template ref-alice></template>'}))
|
||||
tcb.overrideView(
|
||||
MyComp, new ViewMetadata({template: '<template ref-alice></template>'}))
|
||||
.createAsync(MyComp)
|
||||
.then((fixture) => {
|
||||
|
||||
.createAsync(MyComp)
|
||||
.then((fixture) => {
|
||||
var value = fixture.debugElement.childNodes[0].references['alice'];
|
||||
expect(value).toBeAnInstanceOf(TemplateRef_);
|
||||
|
||||
var value = fixture.debugElement.childNodes[0].references['alice'];
|
||||
expect(value).toBeAnInstanceOf(TemplateRef_);
|
||||
|
||||
async.done();
|
||||
})}));
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should preserve case',
|
||||
inject(
|
||||
|
@ -718,7 +710,6 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
template: '<p><child-cmp ref-superAlice></child-cmp></p>',
|
||||
directives: [ChildComp]
|
||||
}))
|
||||
|
||||
.createAsync(MyComp)
|
||||
.then((fixture) => {
|
||||
expect(fixture.debugElement.children[0].children[0].references['superAlice'])
|
||||
|
@ -740,7 +731,6 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
'<template ngFor [ngForOf]="[1]" let-i><child-cmp-no-template #cmp></child-cmp-no-template>{{i}}-{{cmp.ctxProp}}</template>',
|
||||
directives: [ChildCompNoTemplate, NgFor]
|
||||
}))
|
||||
|
||||
.createAsync(MyComp)
|
||||
.then((fixture) => {
|
||||
fixture.detectChanges();
|
||||
|
@ -760,53 +750,53 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
|
||||
tcb.overrideView(MyComp, new ViewMetadata({
|
||||
template: '<push-cmp-with-ref #cmp></push-cmp-with-ref>',
|
||||
directives: [[[PushCmpWithRef]]]
|
||||
}))
|
||||
tcb.overrideView(MyComp, new ViewMetadata({
|
||||
template: '<push-cmp-with-ref #cmp></push-cmp-with-ref>',
|
||||
directives: [[[PushCmpWithRef]]]
|
||||
}))
|
||||
.createAsync(MyComp)
|
||||
.then((fixture) => {
|
||||
|
||||
.createAsync(MyComp)
|
||||
.then((fixture) => {
|
||||
var cmp = fixture.debugElement.children[0].references['cmp'];
|
||||
|
||||
var cmp = fixture.debugElement.children[0].references['cmp'];
|
||||
fixture.detectChanges();
|
||||
expect(cmp.numberOfChecks).toEqual(1);
|
||||
|
||||
fixture.detectChanges();
|
||||
expect(cmp.numberOfChecks).toEqual(1);
|
||||
fixture.detectChanges();
|
||||
expect(cmp.numberOfChecks).toEqual(1);
|
||||
|
||||
fixture.detectChanges();
|
||||
expect(cmp.numberOfChecks).toEqual(1);
|
||||
cmp.propagate();
|
||||
|
||||
cmp.propagate();
|
||||
|
||||
fixture.detectChanges();
|
||||
expect(cmp.numberOfChecks).toEqual(2);
|
||||
async.done();
|
||||
})}));
|
||||
fixture.detectChanges();
|
||||
expect(cmp.numberOfChecks).toEqual(2);
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should be checked when its bindings got updated',
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
|
||||
tcb.overrideView(MyComp, new ViewMetadata({
|
||||
template: '<push-cmp [prop]="ctxProp" #cmp></push-cmp>',
|
||||
directives: [[[PushCmp]]]
|
||||
}))
|
||||
tcb.overrideView(MyComp, new ViewMetadata({
|
||||
template: '<push-cmp [prop]="ctxProp" #cmp></push-cmp>',
|
||||
directives: [[[PushCmp]]]
|
||||
}))
|
||||
.createAsync(MyComp)
|
||||
.then((fixture) => {
|
||||
var cmp = fixture.debugElement.children[0].references['cmp'];
|
||||
|
||||
.createAsync(MyComp)
|
||||
.then((fixture) => {
|
||||
var cmp = fixture.debugElement.children[0].references['cmp'];
|
||||
fixture.debugElement.componentInstance.ctxProp = 'one';
|
||||
fixture.detectChanges();
|
||||
expect(cmp.numberOfChecks).toEqual(1);
|
||||
|
||||
fixture.debugElement.componentInstance.ctxProp = 'one';
|
||||
fixture.detectChanges();
|
||||
expect(cmp.numberOfChecks).toEqual(1);
|
||||
fixture.debugElement.componentInstance.ctxProp = 'two';
|
||||
fixture.detectChanges();
|
||||
expect(cmp.numberOfChecks).toEqual(2);
|
||||
|
||||
fixture.debugElement.componentInstance.ctxProp = 'two';
|
||||
fixture.detectChanges();
|
||||
expect(cmp.numberOfChecks).toEqual(2);
|
||||
|
||||
async.done();
|
||||
})}));
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
if (getDOM().supportsDOMEvents()) {
|
||||
it('should allow to destroy a component from within a host event handler',
|
||||
|
@ -835,69 +825,68 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
|
||||
tcb.overrideView(MyComp, new ViewMetadata({
|
||||
template: '<push-cmp [prop]="ctxProp" #cmp></push-cmp>',
|
||||
directives: [[[PushCmp]]]
|
||||
}))
|
||||
tcb.overrideView(MyComp, new ViewMetadata({
|
||||
template: '<push-cmp [prop]="ctxProp" #cmp></push-cmp>',
|
||||
directives: [[[PushCmp]]]
|
||||
}))
|
||||
.createAsync(MyComp)
|
||||
.then((fixture) => {
|
||||
var cmpEl = fixture.debugElement.children[0];
|
||||
var cmp = cmpEl.componentInstance;
|
||||
fixture.detectChanges();
|
||||
fixture.detectChanges();
|
||||
expect(cmp.numberOfChecks).toEqual(1);
|
||||
|
||||
.createAsync(MyComp)
|
||||
.then((fixture) => {
|
||||
var cmpEl = fixture.debugElement.children[0];
|
||||
var cmp = cmpEl.componentInstance;
|
||||
fixture.detectChanges();
|
||||
fixture.detectChanges();
|
||||
expect(cmp.numberOfChecks).toEqual(1);
|
||||
cmpEl.children[0].triggerEventHandler('click', <Event>{});
|
||||
|
||||
cmpEl.children[0].triggerEventHandler('click', <Event>{});
|
||||
// regular element
|
||||
fixture.detectChanges();
|
||||
fixture.detectChanges();
|
||||
expect(cmp.numberOfChecks).toEqual(2);
|
||||
|
||||
// regular element
|
||||
fixture.detectChanges();
|
||||
fixture.detectChanges();
|
||||
expect(cmp.numberOfChecks).toEqual(2);
|
||||
// element inside of an *ngIf
|
||||
cmpEl.children[1].triggerEventHandler('click', <Event>{});
|
||||
|
||||
// element inside of an *ngIf
|
||||
cmpEl.children[1].triggerEventHandler('click', <Event>{});
|
||||
fixture.detectChanges();
|
||||
fixture.detectChanges();
|
||||
expect(cmp.numberOfChecks).toEqual(3);
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.detectChanges();
|
||||
expect(cmp.numberOfChecks).toEqual(3);
|
||||
// element inside a nested component
|
||||
cmpEl.children[2].children[0].triggerEventHandler('click', <Event>{});
|
||||
|
||||
// element inside a nested component
|
||||
cmpEl.children[2].children[0].triggerEventHandler('click', <Event>{});
|
||||
fixture.detectChanges();
|
||||
fixture.detectChanges();
|
||||
expect(cmp.numberOfChecks).toEqual(4);
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.detectChanges();
|
||||
expect(cmp.numberOfChecks).toEqual(4);
|
||||
|
||||
async.done();
|
||||
})}));
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should not affect updating properties on the component',
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
tcb.overrideView(
|
||||
MyComp, new ViewMetadata({
|
||||
template:
|
||||
'<push-cmp-with-ref [prop]="ctxProp" #cmp></push-cmp-with-ref>',
|
||||
directives: [[[PushCmpWithRef]]]
|
||||
}))
|
||||
tcb.overrideView(
|
||||
MyComp, new ViewMetadata({
|
||||
template: '<push-cmp-with-ref [prop]="ctxProp" #cmp></push-cmp-with-ref>',
|
||||
directives: [[[PushCmpWithRef]]]
|
||||
}))
|
||||
.createAsync(MyComp)
|
||||
.then((fixture) => {
|
||||
|
||||
.createAsync(MyComp)
|
||||
.then((fixture) => {
|
||||
var cmp = fixture.debugElement.children[0].references['cmp'];
|
||||
|
||||
var cmp = fixture.debugElement.children[0].references['cmp'];
|
||||
fixture.debugElement.componentInstance.ctxProp = 'one';
|
||||
fixture.detectChanges();
|
||||
expect(cmp.prop).toEqual('one');
|
||||
|
||||
fixture.debugElement.componentInstance.ctxProp = 'one';
|
||||
fixture.detectChanges();
|
||||
expect(cmp.prop).toEqual('one');
|
||||
fixture.debugElement.componentInstance.ctxProp = 'two';
|
||||
fixture.detectChanges();
|
||||
expect(cmp.prop).toEqual('two');
|
||||
|
||||
fixture.debugElement.componentInstance.ctxProp = 'two';
|
||||
fixture.detectChanges();
|
||||
expect(cmp.prop).toEqual('two');
|
||||
|
||||
async.done();
|
||||
})}));
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
if (getDOM().supportsDOMEvents()) {
|
||||
it('should be checked when an async pipe requests a check',
|
||||
|
@ -932,27 +921,28 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
tcb.overrideView(MyComp, new ViewMetadata({
|
||||
template: `
|
||||
tcb.overrideView(MyComp, new ViewMetadata({
|
||||
template: `
|
||||
<some-directive>
|
||||
<p>
|
||||
<cmp-with-host #child></cmp-with-host>
|
||||
</p>
|
||||
</some-directive>`,
|
||||
directives: [SomeDirective, CompWithHost]
|
||||
}))
|
||||
directives: [SomeDirective, CompWithHost]
|
||||
}))
|
||||
|
||||
.createAsync(MyComp)
|
||||
.then((fixture) => {
|
||||
.createAsync(MyComp)
|
||||
.then((fixture) => {
|
||||
|
||||
var childComponent = fixture.debugElement.children[0]
|
||||
.children[0]
|
||||
.children[0]
|
||||
.references['child'];
|
||||
expect(childComponent.myHost).toBeAnInstanceOf(SomeDirective);
|
||||
var childComponent = fixture.debugElement.children[0]
|
||||
.children[0]
|
||||
.children[0]
|
||||
.references['child'];
|
||||
expect(childComponent.myHost).toBeAnInstanceOf(SomeDirective);
|
||||
|
||||
async.done();
|
||||
})}));
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should create a component that injects an @Host through viewcontainer directive',
|
||||
inject(
|
||||
|
@ -989,7 +979,6 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
template: '<div emitter listener></div>',
|
||||
directives: [DirectiveEmittingEvent, DirectiveListeningEvent]
|
||||
}))
|
||||
|
||||
.createAsync(MyComp)
|
||||
.then((fixture) => {
|
||||
|
||||
|
@ -1026,7 +1015,6 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
template: '<template emitter listener (event)="ctxProp=$event"></template>',
|
||||
directives: [DirectiveEmittingEvent, DirectiveListeningEvent]
|
||||
}))
|
||||
|
||||
.createAsync(MyComp)
|
||||
.then((fixture) => {
|
||||
|
||||
|
@ -1057,7 +1045,6 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
template: '<div [(control)]="ctxProp" two-way></div>',
|
||||
directives: [DirectiveWithTwoWayBinding]
|
||||
}))
|
||||
|
||||
.createAsync(MyComp)
|
||||
.then((fixture) => {
|
||||
var tc = fixture.debugElement.children[0];
|
||||
|
@ -1085,7 +1072,6 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
template: '<div listener></div>',
|
||||
directives: [DirectiveListeningDomEvent]
|
||||
}))
|
||||
|
||||
.createAsync(MyComp)
|
||||
.then((fixture) => {
|
||||
|
||||
|
@ -1115,7 +1101,6 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
template: '<div listener></div>',
|
||||
directives: [DirectiveListeningDomEvent]
|
||||
}))
|
||||
|
||||
.createAsync(MyComp)
|
||||
.then((fixture) => {
|
||||
var tc = fixture.debugElement.children[0];
|
||||
|
@ -1144,7 +1129,6 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
template: '<div update-host-attributes></div>',
|
||||
directives: [DirectiveUpdatingHostAttributes]
|
||||
}))
|
||||
|
||||
.createAsync(MyComp)
|
||||
.then((fixture) => {
|
||||
fixture.detectChanges();
|
||||
|
@ -1165,7 +1149,6 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
template: '<div update-host-properties></div>',
|
||||
directives: [DirectiveUpdatingHostProperties]
|
||||
}))
|
||||
|
||||
.createAsync(MyComp)
|
||||
.then((fixture) => {
|
||||
var tc = fixture.debugElement.children[0];
|
||||
|
@ -1195,7 +1178,6 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
DirectiveListeningDomEventPrevent, DirectiveListeningDomEventNoPrevent
|
||||
]
|
||||
}))
|
||||
|
||||
.createAsync(MyComp)
|
||||
.then((fixture) => {
|
||||
var dispatchedEvent = getDOM().createMouseEvent('click');
|
||||
|
@ -1225,7 +1207,6 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
directives:
|
||||
[NgIf, DirectiveListeningDomEvent, DirectiveListeningDomEventOther]
|
||||
}))
|
||||
|
||||
.createAsync(MyComp)
|
||||
.then((fixture) => {
|
||||
globalCounter = 0;
|
||||
|
@ -1269,7 +1250,6 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
template: '<div><dynamic-vp #dynamic></dynamic-vp></div>',
|
||||
directives: [DynamicViewport]
|
||||
}))
|
||||
|
||||
.createAsync(MyComp)
|
||||
.then((fixture) => {
|
||||
var tc = fixture.debugElement.children[0].children[0];
|
||||
|
@ -1625,62 +1605,60 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
})));
|
||||
}
|
||||
|
||||
if (!IS_DART) {
|
||||
it('should report a meaningful error when a directive is undefined',
|
||||
inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
it('should report a meaningful error when a directive is undefined',
|
||||
inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
|
||||
var undefinedValue: any = void(0);
|
||||
var undefinedValue: any = void(0);
|
||||
|
||||
tcb = tcb.overrideView(
|
||||
MyComp, new ViewMetadata({directives: [undefinedValue], template: ''}));
|
||||
tcb = tcb.overrideView(
|
||||
MyComp, new ViewMetadata({directives: [undefinedValue], template: ''}));
|
||||
|
||||
expect(() => tcb.createAsync(MyComp))
|
||||
.toThrowError(
|
||||
`Unexpected directive value 'undefined' on the View of component '${stringify(MyComp)}'`);
|
||||
}));
|
||||
}
|
||||
expect(() => tcb.createAsync(MyComp))
|
||||
.toThrowError(
|
||||
`Unexpected directive value 'undefined' on the View of component '${stringify(MyComp)}'`);
|
||||
}));
|
||||
|
||||
it('should specify a location of an error that happened during change detection (text)',
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
|
||||
tcb.overrideView(MyComp, new ViewMetadata({template: '<div>{{a.b}}</div>'}))
|
||||
|
||||
.createAsync(MyComp)
|
||||
.then((fixture) => {
|
||||
expect(() => fixture.detectChanges()).toThrowError(/:0:5/);
|
||||
async.done();
|
||||
})}));
|
||||
tcb.overrideView(MyComp, new ViewMetadata({template: '<div>{{a.b}}</div>'}))
|
||||
.createAsync(MyComp)
|
||||
.then((fixture) => {
|
||||
expect(() => fixture.detectChanges()).toThrowError(/:0:5/);
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should specify a location of an error that happened during change detection (element property)',
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
|
||||
tcb.overrideView(MyComp, new ViewMetadata({template: '<div [title]="a.b"></div>'}))
|
||||
|
||||
.createAsync(MyComp)
|
||||
.then((fixture) => {
|
||||
expect(() => fixture.detectChanges()).toThrowError(/:0:5/);
|
||||
async.done();
|
||||
})}));
|
||||
tcb.overrideView(MyComp, new ViewMetadata({template: '<div [title]="a.b"></div>'}))
|
||||
.createAsync(MyComp)
|
||||
.then((fixture) => {
|
||||
expect(() => fixture.detectChanges()).toThrowError(/:0:5/);
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should specify a location of an error that happened during change detection (directive property)',
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
|
||||
tcb.overrideView(MyComp, new ViewMetadata({
|
||||
template: '<child-cmp [title]="a.b"></child-cmp>',
|
||||
directives: [ChildComp]
|
||||
}))
|
||||
|
||||
.createAsync(MyComp)
|
||||
.then((fixture) => {
|
||||
expect(() => fixture.detectChanges()).toThrowError(/:0:11/);
|
||||
async.done();
|
||||
})}));
|
||||
tcb.overrideView(MyComp, new ViewMetadata({
|
||||
template: '<child-cmp [title]="a.b"></child-cmp>',
|
||||
directives: [ChildComp]
|
||||
}))
|
||||
.createAsync(MyComp)
|
||||
.then((fixture) => {
|
||||
expect(() => fixture.detectChanges()).toThrowError(/:0:11/);
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
it('should support imperative views',
|
||||
|
@ -1725,34 +1703,32 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
}));
|
||||
|
||||
describe('Property bindings', () => {
|
||||
if (!IS_DART) {
|
||||
it('should throw on bindings to unknown properties',
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
tcb = tcb.overrideView(
|
||||
MyComp, new ViewMetadata({template: '<div unknown="{{ctxProp}}"></div>'}))
|
||||
it('should throw on bindings to unknown properties',
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
tcb = tcb.overrideView(
|
||||
MyComp, new ViewMetadata({template: '<div unknown="{{ctxProp}}"></div>'}));
|
||||
|
||||
PromiseWrapper.catchError(tcb.createAsync(MyComp), (e) => {
|
||||
expect(e.message).toEqual(
|
||||
`Template parse errors:\nCan't bind to 'unknown' since it isn't a known native property ("<div [ERROR ->]unknown="{{ctxProp}}"></div>"): MyComp@0:5`);
|
||||
async.done();
|
||||
return null;
|
||||
});
|
||||
}));
|
||||
PromiseWrapper.catchError(tcb.createAsync(MyComp), (e) => {
|
||||
expect(e.message).toEqual(
|
||||
`Template parse errors:\nCan't bind to 'unknown' since it isn't a known native property ("<div [ERROR ->]unknown="{{ctxProp}}"></div>"): MyComp@0:5`);
|
||||
async.done();
|
||||
return null;
|
||||
});
|
||||
}));
|
||||
|
||||
it('should not throw for property binding to a non-existing property when there is a matching directive property',
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
tcb.overrideView(MyComp, new ViewMetadata({
|
||||
template: '<div my-dir [elprop]="ctxProp"></div>',
|
||||
directives: [MyDir]
|
||||
}))
|
||||
.createAsync(MyComp)
|
||||
.then((val) => { async.done(); });
|
||||
}));
|
||||
}
|
||||
it('should not throw for property binding to a non-existing property when there is a matching directive property',
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
tcb.overrideView(
|
||||
MyComp,
|
||||
new ViewMetadata(
|
||||
{template: '<div my-dir [elprop]="ctxProp"></div>', directives: [MyDir]}))
|
||||
.createAsync(MyComp)
|
||||
.then((val) => { async.done(); });
|
||||
}));
|
||||
|
||||
it('should not be created when there is a directive with the same property',
|
||||
inject(
|
||||
|
@ -1987,15 +1963,9 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
expect(getDOM().getProperty(<Element>use, 'namespaceURI'))
|
||||
.toEqual('http://www.w3.org/2000/svg');
|
||||
|
||||
if (!IS_DART) {
|
||||
var firstAttribute = getDOM().getProperty(<Element>use, 'attributes')[0];
|
||||
expect(firstAttribute.name).toEqual('xlink:href');
|
||||
expect(firstAttribute.namespaceURI)
|
||||
.toEqual('http://www.w3.org/1999/xlink');
|
||||
} else {
|
||||
// For Dart where '_Attr' has no instance getter 'namespaceURI'
|
||||
expect(getDOM().getOuterHTML(<HTMLElement>use)).toContain('xmlns:xlink');
|
||||
}
|
||||
var firstAttribute = getDOM().getProperty(<Element>use, 'attributes')[0];
|
||||
expect(firstAttribute.name).toEqual('xlink:href');
|
||||
expect(firstAttribute.namespaceURI).toEqual('http://www.w3.org/1999/xlink');
|
||||
|
||||
async.done();
|
||||
});
|
||||
|
|
|
@ -6,14 +6,11 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {beforeEach, ddescribe, xdescribe, describe, expect, iit, inject, beforeEachProviders, it, xit,} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter, beforeEach, ddescribe, xdescribe, describe, expect, iit, inject, beforeEachProviders, it, xit,} from '@angular/core/testing/testing_internal';
|
||||
import {configureCompiler, TestComponentBuilder} from '@angular/core/testing';
|
||||
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
||||
import {OpaqueToken, ViewMetadata, Component, Directive, AfterContentInit, AfterViewInit, QueryList, ContentChildren, ViewChildren, Input} from '@angular/core';
|
||||
import {Component, Directive, AfterContentInit, AfterViewInit, QueryList, ContentChildren, ViewChildren, Input} from '@angular/core';
|
||||
import {NgIf} from '@angular/common';
|
||||
import {CompilerConfig} from '@angular/compiler';
|
||||
import {el} from '@angular/platform-browser/testing/browser_util';
|
||||
|
||||
export function main() {
|
||||
describe('jit', () => { declareTests({useJit: true}); });
|
||||
|
|
|
@ -6,12 +6,9 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {beforeEach, ddescribe, xdescribe, describe, expect, iit, inject, beforeEachProviders, it, xit,} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter, beforeEach, ddescribe, xdescribe, describe, expect, iit, inject, beforeEachProviders, it, xit,} from '@angular/core/testing/testing_internal';
|
||||
import {TestComponentBuilder} from '@angular/core/testing';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
||||
import {Component, ViewChild, ViewContainerRef, ComponentFactoryResolver, NoComponentFactoryError, ComponentRef, forwardRef, ANALYZE_FOR_PRECOMPILE} from '@angular/core';
|
||||
import {CompilerConfig} from '@angular/compiler';
|
||||
import {Component, ComponentFactoryResolver, NoComponentFactoryError, forwardRef, ANALYZE_FOR_PRECOMPILE} from '@angular/core';
|
||||
|
||||
export function main() {
|
||||
describe('jit', () => { declareTests({useJit: true}); });
|
||||
|
|
|
@ -6,13 +6,12 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {beforeEach, ddescribe, xdescribe, describe, expect, iit, inject, beforeEachProviders, it, xit,} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter, beforeEach, ddescribe, xdescribe, describe, expect, iit, inject, beforeEachProviders, it, xit,} from '@angular/core/testing/testing_internal';
|
||||
import {ComponentFixture, TestComponentBuilder} from '@angular/core/testing';
|
||||
|
||||
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
||||
|
||||
import {bind, provide, forwardRef, Component, Directive, ElementRef, TemplateRef, ViewContainerRef, ViewEncapsulation, ViewMetadata} from '@angular/core';
|
||||
import {forwardRef, Component, Directive, ElementRef, TemplateRef, ViewContainerRef, ViewEncapsulation, ViewMetadata} from '@angular/core';
|
||||
import {By,} from '@angular/platform-browser/src/dom/debug/by';
|
||||
import {getAllDebugNodes} from '@angular/core/src/debug/debug_node';
|
||||
|
||||
|
|
|
@ -6,16 +6,14 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {beforeEach, ddescribe, describe, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter, beforeEach, ddescribe, describe, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal';
|
||||
import {TestComponentBuilder} from '@angular/core/testing';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
|
||||
import {isPresent, stringify} from '../../src/facade/lang';
|
||||
import {ObservableWrapper} from '../../src/facade/async';
|
||||
|
||||
import {Component, Directive, TemplateRef, Query, QueryList, ViewQuery, ContentChildren, ViewChildren, ContentChild, ViewChild, AfterContentInit, AfterViewInit, AfterContentChecked, AfterViewChecked} from '@angular/core';
|
||||
import {asNativeElements, ViewContainerRef, Component, Directive, TemplateRef, Query, QueryList, ViewQuery, ContentChildren, ViewChildren, ContentChild, ViewChild, AfterContentInit, AfterViewInit, AfterContentChecked, AfterViewChecked} from '@angular/core';
|
||||
import {NgIf, NgFor} from '@angular/common';
|
||||
import {asNativeElements, ViewContainerRef} from '@angular/core';
|
||||
|
||||
export function main() {
|
||||
describe('Query API', () => {
|
||||
|
@ -303,9 +301,9 @@ export function main() {
|
|||
expect(needsTpl.vc.createEmbeddedView(needsTpl.contentTpl).rootNodes[0])
|
||||
.toHaveText('light');
|
||||
expect(needsTpl.vc.createEmbeddedView(needsTpl.viewTpl).rootNodes[0])
|
||||
.toHaveText('shadow')
|
||||
.toHaveText('shadow');
|
||||
|
||||
async.done();
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
@ -833,6 +831,7 @@ class NeedsViewChildren implements AfterViewInit {
|
|||
|
||||
@Component({selector: 'needs-content-child', template: ''})
|
||||
class NeedsContentChild implements AfterContentInit, AfterContentChecked {
|
||||
/** @internal */
|
||||
_child: TextDirective;
|
||||
|
||||
@ContentChild(TextDirective)
|
||||
|
@ -862,6 +861,7 @@ class NeedsViewChild implements AfterViewInit,
|
|||
AfterViewChecked {
|
||||
shouldShow: boolean = true;
|
||||
shouldShow2: boolean = false;
|
||||
/** @internal */
|
||||
_child: TextDirective;
|
||||
|
||||
@ViewChild(TextDirective)
|
||||
|
|
|
@ -6,12 +6,10 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Component, provide} from '@angular/core';
|
||||
import {ComponentFactory} from '@angular/core/src/linker/component_factory';
|
||||
import {ComponentResolver, ReflectorComponentResolver} from '@angular/core/src/linker/component_resolver';
|
||||
import {ReflectionInfo, reflector} from '@angular/core/src/reflection/reflection';
|
||||
import {afterEach, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter, afterEach, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal';
|
||||
import {Console} from '../../src/console';
|
||||
|
||||
class DummyConsole implements Console {
|
||||
|
@ -42,8 +40,8 @@ export function main() {
|
|||
it('should throw when given a string',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compiler.resolveComponent('someString').catch((e) => {
|
||||
expect(e.message).toContain('Cannot resolve component using \'someString\'.')
|
||||
async.done();
|
||||
expect(e.message).toContain('Cannot resolve component using \'someString\'.');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
|
|
@ -6,24 +6,16 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {beforeEach, ddescribe, xdescribe, describe, expect, iit, inject, beforeEachProviders, it, xit,} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter, beforeEach, ddescribe, xdescribe, describe, expect, iit, inject, beforeEachProviders, it, xit,} from '@angular/core/testing/testing_internal';
|
||||
import {configureCompiler, configureModule, TestComponentBuilder} from '@angular/core/testing';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
|
||||
import {IS_DART} from '../../src/facade/lang';
|
||||
|
||||
import {Component, Pipe, PipeTransform, provide, ViewMetadata, PLATFORM_PIPES, OpaqueToken, Injector, forwardRef} from '@angular/core';
|
||||
import {Component, Pipe, PipeTransform, ViewMetadata, OpaqueToken, Injector, forwardRef} from '@angular/core';
|
||||
import {NgIf, NgClass} from '@angular/common';
|
||||
import {CompilerConfig} from '@angular/compiler';
|
||||
|
||||
export function main() {
|
||||
if (IS_DART) {
|
||||
declareTests({useJit: false});
|
||||
} else {
|
||||
describe('jit', () => { declareTests({useJit: true}); });
|
||||
describe('jit', () => { declareTests({useJit: true}); });
|
||||
|
||||
describe('no jit', () => { declareTests({useJit: false}); });
|
||||
}
|
||||
describe('no jit', () => { declareTests({useJit: false}); });
|
||||
}
|
||||
|
||||
function declareTests({useJit}: {useJit: boolean}) {
|
||||
|
@ -68,20 +60,18 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
});
|
||||
}));
|
||||
|
||||
if (!IS_DART) {
|
||||
it('should evaluate conditional and unary operators with right precedence - #8235',
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
tcb.overrideView(MyComp1, new ViewMetadata({template: `{{!null?.length}}`}))
|
||||
.createAsync(MyComp1)
|
||||
.then((fixture) => {
|
||||
fixture.detectChanges();
|
||||
expect(fixture.nativeElement).toHaveText('true');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
}
|
||||
it('should evaluate conditional and unary operators with right precedence - #8235',
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
tcb.overrideView(MyComp1, new ViewMetadata({template: `{{!null?.length}}`}))
|
||||
.createAsync(MyComp1)
|
||||
.then((fixture) => {
|
||||
fixture.detectChanges();
|
||||
expect(fixture.nativeElement).toHaveText('true');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
describe('providers', () => {
|
||||
|
|
|
@ -6,26 +6,17 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {ddescribe, describe, expect, inject, beforeEachProviders, beforeEach, afterEach, it,} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter, ddescribe, describe, expect, inject, beforeEachProviders, beforeEach, afterEach, it,} from '@angular/core/testing/testing_internal';
|
||||
import {configureCompiler, TestComponentBuilder} from '@angular/core/testing';
|
||||
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
||||
import {provide, Injectable, OpaqueToken} from '@angular/core';
|
||||
import {CompilerConfig} from '@angular/compiler';
|
||||
import {Component, ViewMetadata} from '@angular/core/src/metadata';
|
||||
import {IS_DART} from '../../src/facade/lang';
|
||||
import {el} from '@angular/platform-browser/testing/browser_util';
|
||||
import {Component} from '@angular/core/src/metadata';
|
||||
import {DomSanitizationService} from '@angular/platform-browser/src/security/dom_sanitization_service';
|
||||
|
||||
|
||||
export function main() {
|
||||
if (IS_DART) {
|
||||
declareTests({useJit: false});
|
||||
} else {
|
||||
describe('jit', () => { declareTests({useJit: true}); });
|
||||
describe('jit', () => { declareTests({useJit: true}); });
|
||||
|
||||
describe('no jit', () => { declareTests({useJit: false}); });
|
||||
}
|
||||
describe('no jit', () => { declareTests({useJit: false}); });
|
||||
}
|
||||
|
||||
@Component({selector: 'my-comp', template: '', directives: []})
|
||||
|
|
|
@ -12,7 +12,7 @@ import {Reflector, ReflectionInfo} from '@angular/core/src/reflection/reflection
|
|||
import {ReflectionCapabilities} from '@angular/core/src/reflection/reflection_capabilities';
|
||||
import {ClassDecorator, ParamDecorator, PropDecorator, classDecorator, paramDecorator, propDecorator, HasGetterAndSetterDecorators} from './reflector_common';
|
||||
import {IS_DART} from '../../src/facade/lang';
|
||||
import {browserDetection} from '@angular/platform-browser/testing/browser_util'
|
||||
import {browserDetection} from '@angular/platform-browser/testing/browser_util';
|
||||
|
||||
class AType {
|
||||
value: any /** TODO #9100 */;
|
||||
|
@ -20,17 +20,17 @@ class AType {
|
|||
constructor(value: any /** TODO #9100 */) { this.value = value; }
|
||||
}
|
||||
|
||||
@ClassDecorator('class') class ClassWithDecorators {
|
||||
@ClassDecorator('class')
|
||||
class ClassWithDecorators {
|
||||
@PropDecorator('p1') @PropDecorator('p2') a: any /** TODO #9100 */;
|
||||
b: any /** TODO #9100 */;
|
||||
|
||||
@PropDecorator('p3')
|
||||
set c(value: any /** TODO #9100 */) {
|
||||
}
|
||||
set c(value: any /** TODO #9100 */) {}
|
||||
|
||||
constructor(@ParamDecorator('a') a: AType, @ParamDecorator('b') b: AType) {
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,12 +43,11 @@ class TestObj {
|
|||
b: any /** TODO #9100 */;
|
||||
|
||||
constructor(a: any /** TODO #9100 */, b: any /** TODO #9100 */) {
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
}
|
||||
|
||||
identity(arg: any /** TODO #9100 */) {
|
||||
return arg; }
|
||||
identity(arg: any /** TODO #9100 */) { return arg; }
|
||||
}
|
||||
|
||||
class Interface {}
|
||||
|
@ -74,50 +73,50 @@ class SubClassDoesNotDeclareOnInit extends SuperClassImplementingOnInit {}
|
|||
|
||||
export function main() {
|
||||
describe('Reflector', () => {
|
||||
var reflector: any /** TODO #9100 */;
|
||||
var reflector: any /** TODO #9100 */;
|
||||
|
||||
beforeEach(() => { reflector = new Reflector(new ReflectionCapabilities()); });
|
||||
beforeEach(() => { reflector = new Reflector(new ReflectionCapabilities()); });
|
||||
|
||||
describe('usage tracking', () => {
|
||||
beforeEach(() => { reflector = new Reflector(null); });
|
||||
describe('usage tracking', () => {
|
||||
beforeEach(() => { reflector = new Reflector(null); });
|
||||
|
||||
it('should be disabled by default', () => {
|
||||
expect(() => reflector.listUnusedKeys()).toThrowError('Usage tracking is disabled');
|
||||
it('should be disabled by default', () => {
|
||||
expect(() => reflector.listUnusedKeys()).toThrowError('Usage tracking is disabled');
|
||||
});
|
||||
|
||||
it('should report unused keys', () => {
|
||||
reflector.trackUsage();
|
||||
expect(reflector.listUnusedKeys()).toEqual([]);
|
||||
|
||||
reflector.registerType(AType, new ReflectionInfo(null, null, () => 'AType'));
|
||||
reflector.registerType(TestObj, new ReflectionInfo(null, null, () => 'TestObj'));
|
||||
expect(reflector.listUnusedKeys()).toEqual([AType, TestObj]);
|
||||
|
||||
reflector.factory(AType);
|
||||
expect(reflector.listUnusedKeys()).toEqual([TestObj]);
|
||||
|
||||
reflector.factory(TestObj);
|
||||
expect(reflector.listUnusedKeys()).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
it('should report unused keys', () => {
|
||||
reflector.trackUsage();
|
||||
expect(reflector.listUnusedKeys()).toEqual([]);
|
||||
describe('factory', () => {
|
||||
it('should create a factory for the given type', () => {
|
||||
var obj = reflector.factory(TestObj)(1, 2);
|
||||
|
||||
reflector.registerType(AType, new ReflectionInfo(null, null, () => 'AType'));
|
||||
reflector.registerType(TestObj, new ReflectionInfo(null, null, () => 'TestObj'));
|
||||
expect(reflector.listUnusedKeys()).toEqual([AType, TestObj]);
|
||||
expect(obj.a).toEqual(1);
|
||||
expect(obj.b).toEqual(2);
|
||||
});
|
||||
|
||||
reflector.factory(AType);
|
||||
expect(reflector.listUnusedKeys()).toEqual([TestObj]);
|
||||
// Makes Edge to disconnect when running the full unit test campaign
|
||||
// TODO: remove when issue is solved: https://github.com/angular/angular/issues/4756
|
||||
if (!browserDetection.isEdge) {
|
||||
it('should check args from no to max', () => {
|
||||
var f = (t: any /** TODO #9100 */) => reflector.factory(t);
|
||||
var checkArgs = (obj: any /** TODO #9100 */, args: any /** TODO #9100 */) =>
|
||||
expect(obj.args).toEqual(args);
|
||||
|
||||
reflector.factory(TestObj);
|
||||
expect(reflector.listUnusedKeys()).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('factory', () => {
|
||||
it('should create a factory for the given type', () => {
|
||||
var obj = reflector.factory(TestObj)(1, 2);
|
||||
|
||||
expect(obj.a).toEqual(1);
|
||||
expect(obj.b).toEqual(2);
|
||||
});
|
||||
|
||||
// Makes Edge to disconnect when running the full unit test campaign
|
||||
// TODO: remove when issue is solved: https://github.com/angular/angular/issues/4756
|
||||
if (!browserDetection.isEdge) {
|
||||
it('should check args from no to max', () => {
|
||||
var f = (t: any /** TODO #9100 */) => reflector.factory(t);
|
||||
var checkArgs = (obj: any /** TODO #9100 */, args: any /** TODO #9100 */) =>
|
||||
expect(obj.args).toEqual(args);
|
||||
|
||||
// clang-format off
|
||||
// clang-format off
|
||||
checkArgs(f(TestObjWith00Args)(), []);
|
||||
checkArgs(f(TestObjWith01Args)(1), [1]);
|
||||
checkArgs(f(TestObjWith02Args)(1, 2), [1, 2]);
|
||||
|
@ -139,322 +138,326 @@ export function main() {
|
|||
checkArgs(f(TestObjWith18Args)(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]);
|
||||
checkArgs(f(TestObjWith19Args)(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]);
|
||||
checkArgs(f(TestObjWith20Args)(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]);
|
||||
// clang-format on
|
||||
// clang-format on
|
||||
});
|
||||
}
|
||||
|
||||
it('should throw when more than 20 arguments',
|
||||
() => { expect(() => reflector.factory(TestObjWith21Args)).toThrowError(); });
|
||||
|
||||
it('should return a registered factory if available', () => {
|
||||
reflector.registerType(TestObj, new ReflectionInfo(null, null, () => 'fake'));
|
||||
expect(reflector.factory(TestObj)()).toEqual('fake');
|
||||
});
|
||||
}
|
||||
|
||||
it('should throw when more than 20 arguments',
|
||||
() => { expect(() => reflector.factory(TestObjWith21Args)).toThrowError(); });
|
||||
|
||||
it('should return a registered factory if available', () => {
|
||||
reflector.registerType(TestObj, new ReflectionInfo(null, null, () => 'fake'));
|
||||
expect(reflector.factory(TestObj)()).toEqual('fake');
|
||||
});
|
||||
});
|
||||
|
||||
describe('parameters', () => {
|
||||
it('should return an array of parameters for a type', () => {
|
||||
var p = reflector.parameters(ClassWithDecorators);
|
||||
expect(p).toEqual([[AType, paramDecorator('a')], [AType, paramDecorator('b')]]);
|
||||
});
|
||||
|
||||
it('should work for a class without annotations', () => {
|
||||
var p = reflector.parameters(ClassWithoutDecorators);
|
||||
expect(p.length).toEqual(2);
|
||||
describe('parameters', () => {
|
||||
it('should return an array of parameters for a type', () => {
|
||||
var p = reflector.parameters(ClassWithDecorators);
|
||||
expect(p).toEqual([[AType, paramDecorator('a')], [AType, paramDecorator('b')]]);
|
||||
});
|
||||
|
||||
it('should work for a class without annotations', () => {
|
||||
var p = reflector.parameters(ClassWithoutDecorators);
|
||||
expect(p.length).toEqual(2);
|
||||
});
|
||||
|
||||
it('should return registered parameters if available', () => {
|
||||
reflector.registerType(TestObj, new ReflectionInfo(null, [[1], [2]]));
|
||||
expect(reflector.parameters(TestObj)).toEqual([[1], [2]]);
|
||||
});
|
||||
|
||||
it('should return an empty list when no parameters field in the stored type info', () => {
|
||||
reflector.registerType(TestObj, new ReflectionInfo());
|
||||
expect(reflector.parameters(TestObj)).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
it('should return registered parameters if available', () => {
|
||||
reflector.registerType(TestObj, new ReflectionInfo(null, [[1], [2]]));
|
||||
expect(reflector.parameters(TestObj)).toEqual([[1], [2]]);
|
||||
describe('propMetadata', () => {
|
||||
it('should return a string map of prop metadata for the given class', () => {
|
||||
var p = reflector.propMetadata(ClassWithDecorators);
|
||||
expect(p['a']).toEqual([propDecorator('p1'), propDecorator('p2')]);
|
||||
expect(p['c']).toEqual([propDecorator('p3')]);
|
||||
});
|
||||
|
||||
it('should return registered meta if available', () => {
|
||||
reflector.registerType(TestObj, new ReflectionInfo(null, null, null, null, {'a': [1, 2]}));
|
||||
expect(reflector.propMetadata(TestObj)).toEqual({'a': [1, 2]});
|
||||
});
|
||||
|
||||
if (IS_DART) {
|
||||
it('should merge metadata from getters and setters', () => {
|
||||
var p = reflector.propMetadata(HasGetterAndSetterDecorators);
|
||||
expect(p['a']).toEqual([propDecorator('get'), propDecorator('set')]);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
it('should return an empty list when no parameters field in the stored type info', () => {
|
||||
reflector.registerType(TestObj, new ReflectionInfo());
|
||||
expect(reflector.parameters(TestObj)).toEqual([]);
|
||||
});
|
||||
});
|
||||
describe('annotations', () => {
|
||||
it('should return an array of annotations for a type', () => {
|
||||
var p = reflector.annotations(ClassWithDecorators);
|
||||
expect(p).toEqual([classDecorator('class')]);
|
||||
});
|
||||
|
||||
describe('propMetadata', () => {
|
||||
it('should return a string map of prop metadata for the given class', () => {
|
||||
var p = reflector.propMetadata(ClassWithDecorators);
|
||||
expect(p['a']).toEqual([propDecorator('p1'), propDecorator('p2')]);
|
||||
expect(p['c']).toEqual([propDecorator('p3')]);
|
||||
});
|
||||
it('should return registered annotations if available', () => {
|
||||
reflector.registerType(TestObj, new ReflectionInfo([1, 2]));
|
||||
expect(reflector.annotations(TestObj)).toEqual([1, 2]);
|
||||
});
|
||||
|
||||
it('should return registered meta if available', () => {
|
||||
reflector.registerType(TestObj, new ReflectionInfo(null, null, null, null, {'a': [1, 2]}));
|
||||
expect(reflector.propMetadata(TestObj)).toEqual({'a': [1, 2]});
|
||||
it('should work for a class without annotations', () => {
|
||||
var p = reflector.annotations(ClassWithoutDecorators);
|
||||
expect(p).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
if (IS_DART) {
|
||||
it('should merge metadata from getters and setters', () => {
|
||||
var p = reflector.propMetadata(HasGetterAndSetterDecorators);
|
||||
expect(p['a']).toEqual([propDecorator('get'), propDecorator('set')]);
|
||||
describe('interfaces', () => {
|
||||
it('should return an array of interfaces for a type', () => {
|
||||
var p = reflector.interfaces(ClassImplementingInterface);
|
||||
expect(p).toEqual([Interface, Interface2]);
|
||||
});
|
||||
|
||||
it('should return an empty array otherwise', () => {
|
||||
var p = reflector.interfaces(ClassWithDecorators);
|
||||
expect(p).toEqual([]);
|
||||
});
|
||||
|
||||
it('should throw for undeclared lifecycle interfaces',
|
||||
() => { expect(() => reflector.interfaces(ClassDoesNotDeclareOnInit)).toThrowError(); });
|
||||
|
||||
it('should throw for class inheriting a lifecycle impl and not declaring the interface',
|
||||
() => {
|
||||
expect(() => reflector.interfaces(SubClassDoesNotDeclareOnInit)).toThrowError();
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
describe('annotations', () => {
|
||||
it('should return an array of annotations for a type', () => {
|
||||
var p = reflector.annotations(ClassWithDecorators);
|
||||
expect(p).toEqual([classDecorator('class')]);
|
||||
});
|
||||
|
||||
it('should return registered annotations if available', () => {
|
||||
reflector.registerType(TestObj, new ReflectionInfo([1, 2]));
|
||||
expect(reflector.annotations(TestObj)).toEqual([1, 2]);
|
||||
});
|
||||
|
||||
it('should work for a class without annotations', () => {
|
||||
var p = reflector.annotations(ClassWithoutDecorators);
|
||||
expect(p).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
if (IS_DART) {
|
||||
describe('interfaces', () => {
|
||||
it('should return an array of interfaces for a type', () => {
|
||||
var p = reflector.interfaces(ClassImplementingInterface);
|
||||
expect(p).toEqual([Interface, Interface2]);
|
||||
describe('getter', () => {
|
||||
it('returns a function reading a property', () => {
|
||||
var getA = reflector.getter('a');
|
||||
expect(getA(new TestObj(1, 2))).toEqual(1);
|
||||
});
|
||||
|
||||
it('should return an empty array otherwise', () => {
|
||||
var p = reflector.interfaces(ClassWithDecorators);
|
||||
expect(p).toEqual([]);
|
||||
});
|
||||
|
||||
it('should throw for undeclared lifecycle interfaces',
|
||||
() => { expect(() => reflector.interfaces(ClassDoesNotDeclareOnInit)).toThrowError(); });
|
||||
|
||||
it('should throw for class inheriting a lifecycle impl and not declaring the interface',
|
||||
() => {
|
||||
expect(() => reflector.interfaces(SubClassDoesNotDeclareOnInit)).toThrowError();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
describe('getter', () => {
|
||||
it('returns a function reading a property', () => {
|
||||
var getA = reflector.getter('a');
|
||||
expect(getA(new TestObj(1, 2))).toEqual(1);
|
||||
});
|
||||
|
||||
it('should return a registered getter if available', () => {
|
||||
reflector.registerGetters({'abc': (obj: any /** TODO #9100 */) => 'fake'});
|
||||
expect(reflector.getter('abc')('anything')).toEqual('fake');
|
||||
});
|
||||
});
|
||||
|
||||
describe('setter', () => {
|
||||
it('returns a function setting a property', () => {
|
||||
var setA = reflector.setter('a');
|
||||
var obj = new TestObj(1, 2);
|
||||
setA(obj, 100);
|
||||
expect(obj.a).toEqual(100);
|
||||
});
|
||||
|
||||
it('should return a registered setter if available', () => {
|
||||
var updateMe: any /** TODO #9100 */;
|
||||
reflector.registerSetters({
|
||||
'abc': (obj: any /** TODO #9100 */, value: any /** TODO #9100 */) => { updateMe = value; }
|
||||
});
|
||||
reflector.setter('abc')('anything', 'fake');
|
||||
|
||||
expect(updateMe).toEqual('fake');
|
||||
});
|
||||
});
|
||||
|
||||
describe('method', () => {
|
||||
it('returns a function invoking a method', () => {
|
||||
var func = reflector.method('identity');
|
||||
var obj = new TestObj(1, 2);
|
||||
expect(func(obj, ['value'])).toEqual('value');
|
||||
});
|
||||
|
||||
it('should return a registered method if available', () => {
|
||||
reflector.registerMethods(
|
||||
{'abc': (obj: any /** TODO #9100 */, args: any /** TODO #9100 */) => args});
|
||||
expect(reflector.method('abc')('anything', ['fake'])).toEqual(['fake']);
|
||||
});
|
||||
});
|
||||
|
||||
if (IS_DART) {
|
||||
describe('importUri', () => {
|
||||
it('should return the importUri for a type', () => {
|
||||
expect(reflector.importUri(TestObjWith00Args)
|
||||
.endsWith('test/core/reflection/reflector_spec.dart'))
|
||||
.toBe(true);
|
||||
it('should return a registered getter if available', () => {
|
||||
reflector.registerGetters({'abc': (obj: any /** TODO #9100 */) => 'fake'});
|
||||
expect(reflector.getter('abc')('anything')).toEqual('fake');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
describe('setter', () => {
|
||||
it('returns a function setting a property', () => {
|
||||
var setA = reflector.setter('a');
|
||||
var obj = new TestObj(1, 2);
|
||||
setA(obj, 100);
|
||||
expect(obj.a).toEqual(100);
|
||||
});
|
||||
|
||||
it('should return a registered setter if available', () => {
|
||||
var updateMe: any /** TODO #9100 */;
|
||||
reflector.registerSetters({
|
||||
'abc': (obj: any /** TODO #9100 */, value: any /** TODO #9100 */) => { updateMe = value; }
|
||||
});
|
||||
reflector.setter('abc')('anything', 'fake');
|
||||
|
||||
expect(updateMe).toEqual('fake');
|
||||
});
|
||||
});
|
||||
|
||||
describe('method', () => {
|
||||
it('returns a function invoking a method', () => {
|
||||
var func = reflector.method('identity');
|
||||
var obj = new TestObj(1, 2);
|
||||
expect(func(obj, ['value'])).toEqual('value');
|
||||
});
|
||||
|
||||
it('should return a registered method if available', () => {
|
||||
reflector.registerMethods(
|
||||
{'abc': (obj: any /** TODO #9100 */, args: any /** TODO #9100 */) => args});
|
||||
expect(reflector.method('abc')('anything', ['fake'])).toEqual(['fake']);
|
||||
});
|
||||
});
|
||||
|
||||
if (IS_DART) {
|
||||
describe('importUri', () => {
|
||||
it('should return the importUri for a type', () => {
|
||||
expect(reflector.importUri(TestObjWith00Args)
|
||||
.endsWith('test/core/reflection/reflector_spec.dart'))
|
||||
.toBe(true);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
class TestObjWith00Args {
|
||||
args: any[];
|
||||
constructor() {
|
||||
this.args = []; }
|
||||
constructor() { this.args = []; }
|
||||
}
|
||||
|
||||
class TestObjWith01Args {
|
||||
args: any[];
|
||||
constructor(a1: any) {
|
||||
this.args = [a1]; }
|
||||
constructor(a1: any) { this.args = [a1]; }
|
||||
}
|
||||
|
||||
class TestObjWith02Args {
|
||||
args: any[];
|
||||
constructor(a1: any, a2: any) {
|
||||
this.args = [a1, a2]; }
|
||||
constructor(a1: any, a2: any) { this.args = [a1, a2]; }
|
||||
}
|
||||
|
||||
class TestObjWith03Args {
|
||||
args: any[];
|
||||
constructor(a1: any, a2: any, a3: any) {
|
||||
this.args = [a1, a2, a3]; }
|
||||
constructor(a1: any, a2: any, a3: any) { this.args = [a1, a2, a3]; }
|
||||
}
|
||||
|
||||
class TestObjWith04Args {
|
||||
args: any[];
|
||||
constructor(a1: any, a2: any, a3: any, a4: any) {
|
||||
this.args = [a1, a2, a3, a4]; }
|
||||
constructor(a1: any, a2: any, a3: any, a4: any) { this.args = [a1, a2, a3, a4]; }
|
||||
}
|
||||
|
||||
class TestObjWith05Args {
|
||||
args: any[];
|
||||
constructor(a1: any, a2: any, a3: any, a4: any, a5: any) {
|
||||
this.args = [a1, a2, a3, a4, a5]; }
|
||||
constructor(a1: any, a2: any, a3: any, a4: any, a5: any) { this.args = [a1, a2, a3, a4, a5]; }
|
||||
}
|
||||
|
||||
class TestObjWith06Args {
|
||||
args: any[];
|
||||
constructor(a1: any, a2: any, a3: any, a4: any, a5: any, a6: any) {
|
||||
this.args = [a1, a2, a3, a4, a5, a6];
|
||||
this.args = [a1, a2, a3, a4, a5, a6];
|
||||
}
|
||||
}
|
||||
|
||||
class TestObjWith07Args {
|
||||
args: any[];
|
||||
constructor(a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any) {
|
||||
this.args = [a1, a2, a3, a4, a5, a6, a7];
|
||||
this.args = [a1, a2, a3, a4, a5, a6, a7];
|
||||
}
|
||||
}
|
||||
|
||||
class TestObjWith08Args {
|
||||
args: any[];
|
||||
constructor(a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any) {
|
||||
this.args = [a1, a2, a3, a4, a5, a6, a7, a8];
|
||||
this.args = [a1, a2, a3, a4, a5, a6, a7, a8];
|
||||
}
|
||||
}
|
||||
|
||||
class TestObjWith09Args {
|
||||
args: any[];
|
||||
constructor(a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any) {
|
||||
this.args = [a1, a2, a3, a4, a5, a6, a7, a8, a9];
|
||||
this.args = [a1, a2, a3, a4, a5, a6, a7, a8, a9];
|
||||
}
|
||||
}
|
||||
|
||||
class TestObjWith10Args {
|
||||
args: any[];
|
||||
constructor(a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any,
|
||||
a10: any) {
|
||||
this.args = [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10];
|
||||
constructor(
|
||||
a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, a10: any) {
|
||||
this.args = [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10];
|
||||
}
|
||||
}
|
||||
|
||||
class TestObjWith11Args {
|
||||
args: any[];
|
||||
constructor(a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any,
|
||||
a10: any, a11: any) {
|
||||
this.args = [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11];
|
||||
constructor(
|
||||
a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, a10: any,
|
||||
a11: any) {
|
||||
this.args = [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11];
|
||||
}
|
||||
}
|
||||
|
||||
class TestObjWith12Args {
|
||||
args: any[];
|
||||
constructor(a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any,
|
||||
a10: any, a11: any, a12: any) {
|
||||
this.args = [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12];
|
||||
constructor(
|
||||
a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, a10: any,
|
||||
a11: any, a12: any) {
|
||||
this.args = [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12];
|
||||
}
|
||||
}
|
||||
|
||||
class TestObjWith13Args {
|
||||
args: any[];
|
||||
constructor(a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any,
|
||||
a10: any, a11: any, a12: any, a13: any) {
|
||||
this.args = [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13];
|
||||
constructor(
|
||||
a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, a10: any,
|
||||
a11: any, a12: any, a13: any) {
|
||||
this.args = [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13];
|
||||
}
|
||||
}
|
||||
|
||||
class TestObjWith14Args {
|
||||
args: any[];
|
||||
constructor(a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any,
|
||||
a10: any, a11: any, a12: any, a13: any, a14: any) {
|
||||
this.args = [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14];
|
||||
constructor(
|
||||
a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, a10: any,
|
||||
a11: any, a12: any, a13: any, a14: any) {
|
||||
this.args = [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14];
|
||||
}
|
||||
}
|
||||
|
||||
class TestObjWith15Args {
|
||||
args: any[];
|
||||
constructor(a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any,
|
||||
a10: any, a11: any, a12: any, a13: any, a14: any, a15: any) {
|
||||
this.args = [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15];
|
||||
constructor(
|
||||
a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, a10: any,
|
||||
a11: any, a12: any, a13: any, a14: any, a15: any) {
|
||||
this.args = [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15];
|
||||
}
|
||||
}
|
||||
|
||||
class TestObjWith16Args {
|
||||
args: any[];
|
||||
constructor(a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any,
|
||||
a10: any, a11: any, a12: any, a13: any, a14: any, a15: any, a16: any) {
|
||||
this.args = [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16];
|
||||
constructor(
|
||||
a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, a10: any,
|
||||
a11: any, a12: any, a13: any, a14: any, a15: any, a16: any) {
|
||||
this.args = [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16];
|
||||
}
|
||||
}
|
||||
|
||||
class TestObjWith17Args {
|
||||
args: any[];
|
||||
constructor(a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any,
|
||||
a10: any, a11: any, a12: any, a13: any, a14: any, a15: any, a16: any, a17: any) {
|
||||
this.args = [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17];
|
||||
constructor(
|
||||
a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, a10: any,
|
||||
a11: any, a12: any, a13: any, a14: any, a15: any, a16: any, a17: any) {
|
||||
this.args = [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17];
|
||||
}
|
||||
}
|
||||
|
||||
class TestObjWith18Args {
|
||||
args: any[];
|
||||
constructor(a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any,
|
||||
a10: any, a11: any, a12: any, a13: any, a14: any, a15: any, a16: any, a17: any,
|
||||
a18: any) {
|
||||
this.args = [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18];
|
||||
constructor(
|
||||
a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, a10: any,
|
||||
a11: any, a12: any, a13: any, a14: any, a15: any, a16: any, a17: any, a18: any) {
|
||||
this.args = [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18];
|
||||
}
|
||||
}
|
||||
|
||||
class TestObjWith19Args {
|
||||
args: any[];
|
||||
constructor(a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any,
|
||||
a10: any, a11: any, a12: any, a13: any, a14: any, a15: any, a16: any, a17: any,
|
||||
a18: any, a19: any) {
|
||||
this.args =
|
||||
[a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19];
|
||||
constructor(
|
||||
a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, a10: any,
|
||||
a11: any, a12: any, a13: any, a14: any, a15: any, a16: any, a17: any, a18: any, a19: any) {
|
||||
this.args =
|
||||
[a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19];
|
||||
}
|
||||
}
|
||||
|
||||
class TestObjWith20Args {
|
||||
args: any[];
|
||||
constructor(a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any,
|
||||
a10: any, a11: any, a12: any, a13: any, a14: any, a15: any, a16: any, a17: any,
|
||||
a18: any, a19: any, a20: any) {
|
||||
this.args =
|
||||
[a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20];
|
||||
constructor(
|
||||
a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, a10: any,
|
||||
a11: any, a12: any, a13: any, a14: any, a15: any, a16: any, a17: any, a18: any, a19: any,
|
||||
a20: any) {
|
||||
this.args =
|
||||
[a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20];
|
||||
}
|
||||
}
|
||||
|
||||
class TestObjWith21Args {
|
||||
args: any[];
|
||||
constructor(a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any,
|
||||
a10: any, a11: any, a12: any, a13: any, a14: any, a15: any, a16: any, a17: any,
|
||||
a18: any, a19: any, a20: any, a21: any) {
|
||||
this.args = [
|
||||
a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21
|
||||
];
|
||||
constructor(
|
||||
a1: any, a2: any, a3: any, a4: any, a5: any, a6: any, a7: any, a8: any, a9: any, a10: any,
|
||||
a11: any, a12: any, a13: any, a14: any, a15: any, a16: any, a17: any, a18: any, a19: any,
|
||||
a20: any, a21: any) {
|
||||
this.args = [
|
||||
a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11,
|
||||
a12, a13, a14, a15, a16, a17, a18, a19, a20, a21
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,8 +7,7 @@
|
|||
*/
|
||||
|
||||
import {Injectable} from '@angular/core/src/di';
|
||||
import {inject, describe, ddescribe, it, iit, xit, xdescribe, expect, beforeEach,} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter, SpyObject} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter, SpyObject, inject, describe, ddescribe, it, iit, xit, xdescribe, expect, beforeEach,} from '@angular/core/testing/testing_internal';
|
||||
import {Testability} from '@angular/core/src/testability/testability';
|
||||
import {NgZone} from '@angular/core/src/zone/ng_zone';
|
||||
import {normalizeBlank, scheduleMicroTask} from '../../src/facade/lang';
|
||||
|
@ -17,7 +16,7 @@ import {PromiseWrapper, EventEmitter, ObservableWrapper} from '../../src/facade/
|
|||
// Schedules a microtasks (using a resolved promise .then())
|
||||
function microTask(fn: Function): void {
|
||||
scheduleMicroTask(() => {
|
||||
// We do double dispatch so that we can wait for scheduleMicrotas in the Testability when
|
||||
// We do double dispatch so that we can wait for scheduleMicrotask in the Testability when
|
||||
// NgZone becomes stable.
|
||||
scheduleMicroTask(fn);
|
||||
});
|
||||
|
@ -25,9 +24,11 @@ function microTask(fn: Function): void {
|
|||
|
||||
@Injectable()
|
||||
class MockNgZone extends NgZone {
|
||||
/** @internal */
|
||||
_onUnstableStream: EventEmitter<any>;
|
||||
get onUnstable() { return this._onUnstableStream; }
|
||||
|
||||
/** @internal */
|
||||
_onStableStream: EventEmitter<any>;
|
||||
get onStable() { return this._onStableStream; }
|
||||
|
||||
|
|
|
@ -74,8 +74,7 @@ export function main() {
|
|||
() => { expect(spyObj.spy('someFunc')).not.toHaveBeenCalled(); });
|
||||
|
||||
it('should record function calls', () => {
|
||||
spyObj.spy('someFunc')
|
||||
.andCallFake((a: any /** TODO #9100 */, b: any /** TODO #9100 */) => {return a + b});
|
||||
spyObj.spy('someFunc').andCallFake((a: any, b: any) => a + b);
|
||||
|
||||
expect(spyObj.someFunc(1, 2)).toEqual(3);
|
||||
expect(spyObj.spy('someFunc')).toHaveBeenCalledWith(1, 2);
|
||||
|
|
|
@ -89,7 +89,7 @@ export function main() {
|
|||
expect(proto.extends).toEqual(undefined);
|
||||
expect(proto.prototype).toEqual(undefined);
|
||||
|
||||
expect(reflector.annotations(MyClass)[0].arg).toEqual('test-works')
|
||||
expect(reflector.annotations(MyClass)[0].arg).toEqual('test-works');
|
||||
});
|
||||
|
||||
describe('errors', () => {
|
||||
|
@ -108,13 +108,15 @@ export function main() {
|
|||
|
||||
|
||||
it('should ensure that last position is function', () => {
|
||||
expect(() => {Class({constructor: []})})
|
||||
expect(() => { Class({constructor: []}); })
|
||||
.toThrowError(
|
||||
'Last position of Class method array must be Function in key constructor was \'undefined\'');
|
||||
});
|
||||
|
||||
it('should ensure that annotation count matches parameters count', () => {
|
||||
expect(() => {Class({constructor: [String, function MyType() {}]})})
|
||||
expect(() => {
|
||||
Class({constructor: [String, function MyType() {}]});
|
||||
})
|
||||
.toThrowError(
|
||||
'Number of annotations (1) does not match number of arguments (0) in the function: MyType');
|
||||
});
|
||||
|
@ -126,7 +128,7 @@ export function main() {
|
|||
});
|
||||
|
||||
it('should ensure that extends is a Function', () => {
|
||||
expect(() => {(<Function>Class)({extends: 'non_type', constructor: function() {}})})
|
||||
expect(() => { (<Function>Class)({extends: 'non_type', constructor: function() {}}); })
|
||||
.toThrowError(
|
||||
'Class definition \'extends\' property must be a constructor function was: non_type');
|
||||
});
|
||||
|
|
|
@ -6,15 +6,14 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Log, beforeEach, ddescribe, describe, expect, iit, inject, it, xdescribe, xit,} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter, Log, beforeEach, ddescribe, describe, expect, iit, inject, it, xdescribe, xit,} from '@angular/core/testing/testing_internal';
|
||||
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
import {NgZone, NgZoneError} from '@angular/core/src/zone/ng_zone';
|
||||
import {browserDetection} from '@angular/platform-browser/testing/browser_util';
|
||||
|
||||
import {ObservableWrapper, PromiseCompleter, PromiseWrapper, TimerWrapper} from '../../src/facade/async';
|
||||
import {BaseException} from '../../src/facade/exceptions';
|
||||
import {IS_DART, isPresent, scheduleMicroTask} from '../../src/facade/lang';
|
||||
import {isPresent, scheduleMicroTask} from '../../src/facade/lang';
|
||||
|
||||
var needsLongerTimers = browserDetection.isSlow || browserDetection.isEdge;
|
||||
var resultTimer = 1000;
|
||||
|
@ -443,7 +442,7 @@ function commonTests() {
|
|||
|
||||
macroTask(() => {
|
||||
expect(_log.result()).toEqual('run');
|
||||
async.done()
|
||||
async.done();
|
||||
});
|
||||
}), testTimeout);
|
||||
|
||||
|
|
|
@ -6,8 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {describe, it, expect, beforeEach, ddescribe, iit, xit, inject,} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter, describe, it, expect, beforeEach, ddescribe, iit, xit, inject,} from '@angular/core/testing/testing_internal';
|
||||
import {browserDetection} from '@angular/platform-browser/testing/browser_util';
|
||||
import {ObservableWrapper, Observable, Subject, EventEmitter, PromiseWrapper} from '../src/async';
|
||||
|
||||
|
|
|
@ -7,17 +7,15 @@
|
|||
*/
|
||||
|
||||
import {NgFor, NgIf} from '@angular/common';
|
||||
import {Component, Directive, EventEmitter, Output} from '@angular/core';
|
||||
import {Input, Provider, forwardRef} from '@angular/core';
|
||||
import {Component, Directive, EventEmitter, Input, Output, forwardRef} from '@angular/core';
|
||||
import {ComponentFixture, TestComponentBuilder, configureModule, fakeAsync, flushMicrotasks, tick} from '@angular/core/testing';
|
||||
import {afterEach, beforeEach, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
import {ControlValueAccessor, FORM_DIRECTIVES, FORM_PROVIDERS, FormArray, FormControl, FormGroup, FormsModule, NG_ASYNC_VALIDATORS, NG_VALIDATORS, NgControl, NgForm, NgModel, REACTIVE_FORM_DIRECTIVES, ReactiveFormsModule, Validator, Validators} from '@angular/forms';
|
||||
import {AsyncTestCompleter, afterEach, beforeEach, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal';
|
||||
import {ControlValueAccessor, FormArray, FormControl, FormGroup, FormsModule, NG_ASYNC_VALIDATORS, NG_VALIDATORS, NgControl, NgForm, ReactiveFormsModule, Validator, Validators} from '@angular/forms';
|
||||
import {By} from '@angular/platform-browser/src/dom/debug/by';
|
||||
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
||||
import {dispatchEvent} from '@angular/platform-browser/testing/browser_util';
|
||||
|
||||
import {ObservableWrapper, TimerWrapper} from '../src/facade/async';
|
||||
import {ObservableWrapper} from '../src/facade/async';
|
||||
import {ListWrapper} from '../src/facade/collection';
|
||||
import {PromiseWrapper} from '../src/facade/promise';
|
||||
|
||||
|
|
|
@ -7,12 +7,11 @@
|
|||
*/
|
||||
|
||||
import {fakeAsync, flushMicrotasks, tick} from '@angular/core/testing';
|
||||
import {afterEach, beforeEach, ddescribe, describe, iit, inject, it, xit} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter, afterEach, beforeEach, ddescribe, describe, iit, inject, it, xit} from '@angular/core/testing/testing_internal';
|
||||
import {FormArray, FormControl, FormGroup, Validators} from '@angular/forms';
|
||||
|
||||
import {EventEmitter, ObservableWrapper, TimerWrapper} from '../src/facade/async';
|
||||
import {IS_DART, isPresent} from '../src/facade/lang';
|
||||
import {isPresent} from '../src/facade/lang';
|
||||
import {PromiseWrapper} from '../src/facade/promise';
|
||||
|
||||
export function main() {
|
||||
|
@ -492,17 +491,15 @@ export function main() {
|
|||
}));
|
||||
|
||||
// TODO: remove the if statement after making observable delivery sync
|
||||
if (!IS_DART) {
|
||||
it('should update set errors and status before emitting an event',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
c.valueChanges.subscribe((value: any /** TODO #9100 */) => {
|
||||
expect(c.valid).toEqual(false);
|
||||
expect(c.errors).toEqual({'required': true});
|
||||
async.done();
|
||||
});
|
||||
c.updateValue('');
|
||||
}));
|
||||
}
|
||||
it('should update set errors and status before emitting an event',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
c.valueChanges.subscribe((value: any /** TODO #9100 */) => {
|
||||
expect(c.valid).toEqual(false);
|
||||
expect(c.errors).toEqual({'required': true});
|
||||
async.done();
|
||||
});
|
||||
c.updateValue('');
|
||||
}));
|
||||
|
||||
it('should return a cold observable',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
|
@ -946,7 +943,7 @@ export function main() {
|
|||
|
||||
// rename contains into has
|
||||
it('should return false when the component is not included',
|
||||
() => { expect(group.contains('optional')).toEqual(false); })
|
||||
() => { expect(group.contains('optional')).toEqual(false); });
|
||||
|
||||
it('should return false when there is no component with the given name',
|
||||
() => { expect(group.contains('something else')).toEqual(false); });
|
||||
|
@ -1066,11 +1063,8 @@ export function main() {
|
|||
c2.updateValue('new2');
|
||||
}));
|
||||
|
||||
xit('should not fire an event when an excluded control is updated',
|
||||
inject(
|
||||
[AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
// hard to test without hacking zones
|
||||
}));
|
||||
// hard to test without hacking zones
|
||||
// xit('should not fire an event when an excluded control is updated', () => null);
|
||||
});
|
||||
|
||||
describe('statusChanges', () => {
|
||||
|
@ -1143,7 +1137,7 @@ export function main() {
|
|||
expect(g.errors).toEqual({'async': true});
|
||||
expect(g.find(['one']).errors).toEqual({'async': true});
|
||||
}));
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
describe('FormArray', () => {
|
||||
|
@ -1644,7 +1638,7 @@ export function main() {
|
|||
expect(g.errors).toEqual({'async': true});
|
||||
expect(g.pending).toEqual(false);
|
||||
}));
|
||||
})
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {fakeAsync, flushMicrotasks, tick} from '@angular/core/testing';
|
||||
import {fakeAsync, tick} from '@angular/core/testing';
|
||||
import {afterEach, beforeEach, ddescribe, describe, expect, iit, it, xit} from '@angular/core/testing/testing_internal';
|
||||
import {AbstractControl, FormControl, Validators} from '@angular/forms';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
|
@ -19,9 +19,9 @@ export function main() {
|
|||
function validator(key: string, error: any) {
|
||||
return function(c: AbstractControl) {
|
||||
var r = {};
|
||||
(r as any /** TODO #9100 */)[key] = error;
|
||||
(r as any)[key] = error;
|
||||
return r;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
class AsyncValidatorDirective {
|
||||
|
|
|
@ -6,13 +6,11 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {afterEach, beforeEach, ddescribe, describe, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter, SpyObject} from '@angular/core/testing/testing_internal';
|
||||
import {ObservableWrapper} from '../../src/facade/async';
|
||||
import {AsyncTestCompleter, SpyObject, afterEach, beforeEach, ddescribe, describe, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal';
|
||||
import {BrowserJsonp} from '../../src/backends/browser_jsonp';
|
||||
import {JSONPConnection, JSONPConnection_, JSONPBackend, JSONPBackend_} from '../../src/backends/jsonp_backend';
|
||||
import {provide, Injector, ReflectiveInjector} from '@angular/core';
|
||||
import {isPresent, StringWrapper} from '../../src/facade/lang';
|
||||
import {ReflectiveInjector} from '@angular/core';
|
||||
import {isPresent,} from '../../src/facade/lang';
|
||||
import {TimerWrapper} from '../../src/facade/async';
|
||||
import {Request} from '../../src/static_request';
|
||||
import {Response} from '../../src/static_response';
|
||||
|
@ -21,7 +19,6 @@ import {RequestOptions, BaseRequestOptions} from '../../src/base_request_options
|
|||
import {BaseResponseOptions, ResponseOptions} from '../../src/base_response_options';
|
||||
import {ResponseType, ReadyState, RequestMethod} from '../../src/enums';
|
||||
|
||||
var addEventListenerSpy: any;
|
||||
var existingScripts: MockBrowserJsonp[] = [];
|
||||
var unused: Response;
|
||||
|
||||
|
|
|
@ -6,19 +6,13 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {afterEach, beforeEach, ddescribe, describe, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
import {ObservableWrapper} from '../../src/facade/async';
|
||||
import {BrowserXhr} from '../../src/backends/browser_xhr';
|
||||
import {AsyncTestCompleter, afterEach, beforeEach, ddescribe, describe, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal';
|
||||
import {MockConnection, MockBackend} from '../../testing/mock_backend';
|
||||
import {provide, Injector, ReflectiveInjector} from '@angular/core';
|
||||
import {ReflectiveInjector} from '@angular/core';
|
||||
import {Request} from '../../src/static_request';
|
||||
import {Response} from '../../src/static_response';
|
||||
import {Headers} from '../../src/headers';
|
||||
import {Map} from '../../src/facade/collection';
|
||||
import {RequestOptions, BaseRequestOptions} from '../../src/base_request_options';
|
||||
import {BaseResponseOptions, ResponseOptions} from '../../src/base_response_options';
|
||||
import {ResponseType} from '../../src/enums';
|
||||
import {ReplaySubject} from 'rxjs/ReplaySubject';
|
||||
|
||||
export function main() {
|
||||
|
@ -41,10 +35,11 @@ export function main() {
|
|||
sampleResponse2 = new Response(new ResponseOptions({body: 'response2'}));
|
||||
});
|
||||
|
||||
it('should create a new MockBackend', () => {expect(backend).toBeAnInstanceOf(MockBackend)});
|
||||
it('should create a new MockBackend', () => { expect(backend).toBeAnInstanceOf(MockBackend); });
|
||||
|
||||
it('should create a new MockConnection',
|
||||
() => {expect(backend.createConnection(sampleRequest1)).toBeAnInstanceOf(MockConnection)});
|
||||
it('should create a new MockConnection', () => {
|
||||
expect(backend.createConnection(sampleRequest1)).toBeAnInstanceOf(MockConnection);
|
||||
});
|
||||
|
||||
it('should create a new connection and allow subscription', () => {
|
||||
let connection: MockConnection = backend.createConnection(sampleRequest1);
|
||||
|
|
|
@ -6,13 +6,12 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {afterEach, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter, SpyObject} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter, SpyObject, afterEach, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal';
|
||||
import {BrowserXhr} from '../../src/backends/browser_xhr';
|
||||
import {Json} from '../../src/facade/lang';
|
||||
import {XSRFStrategy} from '../../src/interfaces';
|
||||
import {XHRConnection, XHRBackend, CookieXSRFStrategy} from '../../src/backends/xhr_backend';
|
||||
import {provide, Injector, Injectable, ReflectiveInjector} from '@angular/core';
|
||||
import {Injectable,} from '@angular/core';
|
||||
import {__platform_browser_private__} from '@angular/platform-browser';
|
||||
import {Request} from '../../src/static_request';
|
||||
import {Response} from '../../src/static_response';
|
||||
|
@ -146,7 +145,7 @@ export function main() {
|
|||
backend.createConnection(sampleRequest);
|
||||
expect(sampleRequest.headers.get('X-MY-HEADER')).toBe('XSRF value');
|
||||
});
|
||||
})
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -558,7 +557,7 @@ export function main() {
|
|||
let responseHeaderString = `Date: Fri, 20 Nov 2015 01:45:26 GMT
|
||||
Content-Type: application/json; charset=utf-8
|
||||
Transfer-Encoding: chunked
|
||||
Connection: keep-alive`
|
||||
Connection: keep-alive`;
|
||||
|
||||
connection.response.subscribe((res: Response) => {
|
||||
expect(res.headers.get('Date')).toEqual('Fri, 20 Nov 2015 01:45:26 GMT');
|
||||
|
@ -595,7 +594,7 @@ export function main() {
|
|||
var connection = new XHRConnection(
|
||||
sampleRequest, new MockBrowserXHR(), new ResponseOptions({status: statusCode}));
|
||||
var responseHeaders = `X-Request-URL: http://somedomain.com
|
||||
Foo: Bar`
|
||||
Foo: Bar`;
|
||||
|
||||
connection.response.subscribe((res: Response) => {
|
||||
expect(res.url).toEqual('http://somedomain.com');
|
||||
|
@ -643,7 +642,7 @@ export function main() {
|
|||
var connection =
|
||||
new XHRConnection(sampleRequest, mockXhr, new ResponseOptions({status: statusCode}));
|
||||
var responseHeaders = `X-Request-URL: http://somedomain.com
|
||||
Foo: Bar`
|
||||
Foo: Bar`;
|
||||
|
||||
connection.response.subscribe((res: Response) => {
|
||||
expect(res.url).toEqual('http://somedomain.com');
|
||||
|
|
|
@ -6,11 +6,9 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Injector, ReflectiveInjector, provide} from '@angular/core';
|
||||
import {afterEach, beforeEach, ddescribe, describe, expect, iit, inject, it, xit} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
import {Injector, ReflectiveInjector} from '@angular/core';
|
||||
import {AsyncTestCompleter, afterEach, beforeEach, ddescribe, describe, expect, iit, inject, it, xit} from '@angular/core/testing/testing_internal';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import {Subject} from 'rxjs/Subject';
|
||||
import {zip} from 'rxjs/observable/zip';
|
||||
|
||||
import {BaseRequestOptions, ConnectionBackend, HTTP_PROVIDERS, Http, JSONPBackend, JSONP_PROVIDERS, Jsonp, Request, RequestMethod, RequestOptions, Response, ResponseContentType, ResponseOptions, URLSearchParams, XHRBackend} from '../http';
|
||||
|
@ -354,7 +352,7 @@ export function main() {
|
|||
it('should allow case insensitive strings for method names', () => {
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
backend.connections.subscribe((c: MockConnection) => {
|
||||
expect(c.request.method).toBe(RequestMethod.Post)
|
||||
expect(c.request.method).toBe(RequestMethod.Post);
|
||||
c.mockRespond(new Response(new ResponseOptions({body: 'Thank you'})));
|
||||
async.done();
|
||||
});
|
||||
|
@ -478,7 +476,7 @@ export function main() {
|
|||
return stringToArrayBuffer(Json.stringify(message));
|
||||
}
|
||||
};
|
||||
c.mockRespond(new Response(new ResponseOptions({body: body()})))
|
||||
c.mockRespond(new Response(new ResponseOptions({body: body()})));
|
||||
});
|
||||
|
||||
zip(http.get(
|
||||
|
|
|
@ -21,7 +21,8 @@ class FancyService {
|
|||
value: string = 'real value';
|
||||
getAsyncValue() { return Promise.resolve('async value'); }
|
||||
getTimeoutValue() {
|
||||
return new Promise((resolve, reject) => { setTimeout(() => {resolve('timeout value')}, 10); })
|
||||
return new Promise(
|
||||
(resolve, reject) => { setTimeout(() => { resolve('timeout value'); }, 10); });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,8 +89,8 @@ export function main() {
|
|||
var deferred = PromiseWrapper.completer();
|
||||
originalJasmineIt = jasmine.getEnv().it;
|
||||
jasmine.getEnv().it = (description: string, fn: any /** TODO #9100 */) => {
|
||||
var done = () => { deferred.resolve() };
|
||||
(<any>done).fail = (err: any /** TODO #9100 */) => { deferred.reject(err) };
|
||||
var done = () => { deferred.resolve(); };
|
||||
(<any>done).fail = (err: any /** TODO #9100 */) => { deferred.reject(err); };
|
||||
fn(done);
|
||||
return null;
|
||||
};
|
||||
|
|
|
@ -7,10 +7,9 @@
|
|||
*/
|
||||
|
||||
import {UrlResolver, XHR} from '@angular/compiler';
|
||||
import {Component, provide} from '@angular/core';
|
||||
import {Component} from '@angular/core';
|
||||
import {TestComponentBuilder, configureCompiler, fakeAsync, flushMicrotasks, tick} from '@angular/core/testing';
|
||||
import {beforeEach, beforeEachProviders, ddescribe, describe, iit, inject, it, xit} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter, beforeEach, beforeEachProviders, ddescribe, describe, iit, inject, it, xit} from '@angular/core/testing/testing_internal';
|
||||
import {expect} from '@angular/platform-browser/testing/matchers';
|
||||
|
||||
import {BaseException} from '../../src/facade/exceptions';
|
||||
|
|
|
@ -91,6 +91,7 @@ export function main() {
|
|||
}
|
||||
|
||||
class FakeEventManagerPlugin extends EventManagerPlugin {
|
||||
/** @internal */
|
||||
_eventHandler = new Map<string, Function>();
|
||||
constructor(public _supports: string[]) { super(); }
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {AsyncTestCompleter, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal';
|
||||
import {beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal';
|
||||
import {el} from '@angular/platform-browser/testing/browser_util';
|
||||
|
||||
import {AnimationKeyframe, AnimationStyles} from '../../core_private';
|
||||
|
@ -21,6 +21,7 @@ class ExtendedWebAnimationsDriver extends WebAnimationsDriver {
|
|||
|
||||
constructor() { super(); }
|
||||
|
||||
/** @internal */
|
||||
_triggerWebAnimation(elm: any, keyframes: any[], options: any): DomAnimatePlayer {
|
||||
this.log.push({'elm': elm, 'keyframes': keyframes, 'options': options});
|
||||
return new MockDomAnimatePlayer();
|
||||
|
|
|
@ -22,6 +22,7 @@ class ExtendedWebAnimationsPlayer extends WebAnimationsPlayer {
|
|||
super(element, keyframes, options);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
_triggerWebAnimation(elm: any, keyframes: any[], options: any): DomAnimatePlayer {
|
||||
return this.domPlayer;
|
||||
}
|
||||
|
|
|
@ -70,7 +70,8 @@ class FancyService {
|
|||
value: string = 'real value';
|
||||
getAsyncValue() { return Promise.resolve('async value'); }
|
||||
getTimeoutValue() {
|
||||
return new Promise((resolve, reject) => { setTimeout(() => {resolve('timeout value')}, 10); })
|
||||
return new Promise(
|
||||
(resolve, reject) => { setTimeout(() => { resolve('timeout value'); }, 10); });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -351,8 +352,8 @@ export function main() {
|
|||
var deferred = PromiseWrapper.completer();
|
||||
originalJasmineIt = jasmine.getEnv().it;
|
||||
jasmine.getEnv().it = (description: string, fn: any /** TODO #9100 */) => {
|
||||
var done = () => { deferred.resolve() };
|
||||
(<any>done).fail = (err: any /** TODO #9100 */) => { deferred.reject(err) };
|
||||
var done = () => { deferred.resolve(); };
|
||||
(<any>done).fail = (err: any /** TODO #9100 */) => { deferred.reject(err); };
|
||||
fn(done);
|
||||
return null;
|
||||
};
|
||||
|
@ -365,8 +366,8 @@ export function main() {
|
|||
var deferred = PromiseWrapper.completer();
|
||||
originalJasmineBeforeEach = jasmine.getEnv().beforeEach;
|
||||
jasmine.getEnv().beforeEach = (fn: any) => {
|
||||
var done = () => { deferred.resolve() };
|
||||
(<any>done).fail = (err: any /** TODO #9100 */) => { deferred.reject(err) };
|
||||
var done = () => { deferred.resolve(); };
|
||||
(<any>done).fail = (err: any /** TODO #9100 */) => { deferred.reject(err); };
|
||||
fn(done);
|
||||
return null;
|
||||
};
|
||||
|
|
|
@ -6,10 +6,9 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {NgZone, provide} from '@angular/core';
|
||||
import {NgZone} from '@angular/core';
|
||||
import {withProviders} from '@angular/core/testing/test_bed';
|
||||
import {MockNgZone, beforeEach, beforeEachProviders, describe, expect, inject, it} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter, MockNgZone, beforeEach, beforeEachProviders, describe, expect, inject, it} from '@angular/core/testing/testing_internal';
|
||||
import {MessageBus} from '@angular/platform-browser/src/web_workers/shared/message_bus';
|
||||
|
||||
import {ObservableWrapper, TimerWrapper} from '../../../src/facade/async';
|
||||
|
|
|
@ -7,13 +7,12 @@
|
|||
*/
|
||||
|
||||
import {NgZone} from '@angular/core/src/zone/ng_zone';
|
||||
import {UiArguments} from '@angular/platform-browser/src/web_workers/shared/client_message_broker';
|
||||
import {ClientMessageBroker, ClientMessageBrokerFactory_} from '@angular/platform-browser/src/web_workers/shared/client_message_broker';
|
||||
import {ClientMessageBroker, ClientMessageBrokerFactory_, UiArguments} from '@angular/platform-browser/src/web_workers/shared/client_message_broker';
|
||||
import {MessageBus, MessageBusSink, MessageBusSource} from '@angular/platform-browser/src/web_workers/shared/message_bus';
|
||||
|
||||
import {PromiseWrapper} from '../../../src/facade/async';
|
||||
import {ListWrapper, StringMapWrapper} from '../../../src/facade/collection';
|
||||
import {BaseException, WrappedException} from '../../../src/facade/exceptions';
|
||||
import {BaseException} from '../../../src/facade/exceptions';
|
||||
import {Type, isPresent} from '../../../src/facade/lang';
|
||||
import {SpyMessageBroker} from '../worker/spies';
|
||||
|
||||
|
@ -52,11 +51,11 @@ export function expectBrokerCall(
|
|||
expect(args.method).toEqual(methodName);
|
||||
if (isPresent(vals)) {
|
||||
expect(args.args.length).toEqual(vals.length);
|
||||
ListWrapper.forEachWithIndex(vals, (v, i) => {expect(v).toEqual(args.args[i].value)});
|
||||
ListWrapper.forEachWithIndex(vals, (v, i) => { expect(v).toEqual(args.args[i].value); });
|
||||
}
|
||||
var promise: any /** TODO #9100 */ = null;
|
||||
if (isPresent(handler)) {
|
||||
let givenValues = args.args.map((arg) => {arg.value});
|
||||
let givenValues = args.args.map((arg) => arg.value);
|
||||
if (givenValues.length > 0) {
|
||||
promise = handler(givenValues);
|
||||
} else {
|
||||
|
|
|
@ -6,8 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {beforeEach, beforeEachProviders, describe, expect, inject, it} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter, beforeEach, beforeEachProviders, describe, expect, inject, it} from '@angular/core/testing/testing_internal';
|
||||
import {UiArguments} from '@angular/platform-browser/src/web_workers/shared/client_message_broker';
|
||||
import {MessageBus} from '@angular/platform-browser/src/web_workers/shared/message_bus';
|
||||
import {LocationType} from '@angular/platform-browser/src/web_workers/shared/serialized_types';
|
||||
|
|
|
@ -6,11 +6,10 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {inject, ddescribe, describe, it, iit, expect, beforeEach, beforeEachProviders,} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter, inject, ddescribe, describe, it, iit, expect, beforeEach, beforeEachProviders,} from '@angular/core/testing/testing_internal';
|
||||
import {TestBed, TestComponentBuilder, configureModule} from '@angular/core/testing';
|
||||
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
||||
import {provide, Injector, ViewMetadata, Component, Injectable, ComponentRef, ReflectiveInjector, getPlatform} from '@angular/core';
|
||||
import {Injector, ViewMetadata, Component, Injectable, ComponentRef, ReflectiveInjector, getPlatform} from '@angular/core';
|
||||
import {NgIf} from '@angular/common';
|
||||
import {WebWorkerRootRenderer} from '@angular/platform-browser/src/web_workers/worker/renderer';
|
||||
import {ClientMessageBrokerFactory, ClientMessageBrokerFactory_} from '@angular/platform-browser/src/web_workers/shared/client_message_broker';
|
||||
|
@ -22,10 +21,9 @@ import {RenderStore} from '@angular/platform-browser/src/web_workers/shared/rend
|
|||
import {MessageBasedRenderer} from '@angular/platform-browser/src/web_workers/ui/renderer';
|
||||
import {createPairedMessageBuses, PairedMessageBuses} from '../shared/web_worker_test_util';
|
||||
import {ServiceMessageBrokerFactory_} from '@angular/platform-browser/src/web_workers/shared/service_message_broker';
|
||||
import {CompilerConfig} from '@angular/compiler';
|
||||
import {dispatchEvent} from '../../../../platform-browser/testing/browser_util';
|
||||
import {BrowserTestModule} from '@angular/platform-browser/testing';
|
||||
import {browserDynamicTestPlatform} from '@angular/platform-browser-dynamic/testing'
|
||||
import {browserDynamicTestPlatform} from '@angular/platform-browser-dynamic/testing';
|
||||
|
||||
export function main() {
|
||||
function createWebWorkerBrokerFactory(
|
||||
|
@ -58,205 +56,204 @@ export function main() {
|
|||
return new DebugDomRootRenderer(workerRootRenderer);
|
||||
}
|
||||
|
||||
describe(
|
||||
'Web Worker Renderer',
|
||||
() => {
|
||||
var uiInjector: Injector;
|
||||
var uiRenderStore: RenderStore;
|
||||
var workerRenderStore: RenderStore;
|
||||
describe('Web Worker Renderer', () => {
|
||||
var uiInjector: Injector;
|
||||
var uiRenderStore: RenderStore;
|
||||
var workerRenderStore: RenderStore;
|
||||
|
||||
beforeEach(() => {
|
||||
uiRenderStore = new RenderStore();
|
||||
var testUiInjector = new TestBed();
|
||||
testUiInjector.platform = browserDynamicTestPlatform();
|
||||
testUiInjector.appModule = BrowserTestModule;
|
||||
testUiInjector.configureModule({
|
||||
providers: [
|
||||
Serializer, {provide: RenderStore, useValue: uiRenderStore},
|
||||
{provide: DomRootRenderer, useClass: DomRootRenderer_},
|
||||
{provide: RootRenderer, useExisting: DomRootRenderer}
|
||||
]
|
||||
});
|
||||
testUiInjector.initTestAppModule();
|
||||
var uiSerializer = testUiInjector.get(Serializer);
|
||||
var domRootRenderer = testUiInjector.get(DomRootRenderer);
|
||||
workerRenderStore = new RenderStore();
|
||||
|
||||
configureModule({
|
||||
providers: [
|
||||
Serializer, {provide: RenderStore, useValue: workerRenderStore}, {
|
||||
provide: RootRenderer,
|
||||
useFactory: (workerSerializer: Serializer) => {
|
||||
return createWorkerRenderer(
|
||||
workerSerializer, uiSerializer, domRootRenderer, uiRenderStore,
|
||||
workerRenderStore);
|
||||
},
|
||||
deps: [Serializer]
|
||||
}
|
||||
]
|
||||
});
|
||||
});
|
||||
|
||||
function getRenderElement(workerEl: any) {
|
||||
var id = workerRenderStore.serialize(workerEl);
|
||||
return uiRenderStore.deserialize(id);
|
||||
}
|
||||
|
||||
function getRenderer(componentRef: ComponentRef<any>) {
|
||||
return (<any>componentRef.hostView).internalView.renderer;
|
||||
}
|
||||
|
||||
it('should update text nodes',
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
tcb.overrideView(MyComp2, new ViewMetadata({template: '<div>{{ctxProp}}</div>'}))
|
||||
.createAsync(MyComp2)
|
||||
.then((fixture) => {
|
||||
var renderEl = getRenderElement(fixture.debugElement.nativeElement);
|
||||
expect(renderEl).toHaveText('');
|
||||
|
||||
fixture.debugElement.componentInstance.ctxProp = 'Hello World!';
|
||||
fixture.detectChanges();
|
||||
expect(renderEl).toHaveText('Hello World!');
|
||||
async.done();
|
||||
|
||||
});
|
||||
}));
|
||||
|
||||
it('should update any element property/attributes/class/style(s) independent of the compilation on the root element and other elements',
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
tcb.overrideView(
|
||||
MyComp2, new ViewMetadata(
|
||||
{template: '<input [title]="y" style="position:absolute">'}))
|
||||
.createAsync(MyComp2)
|
||||
.then((fixture) => {
|
||||
var checkSetters =
|
||||
(componentRef: any /** TODO #9100 */,
|
||||
workerEl: any /** TODO #9100 */) => {
|
||||
var renderer = getRenderer(componentRef);
|
||||
var el = getRenderElement(workerEl);
|
||||
renderer.setElementProperty(workerEl, 'tabIndex', 1);
|
||||
expect((<HTMLInputElement>el).tabIndex).toEqual(1);
|
||||
|
||||
renderer.setElementClass(workerEl, 'a', true);
|
||||
expect(getDOM().hasClass(el, 'a')).toBe(true);
|
||||
renderer.setElementClass(workerEl, 'a', false);
|
||||
expect(getDOM().hasClass(el, 'a')).toBe(false);
|
||||
|
||||
renderer.setElementStyle(workerEl, 'width', '10px');
|
||||
expect(getDOM().getStyle(el, 'width')).toEqual('10px');
|
||||
renderer.setElementStyle(workerEl, 'width', null);
|
||||
expect(getDOM().getStyle(el, 'width')).toEqual('');
|
||||
|
||||
renderer.setElementAttribute(workerEl, 'someattr', 'someValue');
|
||||
expect(getDOM().getAttribute(el, 'someattr')).toEqual('someValue');
|
||||
};
|
||||
|
||||
// root element
|
||||
checkSetters(fixture.componentRef, fixture.debugElement.nativeElement);
|
||||
// nested elements
|
||||
checkSetters(
|
||||
fixture.componentRef, fixture.debugElement.children[0].nativeElement);
|
||||
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should update any template comment property/attributes',
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
var tpl = '<template [ngIf]="ctxBoolProp"></template>';
|
||||
tcb.overrideView(MyComp2, new ViewMetadata({template: tpl, directives: [NgIf]}))
|
||||
|
||||
.createAsync(MyComp2)
|
||||
.then((fixture) => {
|
||||
(<MyComp2>fixture.debugElement.componentInstance).ctxBoolProp = true;
|
||||
fixture.detectChanges();
|
||||
var el = getRenderElement(fixture.debugElement.nativeElement);
|
||||
expect(getDOM().getInnerHTML(el)).toContain('"ng-reflect-ng-if": "true"');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should add and remove fragments',
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
tcb.overrideView(MyComp2, new ViewMetadata({
|
||||
template: '<template [ngIf]="ctxBoolProp">hello</template>',
|
||||
directives: [NgIf]
|
||||
}))
|
||||
.createAsync(MyComp2)
|
||||
.then((fixture) => {
|
||||
|
||||
var rootEl = getRenderElement(fixture.debugElement.nativeElement);
|
||||
expect(rootEl).toHaveText('');
|
||||
|
||||
fixture.debugElement.componentInstance.ctxBoolProp = true;
|
||||
fixture.detectChanges();
|
||||
expect(rootEl).toHaveText('hello');
|
||||
|
||||
fixture.debugElement.componentInstance.ctxBoolProp = false;
|
||||
fixture.detectChanges();
|
||||
expect(rootEl).toHaveText('');
|
||||
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
if (getDOM().supportsDOMEvents()) {
|
||||
it('should call actions on the element',
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
tcb.overrideView(MyComp2, new ViewMetadata({template: '<input [title]="y">'}))
|
||||
.createAsync(MyComp2)
|
||||
.then((fixture) => {
|
||||
var el = fixture.debugElement.children[0];
|
||||
getRenderer(fixture.componentRef)
|
||||
.invokeElementMethod(el.nativeElement, 'setAttribute', ['a', 'b']);
|
||||
|
||||
expect(getDOM().getAttribute(getRenderElement(el.nativeElement), 'a'))
|
||||
.toEqual('b');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should listen to events',
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
tcb.overrideView(
|
||||
MyComp2,
|
||||
new ViewMetadata({template: '<input (change)="ctxNumProp = 1">'}))
|
||||
.createAsync(MyComp2)
|
||||
.then((fixture) => {
|
||||
var el = fixture.debugElement.children[0];
|
||||
dispatchEvent(getRenderElement(el.nativeElement), 'change');
|
||||
expect(fixture.componentInstance.ctxNumProp).toBe(1);
|
||||
|
||||
fixture.destroy();
|
||||
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
}
|
||||
beforeEach(() => {
|
||||
uiRenderStore = new RenderStore();
|
||||
var testUiInjector = new TestBed();
|
||||
testUiInjector.platform = browserDynamicTestPlatform();
|
||||
testUiInjector.appModule = BrowserTestModule;
|
||||
testUiInjector.configureModule({
|
||||
providers: [
|
||||
Serializer, {provide: RenderStore, useValue: uiRenderStore},
|
||||
{provide: DomRootRenderer, useClass: DomRootRenderer_},
|
||||
{provide: RootRenderer, useExisting: DomRootRenderer}
|
||||
]
|
||||
});
|
||||
testUiInjector.initTestAppModule();
|
||||
var uiSerializer = testUiInjector.get(Serializer);
|
||||
var domRootRenderer = testUiInjector.get(DomRootRenderer);
|
||||
workerRenderStore = new RenderStore();
|
||||
|
||||
configureModule({
|
||||
providers: [
|
||||
Serializer, {provide: RenderStore, useValue: workerRenderStore}, {
|
||||
provide: RootRenderer,
|
||||
useFactory: (workerSerializer: Serializer) => {
|
||||
return createWorkerRenderer(
|
||||
workerSerializer, uiSerializer, domRootRenderer, uiRenderStore,
|
||||
workerRenderStore);
|
||||
},
|
||||
deps: [Serializer]
|
||||
}
|
||||
]
|
||||
});
|
||||
});
|
||||
|
||||
function getRenderElement(workerEl: any) {
|
||||
var id = workerRenderStore.serialize(workerEl);
|
||||
return uiRenderStore.deserialize(id);
|
||||
}
|
||||
|
||||
function getRenderer(componentRef: ComponentRef<any>) {
|
||||
return (<any>componentRef.hostView).internalView.renderer;
|
||||
}
|
||||
|
||||
it('should update text nodes',
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
tcb.overrideView(MyComp2, new ViewMetadata({template: '<div>{{ctxProp}}</div>'}))
|
||||
.createAsync(MyComp2)
|
||||
.then((fixture) => {
|
||||
var renderEl = getRenderElement(fixture.debugElement.nativeElement);
|
||||
expect(renderEl).toHaveText('');
|
||||
|
||||
fixture.debugElement.componentInstance.ctxProp = 'Hello World!';
|
||||
fixture.detectChanges();
|
||||
expect(renderEl).toHaveText('Hello World!');
|
||||
async.done();
|
||||
|
||||
});
|
||||
}));
|
||||
|
||||
it('should update any element property/attributes/class/style(s) independent of the compilation on the root element and other elements',
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
tcb.overrideView(
|
||||
MyComp2,
|
||||
new ViewMetadata({template: '<input [title]="y" style="position:absolute">'}))
|
||||
.createAsync(MyComp2)
|
||||
.then((fixture) => {
|
||||
var checkSetters =
|
||||
(componentRef: any /** TODO #9100 */, workerEl: any /** TODO #9100 */) => {
|
||||
var renderer = getRenderer(componentRef);
|
||||
var el = getRenderElement(workerEl);
|
||||
renderer.setElementProperty(workerEl, 'tabIndex', 1);
|
||||
expect((<HTMLInputElement>el).tabIndex).toEqual(1);
|
||||
|
||||
renderer.setElementClass(workerEl, 'a', true);
|
||||
expect(getDOM().hasClass(el, 'a')).toBe(true);
|
||||
renderer.setElementClass(workerEl, 'a', false);
|
||||
expect(getDOM().hasClass(el, 'a')).toBe(false);
|
||||
|
||||
renderer.setElementStyle(workerEl, 'width', '10px');
|
||||
expect(getDOM().getStyle(el, 'width')).toEqual('10px');
|
||||
renderer.setElementStyle(workerEl, 'width', null);
|
||||
expect(getDOM().getStyle(el, 'width')).toEqual('');
|
||||
|
||||
renderer.setElementAttribute(workerEl, 'someattr', 'someValue');
|
||||
expect(getDOM().getAttribute(el, 'someattr')).toEqual('someValue');
|
||||
};
|
||||
|
||||
// root element
|
||||
checkSetters(fixture.componentRef, fixture.debugElement.nativeElement);
|
||||
// nested elements
|
||||
checkSetters(
|
||||
fixture.componentRef, fixture.debugElement.children[0].nativeElement);
|
||||
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should update any template comment property/attributes',
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
var tpl = '<template [ngIf]="ctxBoolProp"></template>';
|
||||
tcb.overrideView(MyComp2, new ViewMetadata({template: tpl, directives: [NgIf]}))
|
||||
|
||||
.createAsync(MyComp2)
|
||||
.then((fixture) => {
|
||||
(<MyComp2>fixture.debugElement.componentInstance).ctxBoolProp = true;
|
||||
fixture.detectChanges();
|
||||
var el = getRenderElement(fixture.debugElement.nativeElement);
|
||||
expect(getDOM().getInnerHTML(el)).toContain('"ng-reflect-ng-if": "true"');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should add and remove fragments',
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
tcb.overrideView(MyComp2, new ViewMetadata({
|
||||
template: '<template [ngIf]="ctxBoolProp">hello</template>',
|
||||
directives: [NgIf]
|
||||
}))
|
||||
.createAsync(MyComp2)
|
||||
.then((fixture) => {
|
||||
|
||||
var rootEl = getRenderElement(fixture.debugElement.nativeElement);
|
||||
expect(rootEl).toHaveText('');
|
||||
|
||||
fixture.debugElement.componentInstance.ctxBoolProp = true;
|
||||
fixture.detectChanges();
|
||||
expect(rootEl).toHaveText('hello');
|
||||
|
||||
fixture.debugElement.componentInstance.ctxBoolProp = false;
|
||||
fixture.detectChanges();
|
||||
expect(rootEl).toHaveText('');
|
||||
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
if (getDOM().supportsDOMEvents()) {
|
||||
it('should call actions on the element',
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
tcb.overrideView(MyComp2, new ViewMetadata({template: '<input [title]="y">'}))
|
||||
.createAsync(MyComp2)
|
||||
.then((fixture) => {
|
||||
var el = fixture.debugElement.children[0];
|
||||
getRenderer(fixture.componentRef)
|
||||
.invokeElementMethod(el.nativeElement, 'setAttribute', ['a', 'b']);
|
||||
|
||||
expect(getDOM().getAttribute(getRenderElement(el.nativeElement), 'a'))
|
||||
.toEqual('b');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should listen to events',
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
tcb.overrideView(
|
||||
MyComp2, new ViewMetadata({template: '<input (change)="ctxNumProp = 1">'}))
|
||||
.createAsync(MyComp2)
|
||||
.then((fixture) => {
|
||||
var el = fixture.debugElement.children[0];
|
||||
dispatchEvent(getRenderElement(el.nativeElement), 'change');
|
||||
expect(fixture.componentInstance.ctxNumProp).toBe(1);
|
||||
|
||||
fixture.destroy();
|
||||
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Component(
|
||||
{selector: 'my-comp',
|
||||
directives: []}) @Injectable() class MyComp2 {
|
||||
ctxProp: string; ctxNumProp: any /** TODO #9100 */; ctxBoolProp: boolean; constructor() {
|
||||
@Component({selector: 'my-comp', directives: []})
|
||||
@Injectable()
|
||||
class MyComp2 {
|
||||
ctxProp: string;
|
||||
ctxNumProp: any /** TODO #9100 */;
|
||||
ctxBoolProp: boolean;
|
||||
constructor() {
|
||||
this.ctxProp = 'initial value';
|
||||
this.ctxNumProp = 0;
|
||||
this.ctxBoolProp = false;
|
||||
}
|
||||
|
||||
throwError() { throw 'boom';}
|
||||
throwError() { throw 'boom'; }
|
||||
}
|
||||
|
|
|
@ -6,12 +6,11 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {beforeEach, ddescribe, xdescribe, describe, expect, iit, inject, beforeEachProviders, it, xit,} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter, beforeEach, ddescribe, xdescribe, describe, expect, iit, inject, beforeEachProviders, it, xit,} from '@angular/core/testing/testing_internal';
|
||||
import {TestComponentBuilder} from '@angular/core/testing';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
|
||||
import {SpyRouter, SpyLocation} from '../spies';
|
||||
import {provide, Component} from '@angular/core';
|
||||
import {Component} from '@angular/core';
|
||||
import {Location} from '@angular/common';
|
||||
import {Router, RouteRegistry, RouterLink, RouterOutlet, Route, RouteParams, ComponentInstruction} from '@angular/router-deprecated';
|
||||
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
||||
|
|
|
@ -13,8 +13,7 @@ import {ApplicationRef} from '@angular/core/src/application_ref';
|
|||
import {Console} from '@angular/core/src/console';
|
||||
import {Component} from '@angular/core/src/metadata';
|
||||
import {TestComponentBuilder} from '@angular/core/testing';
|
||||
import {MockApplicationRef, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter, MockApplicationRef, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal';
|
||||
import {bootstrap} from '@angular/platform-browser-dynamic';
|
||||
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
||||
import {DOCUMENT} from '@angular/platform-browser/src/dom/dom_tokens';
|
||||
|
|
|
@ -6,9 +6,8 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {beforeEach, beforeEachProviders, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter, beforeEach, beforeEachProviders, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal';
|
||||
import {ComponentFixture, TestComponentBuilder} from '@angular/core/testing';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
|
||||
import {Location} from '@angular/common';
|
||||
|
||||
|
@ -40,7 +39,7 @@ function asyncRoutesWithoutChildrenWithRouteData() {
|
|||
it('should inject route data into the component',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile(tcb)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new AsyncRoute(
|
||||
{path: '/route-data', loader: asyncRouteDataCmp, data: {isAdmin: true}})]))
|
||||
.then((_) => rtr.navigateByUrl('/route-data'))
|
||||
|
@ -54,7 +53,7 @@ function asyncRoutesWithoutChildrenWithRouteData() {
|
|||
it('should inject empty object if the route has no data property',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile(tcb)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new AsyncRoute(
|
||||
{path: '/route-data-default', loader: asyncRouteDataCmp})]))
|
||||
.then((_) => rtr.navigateByUrl('/route-data-default'))
|
||||
|
@ -82,7 +81,7 @@ function asyncRoutesWithoutChildrenWithoutParams() {
|
|||
|
||||
it('should navigate by URL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile(tcb)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new AsyncRoute(
|
||||
{path: '/test', loader: helloCmpLoader, name: 'Hello'})]))
|
||||
.then((_) => rtr.navigateByUrl('/test'))
|
||||
|
@ -95,7 +94,7 @@ function asyncRoutesWithoutChildrenWithoutParams() {
|
|||
|
||||
it('should navigate by link DSL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile(tcb)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new AsyncRoute(
|
||||
{path: '/test', loader: helloCmpLoader, name: 'Hello'})]))
|
||||
.then((_) => rtr.navigate(['/Hello']))
|
||||
|
@ -108,7 +107,7 @@ function asyncRoutesWithoutChildrenWithoutParams() {
|
|||
|
||||
it('should generate a link URL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile(tcb, `<a [routerLink]="['Hello']">go to hello</a> | <router-outlet></router-outlet>`)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new AsyncRoute(
|
||||
{path: '/test', loader: helloCmpLoader, name: 'Hello'})]))
|
||||
.then((_) => {
|
||||
|
@ -124,7 +123,7 @@ function asyncRoutesWithoutChildrenWithoutParams() {
|
|||
(async: AsyncTestCompleter, location: any /** TODO #9100 */) => {
|
||||
compile(
|
||||
tcb, `<a [routerLink]="['Hello']">go to hello</a> | <router-outlet></router-outlet>`)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new AsyncRoute(
|
||||
{path: '/test', loader: helloCmpLoader, name: 'Hello'})]))
|
||||
.then((_) => {
|
||||
|
@ -160,7 +159,7 @@ function asyncRoutesWithoutChildrenWithParams() {
|
|||
|
||||
it('should navigate by URL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile(tcb)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new AsyncRoute(
|
||||
{path: '/user/:name', loader: userCmpLoader, name: 'User'})]))
|
||||
.then((_) => rtr.navigateByUrl('/user/igor'))
|
||||
|
@ -173,7 +172,7 @@ function asyncRoutesWithoutChildrenWithParams() {
|
|||
|
||||
it('should navigate by link DSL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile(tcb)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then(
|
||||
(_) =>
|
||||
rtr.config([new Route({path: '/user/:name', component: UserCmp, name: 'User'})]))
|
||||
|
@ -189,7 +188,7 @@ function asyncRoutesWithoutChildrenWithParams() {
|
|||
compile(
|
||||
tcb,
|
||||
`<a [routerLink]="['User', {name: 'naomi'}]">greet naomi</a> | <router-outlet></router-outlet>`)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new AsyncRoute(
|
||||
{path: '/user/:name', loader: userCmpLoader, name: 'User'})]))
|
||||
.then((_) => {
|
||||
|
@ -206,7 +205,7 @@ function asyncRoutesWithoutChildrenWithParams() {
|
|||
compile(
|
||||
tcb,
|
||||
`<a [routerLink]="['User', {name: 'naomi'}]">greet naomi</a> | <router-outlet></router-outlet>`)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new AsyncRoute(
|
||||
{path: '/user/:name', loader: userCmpLoader, name: 'User'})]))
|
||||
.then((_) => {
|
||||
|
@ -228,7 +227,7 @@ function asyncRoutesWithoutChildrenWithParams() {
|
|||
it('should navigate between components with different parameters',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile(tcb)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new AsyncRoute(
|
||||
{path: '/user/:name', loader: userCmpLoader, name: 'User'})]))
|
||||
.then((_) => rtr.navigateByUrl('/user/brian'))
|
||||
|
@ -262,7 +261,7 @@ function asyncRoutesWithSyncChildrenWithoutDefaultRoutes() {
|
|||
|
||||
it('should navigate by URL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile(tcb, `outer [ <router-outlet></router-outlet> ]`)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new AsyncRoute(
|
||||
{path: '/a/...', loader: parentCmpLoader, name: 'Parent'})]))
|
||||
.then((_) => rtr.navigateByUrl('/a/b'))
|
||||
|
@ -275,7 +274,7 @@ function asyncRoutesWithSyncChildrenWithoutDefaultRoutes() {
|
|||
|
||||
it('should navigate by link DSL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile(tcb, `outer [ <router-outlet></router-outlet> ]`)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new AsyncRoute(
|
||||
{path: '/a/...', loader: parentCmpLoader, name: 'Parent'})]))
|
||||
.then((_) => rtr.navigate(['/Parent', 'Child']))
|
||||
|
@ -290,7 +289,7 @@ function asyncRoutesWithSyncChildrenWithoutDefaultRoutes() {
|
|||
compile(
|
||||
tcb,
|
||||
`<a [routerLink]="['Parent']">nav to child</a> | outer [ <router-outlet></router-outlet> ]`)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new AsyncRoute(
|
||||
{path: '/a/...', loader: parentCmpLoader, name: 'Parent'})]))
|
||||
.then((_) => {
|
||||
|
@ -307,7 +306,7 @@ function asyncRoutesWithSyncChildrenWithoutDefaultRoutes() {
|
|||
compile(
|
||||
tcb,
|
||||
`<a [routerLink]="['Parent', 'Child']">nav to child</a> | outer [ <router-outlet></router-outlet> ]`)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new AsyncRoute(
|
||||
{path: '/a/...', loader: parentCmpLoader, name: 'Parent'})]))
|
||||
.then((_) => {
|
||||
|
@ -344,7 +343,7 @@ function asyncRoutesWithSyncChildrenWithDefaultRoutes() {
|
|||
|
||||
it('should navigate by URL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile(tcb, `outer [ <router-outlet></router-outlet> ]`)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new AsyncRoute(
|
||||
{path: '/a/...', loader: parentWithDefaultCmpLoader, name: 'Parent'})]))
|
||||
.then((_) => rtr.navigateByUrl('/a'))
|
||||
|
@ -357,7 +356,7 @@ function asyncRoutesWithSyncChildrenWithDefaultRoutes() {
|
|||
|
||||
it('should navigate by link DSL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile(tcb, `outer [ <router-outlet></router-outlet> ]`)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new AsyncRoute(
|
||||
{path: '/a/...', loader: parentWithDefaultCmpLoader, name: 'Parent'})]))
|
||||
.then((_) => rtr.navigate(['/Parent']))
|
||||
|
@ -372,7 +371,7 @@ function asyncRoutesWithSyncChildrenWithDefaultRoutes() {
|
|||
compile(
|
||||
tcb,
|
||||
`<a [routerLink]="['/Parent']">link to inner</a> | outer [ <router-outlet></router-outlet> ]`)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new AsyncRoute(
|
||||
{path: '/a/...', loader: parentWithDefaultCmpLoader, name: 'Parent'})]))
|
||||
.then((_) => {
|
||||
|
@ -389,7 +388,7 @@ function asyncRoutesWithSyncChildrenWithDefaultRoutes() {
|
|||
compile(
|
||||
tcb,
|
||||
`<a [routerLink]="['/Parent']">link to inner</a> | outer [ <router-outlet></router-outlet> ]`)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new AsyncRoute(
|
||||
{path: '/a/...', loader: parentWithDefaultCmpLoader, name: 'Parent'})]))
|
||||
.then((_) => {
|
||||
|
@ -427,7 +426,7 @@ function asyncRoutesWithAsyncChildrenWithoutParamsWithoutDefaultRoutes() {
|
|||
|
||||
it('should navigate by URL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile(tcb, `outer [ <router-outlet></router-outlet> ]`)
|
||||
.then((rtc) => {rootTC = rtc})
|
||||
.then((rtc) => { rootTC = rtc; })
|
||||
.then((_) => rtr.config([new AsyncRoute(
|
||||
{path: '/a/...', loader: asyncParentCmpLoader, name: 'Parent'})]))
|
||||
.then((_) => rtr.navigateByUrl('/a/b'))
|
||||
|
@ -440,7 +439,7 @@ function asyncRoutesWithAsyncChildrenWithoutParamsWithoutDefaultRoutes() {
|
|||
|
||||
it('should navigate by link DSL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile(tcb, `outer [ <router-outlet></router-outlet> ]`)
|
||||
.then((rtc) => {rootTC = rtc})
|
||||
.then((rtc) => { rootTC = rtc; })
|
||||
.then((_) => rtr.config([new AsyncRoute(
|
||||
{path: '/a/...', loader: asyncParentCmpLoader, name: 'Parent'})]))
|
||||
.then((_) => rtr.navigate(['/Parent', 'Child']))
|
||||
|
@ -455,7 +454,7 @@ function asyncRoutesWithAsyncChildrenWithoutParamsWithoutDefaultRoutes() {
|
|||
compile(
|
||||
tcb,
|
||||
`<a [routerLink]="['Parent', 'Child']">nav to child</a> | outer [ <router-outlet></router-outlet> ]`)
|
||||
.then((rtc) => {rootTC = rtc})
|
||||
.then((rtc) => { rootTC = rtc; })
|
||||
.then((_) => rtr.config([new AsyncRoute(
|
||||
{path: '/a/...', loader: asyncParentCmpLoader, name: 'Parent'})]))
|
||||
.then((_) => {
|
||||
|
@ -472,7 +471,7 @@ function asyncRoutesWithAsyncChildrenWithoutParamsWithoutDefaultRoutes() {
|
|||
compile(
|
||||
tcb,
|
||||
`<a [routerLink]="['Parent', 'Child']">nav to child</a> | outer [ <router-outlet></router-outlet> ]`)
|
||||
.then((rtc) => {rootTC = rtc})
|
||||
.then((rtc) => { rootTC = rtc; })
|
||||
.then((_) => rtr.config([new AsyncRoute(
|
||||
{path: '/a/...', loader: asyncParentCmpLoader, name: 'Parent'})]))
|
||||
.then((_) => {
|
||||
|
@ -509,7 +508,7 @@ function asyncRoutesWithAsyncChildrenWithoutParamsWithDefaultRoutes() {
|
|||
|
||||
it('should navigate by URL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile(tcb, `outer [ <router-outlet></router-outlet> ]`)
|
||||
.then((rtc) => {rootTC = rtc})
|
||||
.then((rtc) => { rootTC = rtc; })
|
||||
.then((_) => rtr.config([new AsyncRoute(
|
||||
{path: '/a/...', loader: asyncDefaultParentCmpLoader, name: 'Parent'})]))
|
||||
.then((_) => rtr.navigateByUrl('/a'))
|
||||
|
@ -522,7 +521,7 @@ function asyncRoutesWithAsyncChildrenWithoutParamsWithDefaultRoutes() {
|
|||
|
||||
it('should navigate by link DSL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile(tcb, `outer [ <router-outlet></router-outlet> ]`)
|
||||
.then((rtc) => {rootTC = rtc})
|
||||
.then((rtc) => { rootTC = rtc; })
|
||||
.then((_) => rtr.config([new AsyncRoute(
|
||||
{path: '/a/...', loader: asyncDefaultParentCmpLoader, name: 'Parent'})]))
|
||||
.then((_) => rtr.navigate(['/Parent']))
|
||||
|
@ -537,7 +536,7 @@ function asyncRoutesWithAsyncChildrenWithoutParamsWithDefaultRoutes() {
|
|||
compile(
|
||||
tcb,
|
||||
`<a [routerLink]="['Parent']">nav to child</a> | outer [ <router-outlet></router-outlet> ]`)
|
||||
.then((rtc) => {rootTC = rtc})
|
||||
.then((rtc) => { rootTC = rtc; })
|
||||
.then((_) => rtr.config([new AsyncRoute(
|
||||
{path: '/a/...', loader: asyncDefaultParentCmpLoader, name: 'Parent'})]))
|
||||
.then((_) => {
|
||||
|
@ -554,7 +553,7 @@ function asyncRoutesWithAsyncChildrenWithoutParamsWithDefaultRoutes() {
|
|||
compile(
|
||||
tcb,
|
||||
`<a [routerLink]="['Parent']">nav to child</a> | outer [ <router-outlet></router-outlet> ]`)
|
||||
.then((rtc) => {rootTC = rtc})
|
||||
.then((rtc) => { rootTC = rtc; })
|
||||
.then((_) => rtr.config([new AsyncRoute(
|
||||
{path: '/a/...', loader: asyncDefaultParentCmpLoader, name: 'Parent'})]))
|
||||
.then((_) => {
|
||||
|
@ -591,7 +590,7 @@ function asyncRoutesWithAsyncChildrenWithParamsWithoutDefaultRoutes() {
|
|||
|
||||
it('should navigate by URL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile(tcb, `[ <router-outlet></router-outlet> ]`)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new AsyncRoute(
|
||||
{path: '/team/:id/...', loader: asyncTeamLoader, name: 'Team'})]))
|
||||
.then((_) => rtr.navigateByUrl('/team/angular/user/matias'))
|
||||
|
@ -605,7 +604,7 @@ function asyncRoutesWithAsyncChildrenWithParamsWithoutDefaultRoutes() {
|
|||
|
||||
it('should navigate by link DSL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile(tcb, `[ <router-outlet></router-outlet> ]`)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new AsyncRoute(
|
||||
{path: '/team/:id/...', loader: asyncTeamLoader, name: 'Team'})]))
|
||||
.then((_) => rtr.navigate(['/Team', {id: 'angular'}, 'User', {name: 'matias'}]))
|
||||
|
@ -621,7 +620,7 @@ function asyncRoutesWithAsyncChildrenWithParamsWithoutDefaultRoutes() {
|
|||
compile(
|
||||
tcb,
|
||||
`<a [routerLink]="['/Team', {id: 'angular'}, 'User', {name: 'matias'}]">nav to matias</a> [ <router-outlet></router-outlet> ]`)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new AsyncRoute(
|
||||
{path: '/team/:id/...', loader: asyncTeamLoader, name: 'Team'})]))
|
||||
.then((_) => {
|
||||
|
@ -638,7 +637,7 @@ function asyncRoutesWithAsyncChildrenWithParamsWithoutDefaultRoutes() {
|
|||
compile(
|
||||
tcb,
|
||||
`<a [routerLink]="['/Team', {id: 'angular'}, 'User', {name: 'matias'}]">nav to matias</a> [ <router-outlet></router-outlet> ]`)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new AsyncRoute(
|
||||
{path: '/team/:id/...', loader: asyncTeamLoader, name: 'Team'})]))
|
||||
.then((_) => {
|
||||
|
|
|
@ -9,8 +9,7 @@
|
|||
import {Location} from '@angular/common';
|
||||
import {Component} from '@angular/core';
|
||||
import {ComponentFixture, TestComponentBuilder} from '@angular/core/testing';
|
||||
import {beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal';
|
||||
import {By} from '@angular/platform-browser/src/dom/debug/by';
|
||||
import {AuxRoute, ROUTER_DIRECTIVES, Route, RouteConfig, Router} from '@angular/router-deprecated';
|
||||
|
||||
|
@ -38,7 +37,7 @@ function auxRoutes() {
|
|||
compile(
|
||||
tcb,
|
||||
`main [<router-outlet></router-outlet>] | aux [<router-outlet name="modal"></router-outlet>]`)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([
|
||||
new Route({path: '/hello', component: HelloCmp, name: 'Hello'}),
|
||||
new AuxRoute({path: '/modal', component: ModalCmp, name: 'Aux'})
|
||||
|
@ -56,7 +55,7 @@ function auxRoutes() {
|
|||
compile(
|
||||
tcb,
|
||||
`main [<router-outlet></router-outlet>] | aux [<router-outlet name="modal"></router-outlet>]`)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([
|
||||
new Route({path: '/hello', component: HelloCmp, name: 'Hello'}),
|
||||
new AuxRoute({path: '/modal', component: ModalCmp, name: 'Modal'})
|
||||
|
@ -73,7 +72,7 @@ function auxRoutes() {
|
|||
compile(
|
||||
tcb,
|
||||
`<a [routerLink]="['/', ['Modal']]">open modal</a> | main [<router-outlet></router-outlet>] | aux [<router-outlet name="modal"></router-outlet>]`)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([
|
||||
new Route({path: '/hello', component: HelloCmp, name: 'Hello'}),
|
||||
new AuxRoute({path: '/modal', component: ModalCmp, name: 'Modal'})
|
||||
|
@ -92,7 +91,7 @@ function auxRoutes() {
|
|||
compile(
|
||||
tcb,
|
||||
`<a [routerLink]="['/', ['Modal']]">open modal</a> | <a [routerLink]="['/Hello']">hello</a> | main [<router-outlet></router-outlet>] | aux [<router-outlet name="modal"></router-outlet>]`)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([
|
||||
new Route({path: '/hello', component: HelloCmp, name: 'Hello'}),
|
||||
new AuxRoute({path: '/modal', component: ModalCmp, name: 'Modal'})
|
||||
|
@ -151,7 +150,7 @@ function auxRoutesWithAPrimaryRoute() {
|
|||
compile(
|
||||
tcb,
|
||||
`main [<router-outlet></router-outlet>] | aux [<router-outlet name="modal"></router-outlet>]`)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([
|
||||
new Route({path: '/hello', component: HelloCmp, name: 'Hello'}),
|
||||
new AuxRoute({path: '/modal', component: ModalCmp, name: 'Aux'})
|
||||
|
@ -169,7 +168,7 @@ function auxRoutesWithAPrimaryRoute() {
|
|||
compile(
|
||||
tcb,
|
||||
`main [<router-outlet></router-outlet>] | aux [<router-outlet name="modal"></router-outlet>]`)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([
|
||||
new Route({path: '/hello', component: HelloCmp, name: 'Hello'}),
|
||||
new AuxRoute({path: '/modal', component: ModalCmp, name: 'Modal'})
|
||||
|
@ -186,7 +185,7 @@ function auxRoutesWithAPrimaryRoute() {
|
|||
compile(
|
||||
tcb,
|
||||
`<a [routerLink]="['/Hello', ['Modal']]">open modal</a> | main [<router-outlet></router-outlet>] | aux [<router-outlet name="modal"></router-outlet>]`)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([
|
||||
new Route({path: '/hello', component: HelloCmp, name: 'Hello'}),
|
||||
new AuxRoute({path: '/modal', component: ModalCmp, name: 'Modal'})
|
||||
|
@ -205,7 +204,7 @@ function auxRoutesWithAPrimaryRoute() {
|
|||
compile(
|
||||
tcb,
|
||||
`<a [routerLink]="['/Hello', ['Modal']]">open modal</a> | main [<router-outlet></router-outlet>] | aux [<router-outlet name="modal"></router-outlet>]`)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([
|
||||
new Route({path: '/hello', component: HelloCmp, name: 'Hello'}),
|
||||
new AuxRoute({path: '/modal', component: ModalCmp, name: 'Modal'})
|
||||
|
|
|
@ -6,8 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {beforeEach, beforeEachProviders, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter, beforeEach, beforeEachProviders, expect, iit, inject, it, xit,} from '@angular/core/testing/testing_internal';
|
||||
import {ComponentFixture, TestComponentBuilder} from '@angular/core/testing';
|
||||
|
||||
import {specs, compile, TEST_ROUTER_PROVIDERS, clickOnElement, getHref} from '../util';
|
||||
|
@ -38,7 +37,7 @@ function syncRoutesWithoutChildrenWithoutParams() {
|
|||
|
||||
it('should navigate by URL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile(tcb)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then(
|
||||
(_) => rtr.config([new Route({path: '/test', component: HelloCmp, name: 'Hello'})]))
|
||||
.then((_) => rtr.navigateByUrl('/test'))
|
||||
|
@ -51,7 +50,7 @@ function syncRoutesWithoutChildrenWithoutParams() {
|
|||
|
||||
it('should navigate by link DSL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile(tcb)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then(
|
||||
(_) => rtr.config([new Route({path: '/test', component: HelloCmp, name: 'Hello'})]))
|
||||
.then((_) => rtr.navigate(['/Hello']))
|
||||
|
@ -64,7 +63,7 @@ function syncRoutesWithoutChildrenWithoutParams() {
|
|||
|
||||
it('should generate a link URL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile(tcb, `<a [routerLink]="['Hello']">go to hello</a> | <router-outlet></router-outlet>`)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then(
|
||||
(_) => rtr.config([new Route({path: '/test', component: HelloCmp, name: 'Hello'})]))
|
||||
.then((_) => {
|
||||
|
@ -80,7 +79,7 @@ function syncRoutesWithoutChildrenWithoutParams() {
|
|||
(async: AsyncTestCompleter, location: any /** TODO #9100 */) => {
|
||||
compile(
|
||||
tcb, `<a [routerLink]="['Hello']">go to hello</a> | <router-outlet></router-outlet>`)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then(
|
||||
(_) =>
|
||||
rtr.config([new Route({path: '/test', component: HelloCmp, name: 'Hello'})]))
|
||||
|
@ -117,7 +116,7 @@ function syncRoutesWithoutChildrenWithParams() {
|
|||
|
||||
it('should navigate by URL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile(tcb)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then(
|
||||
(_) =>
|
||||
rtr.config([new Route({path: '/user/:name', component: UserCmp, name: 'User'})]))
|
||||
|
@ -131,7 +130,7 @@ function syncRoutesWithoutChildrenWithParams() {
|
|||
|
||||
it('should navigate by link DSL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile(tcb)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then(
|
||||
(_) =>
|
||||
rtr.config([new Route({path: '/user/:name', component: UserCmp, name: 'User'})]))
|
||||
|
@ -147,7 +146,7 @@ function syncRoutesWithoutChildrenWithParams() {
|
|||
compile(
|
||||
tcb,
|
||||
`<a [routerLink]="['User', {name: 'naomi'}]">greet naomi</a> | <router-outlet></router-outlet>`)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then(
|
||||
(_) =>
|
||||
rtr.config([new Route({path: '/user/:name', component: UserCmp, name: 'User'})]))
|
||||
|
@ -165,7 +164,7 @@ function syncRoutesWithoutChildrenWithParams() {
|
|||
compile(
|
||||
tcb,
|
||||
`<a [routerLink]="['User', {name: 'naomi'}]">greet naomi</a> | <router-outlet></router-outlet>`)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new Route(
|
||||
{path: '/user/:name', component: UserCmp, name: 'User'})]))
|
||||
.then((_) => {
|
||||
|
@ -187,7 +186,7 @@ function syncRoutesWithoutChildrenWithParams() {
|
|||
it('should navigate between components with different parameters',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile(tcb)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then(
|
||||
(_) =>
|
||||
rtr.config([new Route({path: '/user/:name', component: UserCmp, name: 'User'})]))
|
||||
|
@ -222,7 +221,7 @@ function syncRoutesWithSyncChildrenWithoutDefaultRoutesWithoutParams() {
|
|||
|
||||
it('should navigate by URL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile(tcb, `outer [ <router-outlet></router-outlet> ]`)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then(
|
||||
(_) =>
|
||||
rtr.config([new Route({path: '/a/...', component: ParentCmp, name: 'Parent'})]))
|
||||
|
@ -236,7 +235,7 @@ function syncRoutesWithSyncChildrenWithoutDefaultRoutesWithoutParams() {
|
|||
|
||||
it('should navigate by link DSL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile(tcb, `outer [ <router-outlet></router-outlet> ]`)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then(
|
||||
(_) =>
|
||||
rtr.config([new Route({path: '/a/...', component: ParentCmp, name: 'Parent'})]))
|
||||
|
@ -252,7 +251,7 @@ function syncRoutesWithSyncChildrenWithoutDefaultRoutesWithoutParams() {
|
|||
compile(
|
||||
tcb,
|
||||
`<a [routerLink]="['Parent', 'Child']">nav to child</a> | outer [ <router-outlet></router-outlet> ]`)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then(
|
||||
(_) =>
|
||||
rtr.config([new Route({path: '/a/...', component: ParentCmp, name: 'Parent'})]))
|
||||
|
@ -270,7 +269,7 @@ function syncRoutesWithSyncChildrenWithoutDefaultRoutesWithoutParams() {
|
|||
compile(
|
||||
tcb,
|
||||
`<a [routerLink]="['Parent', 'Child']">nav to child</a> | outer [ <router-outlet></router-outlet> ]`)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new Route(
|
||||
{path: '/a/...', component: ParentCmp, name: 'Parent'})]))
|
||||
.then((_) => {
|
||||
|
@ -307,7 +306,7 @@ function syncRoutesWithSyncChildrenWithoutDefaultRoutesWithParams() {
|
|||
|
||||
it('should navigate by URL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile(tcb, `[ <router-outlet></router-outlet> ]`)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new Route(
|
||||
{path: '/team/:id/...', component: TeamCmp, name: 'Team'})]))
|
||||
.then((_) => rtr.navigateByUrl('/team/angular/user/matias'))
|
||||
|
@ -321,7 +320,7 @@ function syncRoutesWithSyncChildrenWithoutDefaultRoutesWithParams() {
|
|||
|
||||
it('should navigate by link DSL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile(tcb, `[ <router-outlet></router-outlet> ]`)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new Route(
|
||||
{path: '/team/:id/...', component: TeamCmp, name: 'Team'})]))
|
||||
.then((_) => rtr.navigate(['/Team', {id: 'angular'}, 'User', {name: 'matias'}]))
|
||||
|
@ -337,7 +336,7 @@ function syncRoutesWithSyncChildrenWithoutDefaultRoutesWithParams() {
|
|||
compile(
|
||||
tcb,
|
||||
`<a [routerLink]="['/Team', {id: 'angular'}, 'User', {name: 'matias'}]">nav to matias</a> [ <router-outlet></router-outlet> ]`)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new Route(
|
||||
{path: '/team/:id/...', component: TeamCmp, name: 'Team'})]))
|
||||
.then((_) => {
|
||||
|
@ -354,7 +353,7 @@ function syncRoutesWithSyncChildrenWithoutDefaultRoutesWithParams() {
|
|||
compile(
|
||||
tcb,
|
||||
`<a [routerLink]="['/Team', {id: 'angular'}, 'User', {name: 'matias'}]">nav to matias</a> [ <router-outlet></router-outlet> ]`)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new Route(
|
||||
{path: '/team/:id/...', component: TeamCmp, name: 'Team'})]))
|
||||
.then((_) => {
|
||||
|
@ -391,7 +390,7 @@ function syncRoutesWithSyncChildrenWithDefaultRoutesWithoutParams() {
|
|||
|
||||
it('should navigate by URL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile(tcb, `outer [ <router-outlet></router-outlet> ]`)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new Route(
|
||||
{path: '/a/...', component: ParentWithDefaultCmp, name: 'Parent'})]))
|
||||
.then((_) => rtr.navigateByUrl('/a'))
|
||||
|
@ -404,7 +403,7 @@ function syncRoutesWithSyncChildrenWithDefaultRoutesWithoutParams() {
|
|||
|
||||
it('should navigate by link DSL', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile(tcb, `outer [ <router-outlet></router-outlet> ]`)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new Route(
|
||||
{path: '/a/...', component: ParentWithDefaultCmp, name: 'Parent'})]))
|
||||
.then((_) => rtr.navigate(['/Parent']))
|
||||
|
@ -419,7 +418,7 @@ function syncRoutesWithSyncChildrenWithDefaultRoutesWithoutParams() {
|
|||
compile(
|
||||
tcb,
|
||||
`<a [routerLink]="['/Parent']">link to inner</a> | outer [ <router-outlet></router-outlet> ]`)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new Route(
|
||||
{path: '/a/...', component: ParentWithDefaultCmp, name: 'Parent'})]))
|
||||
.then((_) => {
|
||||
|
@ -436,7 +435,7 @@ function syncRoutesWithSyncChildrenWithDefaultRoutesWithoutParams() {
|
|||
compile(
|
||||
tcb,
|
||||
`<a [routerLink]="['/Parent']">link to inner</a> | outer [ <router-outlet></router-outlet> ]`)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new Route(
|
||||
{path: '/a/...', component: ParentWithDefaultCmp, name: 'Parent'})]))
|
||||
.then((_) => {
|
||||
|
@ -472,40 +471,38 @@ function syncRoutesWithDynamicComponents() {
|
|||
}));
|
||||
|
||||
|
||||
it('should work',
|
||||
inject(
|
||||
[AsyncTestCompleter],
|
||||
(async: AsyncTestCompleter) => {
|
||||
tcb.createAsync(DynamicLoaderCmp)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((_) => rtr.config([new Route({path: '/', component: HelloCmp})]))
|
||||
.then((_) => {
|
||||
fixture.detectChanges();
|
||||
expect(fixture.debugElement.nativeElement).toHaveText('[ ]');
|
||||
return fixture.componentInstance.onSomeAction();
|
||||
})
|
||||
.then((_) => {
|
||||
fixture.detectChanges();
|
||||
return rtr.navigateByUrl('/');
|
||||
})
|
||||
.then((_) => {
|
||||
fixture.detectChanges();
|
||||
expect(fixture.debugElement.nativeElement).toHaveText('[ hello ]');
|
||||
it('should work', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
tcb.createAsync(DynamicLoaderCmp)
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new Route({path: '/', component: HelloCmp})]))
|
||||
.then((_) => {
|
||||
fixture.detectChanges();
|
||||
expect(fixture.debugElement.nativeElement).toHaveText('[ ]');
|
||||
return fixture.componentInstance.onSomeAction();
|
||||
})
|
||||
.then((_) => {
|
||||
fixture.detectChanges();
|
||||
return rtr.navigateByUrl('/');
|
||||
})
|
||||
.then((_) => {
|
||||
fixture.detectChanges();
|
||||
expect(fixture.debugElement.nativeElement).toHaveText('[ hello ]');
|
||||
|
||||
return fixture.componentInstance.onSomeAction();
|
||||
})
|
||||
.then((_) => {
|
||||
return fixture.componentInstance.onSomeAction();
|
||||
})
|
||||
.then((_) => {
|
||||
|
||||
// TODO(i): This should be rewritten to use NgZone#onStable or
|
||||
// something
|
||||
// similar basically the assertion needs to run when the world is
|
||||
// stable and we don't know when that is, only zones know.
|
||||
PromiseWrapper.resolve(null).then((_) => {
|
||||
fixture.detectChanges();
|
||||
expect(fixture.debugElement.nativeElement).toHaveText('[ hello ]');
|
||||
async.done();
|
||||
});
|
||||
})}));
|
||||
// TODO(i): This should be rewritten to use NgZone#onStable or
|
||||
// something
|
||||
// similar basically the assertion needs to run when the world is
|
||||
// stable and we don't know when that is, only zones know.
|
||||
PromiseWrapper.resolve(null).then((_) => {
|
||||
fixture.detectChanges();
|
||||
expect(fixture.debugElement.nativeElement).toHaveText('[ hello ]');
|
||||
async.done();
|
||||
});
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -6,10 +6,9 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Component, Inject, Injector, provide} from '@angular/core';
|
||||
import {Component,} from '@angular/core';
|
||||
import {ComponentFixture, TestComponentBuilder} from '@angular/core/testing';
|
||||
import {beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal';
|
||||
import {RouteParams, Router, RouterLink, RouterOutlet} from '@angular/router-deprecated';
|
||||
|
||||
import {EventEmitter, ObservableWrapper, PromiseCompleter, PromiseWrapper} from '../../src/facade/async';
|
||||
|
@ -19,7 +18,7 @@ import {CanDeactivate, CanReuse, OnActivate, OnDeactivate, OnReuse} from '../../
|
|||
import {CanActivate} from '../../src/lifecycle/lifecycle_annotations';
|
||||
import {AsyncRoute, AuxRoute, Redirect, Route, RouteConfig} from '../../src/route_config/route_config_decorator';
|
||||
|
||||
import {RootCmp, TEST_ROUTER_PROVIDERS, compile} from './util';
|
||||
import {TEST_ROUTER_PROVIDERS, compile} from './util';
|
||||
|
||||
var cmpInstanceCount: any /** TODO #9100 */;
|
||||
var log: string[];
|
||||
|
@ -47,7 +46,7 @@ export function main() {
|
|||
it('should call the routerOnActivate hook',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile(tcb)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})]))
|
||||
.then((_) => rtr.navigateByUrl('/on-activate'))
|
||||
.then((_) => {
|
||||
|
@ -61,7 +60,7 @@ export function main() {
|
|||
it('should wait for a parent component\'s routerOnActivate hook to resolve before calling its child\'s',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile(tcb)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})]))
|
||||
.then((_) => {
|
||||
ObservableWrapper.subscribe<string>(eventBus, (ev) => {
|
||||
|
@ -83,7 +82,7 @@ export function main() {
|
|||
it('should call the routerOnDeactivate hook',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile(tcb)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})]))
|
||||
.then((_) => rtr.navigateByUrl('/on-deactivate'))
|
||||
.then((_) => rtr.navigateByUrl('/a'))
|
||||
|
@ -98,7 +97,7 @@ export function main() {
|
|||
it('should wait for a child component\'s routerOnDeactivate hook to resolve before calling its parent\'s',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile(tcb)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})]))
|
||||
.then((_) => rtr.navigateByUrl('/parent-deactivate/child-deactivate'))
|
||||
.then((_) => {
|
||||
|
@ -124,7 +123,7 @@ export function main() {
|
|||
it('should reuse a component when the routerCanReuse hook returns true',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile(tcb)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})]))
|
||||
.then((_) => rtr.navigateByUrl('/on-reuse/1/a'))
|
||||
.then((_) => {
|
||||
|
@ -147,7 +146,7 @@ export function main() {
|
|||
it('should not reuse a component when the routerCanReuse hook returns false',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile(tcb)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})]))
|
||||
.then((_) => rtr.navigateByUrl('/never-reuse/1/a'))
|
||||
.then((_) => {
|
||||
|
@ -170,7 +169,7 @@ export function main() {
|
|||
it('should navigate when routerCanActivate returns true',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile(tcb)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})]))
|
||||
.then((_) => {
|
||||
ObservableWrapper.subscribe<string>(eventBus, (ev) => {
|
||||
|
@ -190,7 +189,7 @@ export function main() {
|
|||
it('should not navigate when routerCanActivate returns false',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile(tcb)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})]))
|
||||
.then((_) => {
|
||||
ObservableWrapper.subscribe<string>(eventBus, (ev) => {
|
||||
|
@ -210,7 +209,7 @@ export function main() {
|
|||
it('should navigate away when routerCanDeactivate returns true',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile(tcb)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})]))
|
||||
.then((_) => rtr.navigateByUrl('/can-deactivate/a'))
|
||||
.then((_) => {
|
||||
|
@ -236,7 +235,7 @@ export function main() {
|
|||
it('should not navigate away when routerCanDeactivate returns false',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile(tcb)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})]))
|
||||
.then((_) => rtr.navigateByUrl('/can-deactivate/a'))
|
||||
.then((_) => {
|
||||
|
@ -263,7 +262,7 @@ export function main() {
|
|||
it('should run activation and deactivation hooks in the correct order',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile(tcb)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})]))
|
||||
.then((_) => rtr.navigateByUrl('/activation-hooks/child'))
|
||||
.then((_) => {
|
||||
|
@ -291,7 +290,7 @@ export function main() {
|
|||
it('should only run reuse hooks when reusing',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile(tcb)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})]))
|
||||
.then((_) => rtr.navigateByUrl('/reuse-hooks/1'))
|
||||
.then((_) => {
|
||||
|
|
|
@ -9,8 +9,7 @@
|
|||
import {Location} from '@angular/common';
|
||||
import {Component, Inject, Injector, provide} from '@angular/core';
|
||||
import {ComponentFixture, TestComponentBuilder} from '@angular/core/testing';
|
||||
import {beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal';
|
||||
import {RouteData, RouteParams, Router, RouterLink, RouterOutlet} from '@angular/router-deprecated';
|
||||
|
||||
import {PromiseWrapper, TimerWrapper} from '../../src/facade/async';
|
||||
|
@ -41,7 +40,7 @@ export function main() {
|
|||
|
||||
it('should work in a simple case', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile(tcb)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new Route({path: '/test', component: HelloCmp})]))
|
||||
.then((_) => rtr.navigateByUrl('/test'))
|
||||
.then((_) => {
|
||||
|
@ -55,7 +54,7 @@ export function main() {
|
|||
it('should navigate between components with different parameters',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile(tcb)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new Route({path: '/user/:name', component: UserCmp})]))
|
||||
.then((_) => rtr.navigateByUrl('/user/brian'))
|
||||
.then((_) => {
|
||||
|
@ -73,7 +72,7 @@ export function main() {
|
|||
it('should navigate to child routes',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile(tcb, 'outer [ <router-outlet></router-outlet> ]')
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new Route({path: '/a/...', component: ParentCmp})]))
|
||||
.then((_) => rtr.navigateByUrl('/a/b'))
|
||||
.then((_) => {
|
||||
|
@ -87,7 +86,7 @@ export function main() {
|
|||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
|
||||
compile(tcb, 'outer [ <router-outlet></router-outlet> ]')
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new Route({path: '/a/...', component: ParentCmp})]))
|
||||
.then((_) => rtr.navigateByUrl('/a'))
|
||||
.then((_) => {
|
||||
|
@ -102,7 +101,7 @@ export function main() {
|
|||
[AsyncTestCompleter, Location],
|
||||
(async: AsyncTestCompleter, location: any /** TODO #9100 */) => {
|
||||
compile(tcb, 'outer [ <router-outlet></router-outlet> ]')
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new Route({path: '/...', component: ParentCmp})]))
|
||||
.then((_) => rtr.navigateByUrl('/b'))
|
||||
.then((_) => {
|
||||
|
@ -117,7 +116,7 @@ export function main() {
|
|||
it('should navigate to child routes of async routes',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile(tcb, 'outer [ <router-outlet></router-outlet> ]')
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new AsyncRoute({path: '/a/...', loader: parentLoader})]))
|
||||
.then((_) => rtr.navigateByUrl('/a/b'))
|
||||
.then((_) => {
|
||||
|
@ -133,7 +132,7 @@ export function main() {
|
|||
[AsyncTestCompleter, Location],
|
||||
(async: AsyncTestCompleter, location: any /** TODO #9100 */) => {
|
||||
compile(tcb)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => location.setInitialPath('/test/'))
|
||||
.then((_) => rtr.config([new Route({path: '/test', component: HelloCmp})]))
|
||||
.then((_) => rtr.navigateByUrl('/test'))
|
||||
|
@ -148,7 +147,7 @@ export function main() {
|
|||
it('should reuse common parent components',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile(tcb)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new Route({path: '/team/:id/...', component: TeamCmp})]))
|
||||
.then((_) => rtr.navigateByUrl('/team/angular/user/rado'))
|
||||
.then((_) => {
|
||||
|
@ -169,7 +168,7 @@ export function main() {
|
|||
it('should not reuse children when parent components change',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile(tcb)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new Route({path: '/team/:id/...', component: TeamCmp})]))
|
||||
.then((_) => rtr.navigateByUrl('/team/angular/user/rado'))
|
||||
.then((_) => {
|
||||
|
@ -191,7 +190,7 @@ export function main() {
|
|||
it('should inject route data into component',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile(tcb)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new Route(
|
||||
{path: '/route-data', component: RouteDataCmp, data: {isAdmin: true}})]))
|
||||
.then((_) => rtr.navigateByUrl('/route-data'))
|
||||
|
@ -205,7 +204,7 @@ export function main() {
|
|||
it('should inject route data into component with AsyncRoute',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile(tcb)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new AsyncRoute(
|
||||
{path: '/route-data', loader: asyncRouteDataCmp, data: {isAdmin: true}})]))
|
||||
.then((_) => rtr.navigateByUrl('/route-data'))
|
||||
|
@ -219,7 +218,7 @@ export function main() {
|
|||
it('should inject empty object if the route has no data property',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile(tcb)
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new Route(
|
||||
{path: '/route-data-default', component: RouteDataCmp})]))
|
||||
.then((_) => rtr.navigateByUrl('/route-data-default'))
|
||||
|
@ -233,7 +232,7 @@ export function main() {
|
|||
it('should fire an event for each activated component',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile(tcb, '<router-outlet (activate)="activatedCmp = $event"></router-outlet>')
|
||||
.then((rtc) => {fixture = rtc})
|
||||
.then((rtc) => { fixture = rtc; })
|
||||
.then((_) => rtr.config([new Route({path: '/test', component: HelloCmp})]))
|
||||
.then((_) => rtr.navigateByUrl('/test'))
|
||||
.then((_) => {
|
||||
|
|
|
@ -8,8 +8,7 @@
|
|||
|
||||
import {Location} from '@angular/common';
|
||||
import {ComponentFixture, TestComponentBuilder} from '@angular/core/testing';
|
||||
import {beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal';
|
||||
import {RouteData, RouteParams, Router, RouterLink, RouterOutlet} from '@angular/router-deprecated';
|
||||
|
||||
import {AsyncRoute, AuxRoute, Redirect, Route, RouteConfig} from '../../src/route_config/route_config_decorator';
|
||||
|
@ -44,7 +43,7 @@ export function main() {
|
|||
[AsyncTestCompleter, Location],
|
||||
(async: AsyncTestCompleter, location: any /** TODO #9100 */) => {
|
||||
compile(tcb)
|
||||
.then((rtc) => {rootTC = rtc})
|
||||
.then((rtc) => { rootTC = rtc; })
|
||||
.then((_) => rtr.config([
|
||||
new Redirect({path: '/original', redirectTo: ['Hello']}),
|
||||
new Route({path: '/redirected', component: HelloCmp, name: 'Hello'})
|
||||
|
@ -64,7 +63,7 @@ export function main() {
|
|||
[AsyncTestCompleter, Location],
|
||||
(async: AsyncTestCompleter, location: any /** TODO #9100 */) => {
|
||||
compile(tcb)
|
||||
.then((rtc) => {rootTC = rtc})
|
||||
.then((rtc) => { rootTC = rtc; })
|
||||
.then((_) => rtr.config([
|
||||
new Redirect({path: '/original', redirectTo: ['/Hello']}),
|
||||
new Route({path: '/redirected', component: HelloCmp, name: 'Hello'})
|
||||
|
@ -84,7 +83,7 @@ export function main() {
|
|||
[AsyncTestCompleter, Location],
|
||||
(async: AsyncTestCompleter, location: any /** TODO #9100 */) => {
|
||||
compile(tcb)
|
||||
.then((rtc) => {rootTC = rtc})
|
||||
.then((rtc) => { rootTC = rtc; })
|
||||
.then((_) => rtr.config([
|
||||
new Redirect({path: '/original', redirectTo: ['./Hello']}),
|
||||
new Route({path: '/redirected', component: HelloCmp, name: 'Hello'})
|
||||
|
@ -104,7 +103,7 @@ export function main() {
|
|||
[AsyncTestCompleter, Location],
|
||||
(async: AsyncTestCompleter, location: any /** TODO #9100 */) => {
|
||||
compile(tcb)
|
||||
.then((rtc) => {rootTC = rtc})
|
||||
.then((rtc) => { rootTC = rtc; })
|
||||
.then((_) => rtr.config([
|
||||
new Route({path: '/original/...', component: RedirectToParentCmp}),
|
||||
new Route({path: '/redirected', component: HelloCmp, name: 'HelloSib'})
|
||||
|
@ -124,7 +123,7 @@ export function main() {
|
|||
[AsyncTestCompleter, Location],
|
||||
(async: AsyncTestCompleter, location: any /** TODO #9100 */) => {
|
||||
compile(tcb)
|
||||
.then((rtc) => {rootTC = rtc})
|
||||
.then((rtc) => { rootTC = rtc; })
|
||||
.then((_) => rtr.config([
|
||||
new Route({path: '/foo', component: HelloCmp, name: 'Hello'}),
|
||||
new Route({path: '/:param', component: GoodbyeCmp, name: 'Goodbye'}),
|
||||
|
|
|
@ -6,8 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {beforeEach, ddescribe, xdescribe, describe, expect, iit, inject, beforeEachProviders, it, xit,} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter, beforeEach, ddescribe, xdescribe, describe, expect, iit, inject, beforeEachProviders, it, xit,} from '@angular/core/testing/testing_internal';
|
||||
import {ComponentFixture, TestComponentBuilder} from '@angular/core/testing';
|
||||
import {Location} from '@angular/common';
|
||||
import {NumberWrapper, escapeRegExp} from '../../src/facade/lang';
|
||||
|
|
|
@ -6,11 +6,10 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {describe, it, iit, ddescribe, expect, inject, beforeEach, beforeEachProviders,} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter, describe, it, iit, ddescribe, expect, inject, beforeEach, beforeEachProviders,} from '@angular/core/testing/testing_internal';
|
||||
|
||||
import {Injector, provide, ReflectiveInjector} from '@angular/core';
|
||||
import {Location, LocationStrategy, APP_BASE_HREF} from '@angular/common';
|
||||
import {ReflectiveInjector} from '@angular/core';
|
||||
import {Location, LocationStrategy} from '@angular/common';
|
||||
import {MockLocationStrategy} from '@angular/common/testing/mock_location_strategy';
|
||||
|
||||
export function main() {
|
||||
|
|
|
@ -6,18 +6,16 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {beforeEach, ddescribe, describe, expect, iit, inject, it, xdescribe, xit,} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter, beforeEach, ddescribe, describe, expect, iit, inject, it, xdescribe, xit,} from '@angular/core/testing/testing_internal';
|
||||
|
||||
import {bootstrap} from '@angular/platform-browser-dynamic';
|
||||
import {APP_BASE_HREF, LocationStrategy} from '@angular/common';
|
||||
import {LocationStrategy} from '@angular/common';
|
||||
import {Component, Directive} from '@angular/core/src/metadata';
|
||||
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
||||
import {Console} from '@angular/core/src/console';
|
||||
import {provide, disposePlatform} from '@angular/core';
|
||||
import {ExceptionHandler, disposePlatform} from '@angular/core';
|
||||
import {DOCUMENT} from '@angular/platform-browser/src/dom/dom_tokens';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
import {ROUTER_PROVIDERS, Router, RouteConfig, ROUTER_DIRECTIVES} from '@angular/router-deprecated';
|
||||
import {ExceptionHandler} from '@angular/core';
|
||||
import {MockLocationStrategy} from '@angular/common/testing/mock_location_strategy';
|
||||
|
||||
class _ArrayLogger {
|
||||
|
@ -138,38 +136,37 @@ export function main() {
|
|||
}));
|
||||
|
||||
it('should throw if a config is missing a target',
|
||||
inject(
|
||||
[AsyncTestCompleter],
|
||||
(async: AsyncTestCompleter) => {bootstrap(WrongConfigCmp, testBindings).catch((e) => {
|
||||
expect(e.originalException)
|
||||
.toContainError(
|
||||
'Route config should contain exactly one "component", "loader", or "redirectTo" property.');
|
||||
async.done();
|
||||
return null;
|
||||
})}));
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
bootstrap(WrongConfigCmp, testBindings).catch((e) => {
|
||||
expect(e.originalException)
|
||||
.toContainError(
|
||||
'Route config should contain exactly one "component", "loader", or "redirectTo" property.');
|
||||
async.done();
|
||||
return null;
|
||||
});
|
||||
}));
|
||||
|
||||
it('should throw if a config has an invalid component type',
|
||||
inject(
|
||||
[AsyncTestCompleter],
|
||||
(async:
|
||||
AsyncTestCompleter) => {bootstrap(WrongComponentTypeCmp, testBindings).catch((e) => {
|
||||
expect(e.originalException)
|
||||
.toContainError(
|
||||
'Invalid component type "intentionallyWrongComponentType". Valid types are "constructor" and "loader".');
|
||||
async.done();
|
||||
return null;
|
||||
})}));
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
bootstrap(WrongComponentTypeCmp, testBindings).catch((e) => {
|
||||
expect(e.originalException)
|
||||
.toContainError(
|
||||
'Invalid component type "intentionallyWrongComponentType". Valid types are "constructor" and "loader".');
|
||||
async.done();
|
||||
return null;
|
||||
});
|
||||
}));
|
||||
|
||||
it('should throw if a config has an invalid alias name',
|
||||
inject(
|
||||
[AsyncTestCompleter],
|
||||
(async: AsyncTestCompleter) => {bootstrap(BadAliasNameCmp, testBindings).catch((e) => {
|
||||
expect(e.originalException)
|
||||
.toContainError(
|
||||
`Route "/child" with name "child" does not begin with an uppercase letter. Route names should be PascalCase like "Child".`);
|
||||
async.done();
|
||||
return null;
|
||||
})}));
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
bootstrap(BadAliasNameCmp, testBindings).catch((e) => {
|
||||
expect(e.originalException)
|
||||
.toContainError(
|
||||
`Route "/child" with name "child" does not begin with an uppercase letter. Route names should be PascalCase like "Child".`);
|
||||
async.done();
|
||||
return null;
|
||||
});
|
||||
}));
|
||||
|
||||
});
|
||||
}
|
||||
|
|
|
@ -6,8 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {describe, it, iit, ddescribe, expect, inject, beforeEach,} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter, describe, it, iit, ddescribe, expect, inject, beforeEach,} from '@angular/core/testing/testing_internal';
|
||||
|
||||
import {PromiseWrapper} from '../src/facade/async';
|
||||
import {Type, IS_DART} from '../src/facade/lang';
|
||||
|
|
|
@ -9,8 +9,7 @@
|
|||
import {Location} from '@angular/common';
|
||||
import {SpyLocation} from '@angular/common/testing';
|
||||
import {provide} from '@angular/core';
|
||||
import {beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xit} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xit} from '@angular/core/testing/testing_internal';
|
||||
|
||||
import {RouterOutlet} from '../src/directives/router_outlet';
|
||||
import {ObservableWrapper, PromiseWrapper} from '../src/facade/async';
|
||||
|
|
|
@ -10,7 +10,7 @@ import {describe, it, iit, ddescribe, expect, inject, beforeEach,} from '@angula
|
|||
|
||||
import {GeneratedUrl} from '../../../src/rules/route_paths/route_path';
|
||||
import {RegexRoutePath} from '../../../src/rules/route_paths/regex_route_path';
|
||||
import {parser, Url} from '../../../src/url_parser';
|
||||
import {parser} from '../../../src/url_parser';
|
||||
|
||||
function emptySerializer(params: any /** TODO #9100 */) {
|
||||
return new GeneratedUrl('', {});
|
||||
|
@ -47,10 +47,9 @@ export function main() {
|
|||
});
|
||||
|
||||
it('should raise an error when the number of parameters doesnt match', () => {
|
||||
expect(
|
||||
() => {new RegexRoutePath(
|
||||
'^a-([0-9]+)-b-([0-9]+)$', emptySerializer, ['complete_match', 'a'])})
|
||||
.toThrowError(`Regex group names [complete_match,a] must contain names for each matching \
|
||||
expect(() => {
|
||||
new RegexRoutePath('^a-([0-9]+)-b-([0-9]+)$', emptySerializer, ['complete_match', 'a']);
|
||||
}).toThrowError(`Regex group names [complete_match,a] must contain names for each matching \
|
||||
group and a name for the complete match as its first element of regex '^a-([0-9]+)-b-([0-9]+)$'. \
|
||||
3 group names are expected.`);
|
||||
});
|
||||
|
|
|
@ -6,8 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {describe, it, iit, ddescribe, expect, inject, beforeEach,} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter, describe, it, iit, ddescribe, expect, inject, beforeEach,} from '@angular/core/testing/testing_internal';
|
||||
import {RouteMatch, PathMatch, RedirectMatch} from '../../src/rules/rules';
|
||||
import {RuleSet} from '../../src/rules/rule_set';
|
||||
import {GeneratedUrl} from '../../src/rules/route_paths/route_path';
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
/**
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import {of } from 'rxjs/observable/of';
|
||||
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
/**
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {validateConfig} from '../src/config';
|
||||
|
||||
describe('config', () => {
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
/**
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Routes} from '../src/config';
|
||||
import {createRouterState} from '../src/create_router_state';
|
||||
import {recognize} from '../src/recognize';
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
/**
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {BehaviorSubject} from 'rxjs/BehaviorSubject';
|
||||
|
||||
import {createUrlTree} from '../src/create_url_tree';
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
/**
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Routes} from '../src/config';
|
||||
import {recognize} from '../src/recognize';
|
||||
import {ActivatedRouteSnapshot, RouterStateSnapshot} from '../src/router_state';
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
/**
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Routes} from '../src/config';
|
||||
import {recognize} from '../src/recognize';
|
||||
import {resolve} from '../src/resolve';
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue