refactor(): use const and let instead of var
This commit is contained in:

committed by
Victor Berchet

parent
73593d4bf3
commit
77ee27c59e
@ -20,8 +20,8 @@ export class AnimationGroupPlayer implements AnimationPlayer {
|
||||
public parentPlayer: AnimationPlayer = null;
|
||||
|
||||
constructor(private _players: AnimationPlayer[]) {
|
||||
var count = 0;
|
||||
var total = this._players.length;
|
||||
let count = 0;
|
||||
const total = this._players.length;
|
||||
if (total == 0) {
|
||||
scheduleMicroTask(() => this._onFinish());
|
||||
} else {
|
||||
@ -93,9 +93,9 @@ export class AnimationGroupPlayer implements AnimationPlayer {
|
||||
}
|
||||
|
||||
getPosition(): number {
|
||||
var min = 0;
|
||||
let min = 0;
|
||||
this._players.forEach(player => {
|
||||
var p = player.getPosition();
|
||||
const p = player.getPosition();
|
||||
min = Math.min(p, min);
|
||||
});
|
||||
return min;
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
import {AnimationPlayer} from './animation_player';
|
||||
|
||||
var _queuedAnimations: AnimationPlayer[] = [];
|
||||
let _queuedAnimations: AnimationPlayer[] = [];
|
||||
|
||||
/** @internal */
|
||||
export function queueAnimation(player: AnimationPlayer) {
|
||||
@ -26,8 +26,8 @@ export function triggerQueuedAnimations() {
|
||||
}
|
||||
|
||||
function _triggerAnimations() {
|
||||
for (var i = 0; i < _queuedAnimations.length; i++) {
|
||||
var player = _queuedAnimations[i];
|
||||
for (let i = 0; i < _queuedAnimations.length; i++) {
|
||||
const player = _queuedAnimations[i];
|
||||
player.play();
|
||||
}
|
||||
_queuedAnimations = [];
|
||||
|
@ -36,7 +36,7 @@ export class AnimationSequencePlayer implements AnimationPlayer {
|
||||
this._activePlayer = new NoOpAnimationPlayer();
|
||||
this._onFinish();
|
||||
} else {
|
||||
var player = this._players[this._currentIndex++];
|
||||
const player = this._players[this._currentIndex++];
|
||||
player.onDone(() => this._onNext(true));
|
||||
|
||||
this._activePlayer = player;
|
||||
|
@ -15,7 +15,7 @@ import {AUTO_STYLE} from './metadata';
|
||||
export function prepareFinalAnimationStyles(
|
||||
previousStyles: {[key: string]: string | number}, newStyles: {[key: string]: string | number},
|
||||
nullValue: string = null): {[key: string]: string} {
|
||||
var finalStyles: {[key: string]: string} = {};
|
||||
const finalStyles: {[key: string]: string} = {};
|
||||
|
||||
Object.keys(newStyles).forEach(prop => {
|
||||
const value = newStyles[prop];
|
||||
@ -34,14 +34,14 @@ export function prepareFinalAnimationStyles(
|
||||
export function balanceAnimationKeyframes(
|
||||
collectedStyles: {[key: string]: string | number},
|
||||
finalStateStyles: {[key: string]: string | number}, keyframes: any[]): any[] {
|
||||
var limit = keyframes.length - 1;
|
||||
var firstKeyframe = keyframes[0];
|
||||
const limit = keyframes.length - 1;
|
||||
const firstKeyframe = keyframes[0];
|
||||
|
||||
// phase 1: copy all the styles from the first keyframe into the lookup map
|
||||
var flatenedFirstKeyframeStyles = flattenStyles(firstKeyframe.styles.styles);
|
||||
const flatenedFirstKeyframeStyles = flattenStyles(firstKeyframe.styles.styles);
|
||||
|
||||
var extraFirstKeyframeStyles: {[key: string]: string} = {};
|
||||
var hasExtraFirstStyles = false;
|
||||
const extraFirstKeyframeStyles: {[key: string]: string} = {};
|
||||
let hasExtraFirstStyles = false;
|
||||
Object.keys(collectedStyles).forEach(prop => {
|
||||
const value = collectedStyles[prop] as string;
|
||||
// if the style is already defined in the first keyframe then
|
||||
@ -53,15 +53,15 @@ export function balanceAnimationKeyframes(
|
||||
}
|
||||
});
|
||||
|
||||
var keyframeCollectedStyles = StringMapWrapper.merge({}, flatenedFirstKeyframeStyles);
|
||||
const keyframeCollectedStyles = StringMapWrapper.merge({}, flatenedFirstKeyframeStyles);
|
||||
|
||||
// phase 2: normalize the final keyframe
|
||||
var finalKeyframe = keyframes[limit];
|
||||
const finalKeyframe = keyframes[limit];
|
||||
finalKeyframe.styles.styles.unshift(finalStateStyles);
|
||||
|
||||
var flatenedFinalKeyframeStyles = flattenStyles(finalKeyframe.styles.styles);
|
||||
var extraFinalKeyframeStyles: {[key: string]: string} = {};
|
||||
var hasExtraFinalStyles = false;
|
||||
const flatenedFinalKeyframeStyles = flattenStyles(finalKeyframe.styles.styles);
|
||||
const extraFinalKeyframeStyles: {[key: string]: string} = {};
|
||||
let hasExtraFinalStyles = false;
|
||||
Object.keys(keyframeCollectedStyles).forEach(prop => {
|
||||
if (!isPresent(flatenedFinalKeyframeStyles[prop])) {
|
||||
extraFinalKeyframeStyles[prop] = AUTO_STYLE;
|
||||
@ -88,7 +88,7 @@ export function balanceAnimationKeyframes(
|
||||
}
|
||||
|
||||
export function clearStyles(styles: {[key: string]: string | number}): {[key: string]: string} {
|
||||
var finalStyles: {[key: string]: string} = {};
|
||||
const finalStyles: {[key: string]: string} = {};
|
||||
Object.keys(styles).forEach(key => { finalStyles[key] = null; });
|
||||
return finalStyles;
|
||||
}
|
||||
@ -96,7 +96,7 @@ export function clearStyles(styles: {[key: string]: string | number}): {[key: st
|
||||
export function collectAndResolveStyles(
|
||||
collection: {[key: string]: string | number}, styles: {[key: string]: string | number}[]) {
|
||||
return styles.map(entry => {
|
||||
var stylesObj: {[key: string]: string | number} = {};
|
||||
const stylesObj: {[key: string]: string | number} = {};
|
||||
Object.keys(entry).forEach(prop => {
|
||||
let value = entry[prop];
|
||||
if (value == FILL_STYLE_FLAG) {
|
||||
@ -118,7 +118,7 @@ export function renderStyles(
|
||||
}
|
||||
|
||||
export function flattenStyles(styles: {[key: string]: string | number}[]): {[key: string]: string} {
|
||||
var finalStyles: {[key: string]: string} = {};
|
||||
const finalStyles: {[key: string]: string} = {};
|
||||
styles.forEach(entry => {
|
||||
Object.keys(entry).forEach(prop => { finalStyles[prop] = entry[prop] as string; });
|
||||
});
|
||||
|
@ -183,9 +183,9 @@ export class AnimationGroupMetadata extends AnimationWithStepsMetadata {
|
||||
export function animate(
|
||||
timing: string | number, styles: AnimationStyleMetadata | AnimationKeyframesSequenceMetadata =
|
||||
null): AnimationAnimateMetadata {
|
||||
var stylesEntry = styles;
|
||||
let stylesEntry = styles;
|
||||
if (!isPresent(stylesEntry)) {
|
||||
var EMPTY_STYLE: {[key: string]: string | number} = {};
|
||||
const EMPTY_STYLE: {[key: string]: string | number} = {};
|
||||
stylesEntry = new AnimationStyleMetadata([EMPTY_STYLE], 1);
|
||||
}
|
||||
return new AnimationAnimateMetadata(timing, stylesEntry);
|
||||
@ -326,8 +326,8 @@ export function sequence(steps: AnimationMetadata[]): AnimationSequenceMetadata
|
||||
export function style(
|
||||
tokens: string | {[key: string]: string | number} |
|
||||
Array<string|{[key: string]: string | number}>): AnimationStyleMetadata {
|
||||
var input: Array<{[key: string]: string | number}|string>;
|
||||
var offset: number = null;
|
||||
let input: Array<{[key: string]: string | number}|string>;
|
||||
let offset: number = null;
|
||||
if (typeof tokens === 'string') {
|
||||
input = [<string>tokens];
|
||||
} else {
|
||||
@ -337,7 +337,7 @@ export function style(
|
||||
input = [<{[key: string]: string | number}>tokens];
|
||||
}
|
||||
input.forEach(entry => {
|
||||
var entryOffset = (entry as any /** TODO #9100 */)['offset'];
|
||||
const entryOffset = (entry as any /** TODO #9100 */)['offset'];
|
||||
if (isPresent(entryOffset)) {
|
||||
offset = offset == null ? parseFloat(entryOffset) : offset;
|
||||
}
|
||||
@ -564,7 +564,7 @@ export function keyframes(steps: AnimationStyleMetadata[]): AnimationKeyframesSe
|
||||
*/
|
||||
export function transition(stateChangeExpr: string, steps: AnimationMetadata | AnimationMetadata[]):
|
||||
AnimationStateTransitionMetadata {
|
||||
var animationData = Array.isArray(steps) ? new AnimationSequenceMetadata(steps) : steps;
|
||||
const animationData = Array.isArray(steps) ? new AnimationSequenceMetadata(steps) : steps;
|
||||
return new AnimationStateTransitionMetadata(stateChangeExpr, animationData);
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@ export class ViewAnimationMap {
|
||||
private _allPlayers: AnimationPlayer[] = [];
|
||||
|
||||
find(element: any, animationName: string): AnimationPlayer {
|
||||
var playersByAnimation = this._map.get(element);
|
||||
const playersByAnimation = this._map.get(element);
|
||||
if (isPresent(playersByAnimation)) {
|
||||
return playersByAnimation[animationName];
|
||||
}
|
||||
@ -29,11 +29,11 @@ export class ViewAnimationMap {
|
||||
}
|
||||
|
||||
set(element: any, animationName: string, player: AnimationPlayer): void {
|
||||
var playersByAnimation = this._map.get(element);
|
||||
let playersByAnimation = this._map.get(element);
|
||||
if (!isPresent(playersByAnimation)) {
|
||||
playersByAnimation = {};
|
||||
}
|
||||
var existingEntry = playersByAnimation[animationName];
|
||||
const existingEntry = playersByAnimation[animationName];
|
||||
if (isPresent(existingEntry)) {
|
||||
this.remove(element, animationName);
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ export class DefaultIterableDifferFactory implements IterableDifferFactory {
|
||||
}
|
||||
}
|
||||
|
||||
var trackByIdentity = (index: number, item: any) => item;
|
||||
const trackByIdentity = (index: number, item: any) => item;
|
||||
|
||||
/**
|
||||
* @stable
|
||||
@ -55,7 +55,7 @@ export class DefaultIterableDiffer implements IterableDiffer {
|
||||
get length(): number { return this._length; }
|
||||
|
||||
forEachItem(fn: Function) {
|
||||
var record: CollectionChangeRecord;
|
||||
let record: CollectionChangeRecord;
|
||||
for (record = this._itHead; record !== null; record = record._next) {
|
||||
fn(record);
|
||||
}
|
||||
@ -63,20 +63,20 @@ export class DefaultIterableDiffer implements IterableDiffer {
|
||||
|
||||
forEachOperation(
|
||||
fn: (item: CollectionChangeRecord, previousIndex: number, currentIndex: number) => void) {
|
||||
var nextIt = this._itHead;
|
||||
var nextRemove = this._removalsHead;
|
||||
var addRemoveOffset = 0;
|
||||
var moveOffsets: number[] = null;
|
||||
let nextIt = this._itHead;
|
||||
let nextRemove = this._removalsHead;
|
||||
let addRemoveOffset = 0;
|
||||
let moveOffsets: number[] = null;
|
||||
while (nextIt || nextRemove) {
|
||||
// Figure out which is the next record to process
|
||||
// Order: remove, add, move
|
||||
let record = !nextRemove ||
|
||||
const record = !nextRemove ||
|
||||
nextIt &&
|
||||
nextIt.currentIndex < getPreviousIndex(nextRemove, addRemoveOffset, moveOffsets) ?
|
||||
nextIt :
|
||||
nextRemove;
|
||||
var adjPreviousIndex = getPreviousIndex(record, addRemoveOffset, moveOffsets);
|
||||
var currentIndex = record.currentIndex;
|
||||
const adjPreviousIndex = getPreviousIndex(record, addRemoveOffset, moveOffsets);
|
||||
const currentIndex = record.currentIndex;
|
||||
|
||||
// consume the item, and adjust the addRemoveOffset and update moveDistance if necessary
|
||||
if (record === nextRemove) {
|
||||
@ -89,17 +89,17 @@ export class DefaultIterableDiffer implements IterableDiffer {
|
||||
} else {
|
||||
// INVARIANT: currentIndex < previousIndex
|
||||
if (!moveOffsets) moveOffsets = [];
|
||||
let localMovePreviousIndex = adjPreviousIndex - addRemoveOffset;
|
||||
let localCurrentIndex = currentIndex - addRemoveOffset;
|
||||
const localMovePreviousIndex = adjPreviousIndex - addRemoveOffset;
|
||||
const localCurrentIndex = currentIndex - addRemoveOffset;
|
||||
if (localMovePreviousIndex != localCurrentIndex) {
|
||||
for (var i = 0; i < localMovePreviousIndex; i++) {
|
||||
var offset = i < moveOffsets.length ? moveOffsets[i] : (moveOffsets[i] = 0);
|
||||
var index = offset + i;
|
||||
for (let i = 0; i < localMovePreviousIndex; i++) {
|
||||
const offset = i < moveOffsets.length ? moveOffsets[i] : (moveOffsets[i] = 0);
|
||||
const index = offset + i;
|
||||
if (localCurrentIndex <= index && index < localMovePreviousIndex) {
|
||||
moveOffsets[i] = offset + 1;
|
||||
}
|
||||
}
|
||||
var previousIndex = record.previousIndex;
|
||||
const previousIndex = record.previousIndex;
|
||||
moveOffsets[previousIndex] = localCurrentIndex - localMovePreviousIndex;
|
||||
}
|
||||
}
|
||||
@ -112,35 +112,35 @@ export class DefaultIterableDiffer implements IterableDiffer {
|
||||
}
|
||||
|
||||
forEachPreviousItem(fn: Function) {
|
||||
var record: CollectionChangeRecord;
|
||||
let record: CollectionChangeRecord;
|
||||
for (record = this._previousItHead; record !== null; record = record._nextPrevious) {
|
||||
fn(record);
|
||||
}
|
||||
}
|
||||
|
||||
forEachAddedItem(fn: Function) {
|
||||
var record: CollectionChangeRecord;
|
||||
let record: CollectionChangeRecord;
|
||||
for (record = this._additionsHead; record !== null; record = record._nextAdded) {
|
||||
fn(record);
|
||||
}
|
||||
}
|
||||
|
||||
forEachMovedItem(fn: Function) {
|
||||
var record: CollectionChangeRecord;
|
||||
let record: CollectionChangeRecord;
|
||||
for (record = this._movesHead; record !== null; record = record._nextMoved) {
|
||||
fn(record);
|
||||
}
|
||||
}
|
||||
|
||||
forEachRemovedItem(fn: Function) {
|
||||
var record: CollectionChangeRecord;
|
||||
let record: CollectionChangeRecord;
|
||||
for (record = this._removalsHead; record !== null; record = record._nextRemoved) {
|
||||
fn(record);
|
||||
}
|
||||
}
|
||||
|
||||
forEachIdentityChange(fn: Function) {
|
||||
var record: CollectionChangeRecord;
|
||||
let record: CollectionChangeRecord;
|
||||
for (record = this._identityChangesHead; record !== null; record = record._nextIdentityChange) {
|
||||
fn(record);
|
||||
}
|
||||
@ -165,11 +165,11 @@ export class DefaultIterableDiffer implements IterableDiffer {
|
||||
check(collection: any): boolean {
|
||||
this._reset();
|
||||
|
||||
var record: CollectionChangeRecord = this._itHead;
|
||||
var mayBeDirty: boolean = false;
|
||||
var index: number;
|
||||
var item: any;
|
||||
var itemTrackBy: any;
|
||||
let record: CollectionChangeRecord = this._itHead;
|
||||
let mayBeDirty: boolean = false;
|
||||
let index: number;
|
||||
let item: any;
|
||||
let itemTrackBy: any;
|
||||
if (Array.isArray(collection)) {
|
||||
const list = collection;
|
||||
this._length = collection.length;
|
||||
@ -233,8 +233,8 @@ export class DefaultIterableDiffer implements IterableDiffer {
|
||||
*/
|
||||
_reset() {
|
||||
if (this.isDirty) {
|
||||
var record: CollectionChangeRecord;
|
||||
var nextRecord: CollectionChangeRecord;
|
||||
let record: CollectionChangeRecord;
|
||||
let nextRecord: CollectionChangeRecord;
|
||||
|
||||
for (record = this._previousItHead = this._itHead; record !== null; record = record._next) {
|
||||
record._nextPrevious = record._next;
|
||||
@ -271,7 +271,7 @@ export class DefaultIterableDiffer implements IterableDiffer {
|
||||
_mismatch(record: CollectionChangeRecord, item: any, itemTrackBy: any, index: number):
|
||||
CollectionChangeRecord {
|
||||
// The previous record after which we will append the current one.
|
||||
var previousRecord: CollectionChangeRecord;
|
||||
let previousRecord: CollectionChangeRecord;
|
||||
|
||||
if (record === null) {
|
||||
previousRecord = this._itTail;
|
||||
@ -336,7 +336,7 @@ export class DefaultIterableDiffer implements IterableDiffer {
|
||||
*/
|
||||
_verifyReinsertion(record: CollectionChangeRecord, item: any, itemTrackBy: any, index: number):
|
||||
CollectionChangeRecord {
|
||||
var reinsertRecord: CollectionChangeRecord =
|
||||
const reinsertRecord: CollectionChangeRecord =
|
||||
this._unlinkedRecords === null ? null : this._unlinkedRecords.get(itemTrackBy);
|
||||
if (reinsertRecord !== null) {
|
||||
record = this._reinsertAfter(reinsertRecord, record._prev, index);
|
||||
@ -357,7 +357,7 @@ export class DefaultIterableDiffer implements IterableDiffer {
|
||||
_truncate(record: CollectionChangeRecord) {
|
||||
// Anything after that needs to be removed;
|
||||
while (record !== null) {
|
||||
var nextRecord: CollectionChangeRecord = record._next;
|
||||
const nextRecord: CollectionChangeRecord = record._next;
|
||||
this._addToRemovals(this._unlink(record));
|
||||
record = nextRecord;
|
||||
}
|
||||
@ -388,8 +388,8 @@ export class DefaultIterableDiffer implements IterableDiffer {
|
||||
if (this._unlinkedRecords !== null) {
|
||||
this._unlinkedRecords.remove(record);
|
||||
}
|
||||
var prev = record._prevRemoved;
|
||||
var next = record._nextRemoved;
|
||||
const prev = record._prevRemoved;
|
||||
const next = record._nextRemoved;
|
||||
|
||||
if (prev === null) {
|
||||
this._removalsHead = next;
|
||||
@ -442,7 +442,7 @@ export class DefaultIterableDiffer implements IterableDiffer {
|
||||
// assert(record._next === null);
|
||||
// assert(record._prev === null);
|
||||
|
||||
var next: CollectionChangeRecord = prevRecord === null ? this._itHead : prevRecord._next;
|
||||
const next: CollectionChangeRecord = prevRecord === null ? this._itHead : prevRecord._next;
|
||||
// todo(vicb)
|
||||
// assert(next != record);
|
||||
// assert(prevRecord != record);
|
||||
@ -479,8 +479,8 @@ export class DefaultIterableDiffer implements IterableDiffer {
|
||||
this._linkedRecords.remove(record);
|
||||
}
|
||||
|
||||
var prev = record._prev;
|
||||
var next = record._next;
|
||||
const prev = record._prev;
|
||||
const next = record._next;
|
||||
|
||||
// todo(vicb)
|
||||
// assert((record._prev = null) === null);
|
||||
@ -559,22 +559,22 @@ export class DefaultIterableDiffer implements IterableDiffer {
|
||||
|
||||
|
||||
toString(): string {
|
||||
var list: any[] /** TODO #9100 */ = [];
|
||||
const list: any[] /** TODO #9100 */ = [];
|
||||
this.forEachItem((record: any /** TODO #9100 */) => list.push(record));
|
||||
|
||||
var previous: any[] /** TODO #9100 */ = [];
|
||||
const previous: any[] /** TODO #9100 */ = [];
|
||||
this.forEachPreviousItem((record: any /** TODO #9100 */) => previous.push(record));
|
||||
|
||||
var additions: any[] /** TODO #9100 */ = [];
|
||||
const additions: any[] /** TODO #9100 */ = [];
|
||||
this.forEachAddedItem((record: any /** TODO #9100 */) => additions.push(record));
|
||||
|
||||
var moves: any[] /** TODO #9100 */ = [];
|
||||
const moves: any[] /** TODO #9100 */ = [];
|
||||
this.forEachMovedItem((record: any /** TODO #9100 */) => moves.push(record));
|
||||
|
||||
var removals: any[] /** TODO #9100 */ = [];
|
||||
const removals: any[] /** TODO #9100 */ = [];
|
||||
this.forEachRemovedItem((record: any /** TODO #9100 */) => removals.push(record));
|
||||
|
||||
var identityChanges: any[] /** TODO #9100 */ = [];
|
||||
const identityChanges: any[] /** TODO #9100 */ = [];
|
||||
this.forEachIdentityChange((record: any /** TODO #9100 */) => identityChanges.push(record));
|
||||
|
||||
return 'collection: ' + list.join(', ') + '\n' +
|
||||
@ -655,7 +655,7 @@ class _DuplicateItemRecordList {
|
||||
// Returns a CollectionChangeRecord having CollectionChangeRecord.trackById == trackById and
|
||||
// CollectionChangeRecord.currentIndex >= afterIndex
|
||||
get(trackById: any, afterIndex: number): CollectionChangeRecord {
|
||||
var record: CollectionChangeRecord;
|
||||
let record: CollectionChangeRecord;
|
||||
for (record = this._head; record !== null; record = record._nextDup) {
|
||||
if ((afterIndex === null || afterIndex < record.currentIndex) &&
|
||||
looseIdentical(record.trackById, trackById)) {
|
||||
@ -680,8 +680,8 @@ class _DuplicateItemRecordList {
|
||||
// return false;
|
||||
//});
|
||||
|
||||
var prev: CollectionChangeRecord = record._prevDup;
|
||||
var next: CollectionChangeRecord = record._nextDup;
|
||||
const prev: CollectionChangeRecord = record._prevDup;
|
||||
const next: CollectionChangeRecord = record._nextDup;
|
||||
if (prev === null) {
|
||||
this._head = next;
|
||||
} else {
|
||||
@ -746,9 +746,9 @@ class _DuplicateMap {
|
||||
}
|
||||
|
||||
function getPreviousIndex(item: any, addRemoveOffset: number, moveOffsets: number[]): number {
|
||||
var previousIndex = item.previousIndex;
|
||||
const previousIndex = item.previousIndex;
|
||||
if (previousIndex === null) return previousIndex;
|
||||
var moveOffset = 0;
|
||||
let moveOffset = 0;
|
||||
if (moveOffsets && previousIndex < moveOffsets.length) {
|
||||
moveOffset = moveOffsets[previousIndex];
|
||||
}
|
||||
|
@ -37,35 +37,35 @@ export class DefaultKeyValueDiffer implements KeyValueDiffer {
|
||||
}
|
||||
|
||||
forEachItem(fn: (r: KeyValueChangeRecord) => void) {
|
||||
var record: KeyValueChangeRecord;
|
||||
let record: KeyValueChangeRecord;
|
||||
for (record = this._mapHead; record !== null; record = record._next) {
|
||||
fn(record);
|
||||
}
|
||||
}
|
||||
|
||||
forEachPreviousItem(fn: (r: KeyValueChangeRecord) => void) {
|
||||
var record: KeyValueChangeRecord;
|
||||
let record: KeyValueChangeRecord;
|
||||
for (record = this._previousMapHead; record !== null; record = record._nextPrevious) {
|
||||
fn(record);
|
||||
}
|
||||
}
|
||||
|
||||
forEachChangedItem(fn: (r: KeyValueChangeRecord) => void) {
|
||||
var record: KeyValueChangeRecord;
|
||||
let record: KeyValueChangeRecord;
|
||||
for (record = this._changesHead; record !== null; record = record._nextChanged) {
|
||||
fn(record);
|
||||
}
|
||||
}
|
||||
|
||||
forEachAddedItem(fn: (r: KeyValueChangeRecord) => void) {
|
||||
var record: KeyValueChangeRecord;
|
||||
let record: KeyValueChangeRecord;
|
||||
for (record = this._additionsHead; record !== null; record = record._nextAdded) {
|
||||
fn(record);
|
||||
}
|
||||
}
|
||||
|
||||
forEachRemovedItem(fn: (r: KeyValueChangeRecord) => void) {
|
||||
var record: KeyValueChangeRecord;
|
||||
let record: KeyValueChangeRecord;
|
||||
for (record = this._removalsHead; record !== null; record = record._nextRemoved) {
|
||||
fn(record);
|
||||
}
|
||||
@ -85,7 +85,7 @@ export class DefaultKeyValueDiffer implements KeyValueDiffer {
|
||||
|
||||
check(map: Map<any, any>|{[k: string]: any}): boolean {
|
||||
this._reset();
|
||||
let records = this._records;
|
||||
const records = this._records;
|
||||
let oldSeqRecord: KeyValueChangeRecord = this._mapHead;
|
||||
let lastOldSeqRecord: KeyValueChangeRecord = null;
|
||||
let lastNewSeqRecord: KeyValueChangeRecord = null;
|
||||
@ -162,7 +162,7 @@ export class DefaultKeyValueDiffer implements KeyValueDiffer {
|
||||
} else {
|
||||
lastRecord._next = null;
|
||||
}
|
||||
var nextRecord = record._next;
|
||||
const nextRecord = record._next;
|
||||
this._addToRemovals(record);
|
||||
lastRecord = record;
|
||||
record = nextRecord;
|
||||
@ -202,7 +202,7 @@ export class DefaultKeyValueDiffer implements KeyValueDiffer {
|
||||
|
||||
/** @internal */
|
||||
_removeFromSeq(prev: KeyValueChangeRecord, record: KeyValueChangeRecord) {
|
||||
var next = record._next;
|
||||
const next = record._next;
|
||||
if (prev === null) {
|
||||
this._mapHead = next;
|
||||
} else {
|
||||
|
@ -50,7 +50,7 @@ export class IterableDiffers {
|
||||
|
||||
static create(factories: IterableDifferFactory[], parent?: IterableDiffers): IterableDiffers {
|
||||
if (isPresent(parent)) {
|
||||
var copied = parent.factories.slice();
|
||||
const copied = parent.factories.slice();
|
||||
factories = factories.concat(copied);
|
||||
return new IterableDiffers(factories);
|
||||
} else {
|
||||
@ -95,7 +95,7 @@ export class IterableDiffers {
|
||||
}
|
||||
|
||||
find(iterable: any): IterableDifferFactory {
|
||||
var factory = this.factories.find(f => f.supports(iterable));
|
||||
const factory = this.factories.find(f => f.supports(iterable));
|
||||
if (isPresent(factory)) {
|
||||
return factory;
|
||||
} else {
|
||||
|
@ -41,7 +41,7 @@ export class KeyValueDiffers {
|
||||
|
||||
static create(factories: KeyValueDifferFactory[], parent?: KeyValueDiffers): KeyValueDiffers {
|
||||
if (isPresent(parent)) {
|
||||
var copied = parent.factories.slice();
|
||||
const copied = parent.factories.slice();
|
||||
factories = factories.concat(copied);
|
||||
return new KeyValueDiffers(factories);
|
||||
} else {
|
||||
@ -86,7 +86,7 @@ export class KeyValueDiffers {
|
||||
}
|
||||
|
||||
find(kv: Object): KeyValueDifferFactory {
|
||||
var factory = this.factories.find(f => f.supports(kv));
|
||||
const factory = this.factories.find(f => f.supports(kv));
|
||||
if (isPresent(factory)) {
|
||||
return factory;
|
||||
} else {
|
||||
|
@ -26,15 +26,15 @@ export class DebugDomRenderer implements Renderer {
|
||||
constructor(private _delegate: Renderer) {}
|
||||
|
||||
selectRootElement(selectorOrNode: string|any, debugInfo?: RenderDebugInfo): any {
|
||||
var nativeEl = this._delegate.selectRootElement(selectorOrNode, debugInfo);
|
||||
var debugEl = new DebugElement(nativeEl, null, debugInfo);
|
||||
const nativeEl = this._delegate.selectRootElement(selectorOrNode, debugInfo);
|
||||
const debugEl = new DebugElement(nativeEl, null, debugInfo);
|
||||
indexDebugNode(debugEl);
|
||||
return nativeEl;
|
||||
}
|
||||
|
||||
createElement(parentElement: any, name: string, debugInfo?: RenderDebugInfo): any {
|
||||
var nativeEl = this._delegate.createElement(parentElement, name, debugInfo);
|
||||
var debugEl = new DebugElement(nativeEl, getDebugNode(parentElement), debugInfo);
|
||||
const nativeEl = this._delegate.createElement(parentElement, name, debugInfo);
|
||||
const debugEl = new DebugElement(nativeEl, getDebugNode(parentElement), debugInfo);
|
||||
debugEl.name = name;
|
||||
indexDebugNode(debugEl);
|
||||
return nativeEl;
|
||||
@ -43,34 +43,34 @@ export class DebugDomRenderer implements Renderer {
|
||||
createViewRoot(hostElement: any): any { return this._delegate.createViewRoot(hostElement); }
|
||||
|
||||
createTemplateAnchor(parentElement: any, debugInfo?: RenderDebugInfo): any {
|
||||
var comment = this._delegate.createTemplateAnchor(parentElement, debugInfo);
|
||||
var debugEl = new DebugNode(comment, getDebugNode(parentElement), debugInfo);
|
||||
const comment = this._delegate.createTemplateAnchor(parentElement, debugInfo);
|
||||
const debugEl = new DebugNode(comment, getDebugNode(parentElement), debugInfo);
|
||||
indexDebugNode(debugEl);
|
||||
return comment;
|
||||
}
|
||||
|
||||
createText(parentElement: any, value: string, debugInfo?: RenderDebugInfo): any {
|
||||
var text = this._delegate.createText(parentElement, value, debugInfo);
|
||||
var debugEl = new DebugNode(text, getDebugNode(parentElement), debugInfo);
|
||||
const text = this._delegate.createText(parentElement, value, debugInfo);
|
||||
const debugEl = new DebugNode(text, getDebugNode(parentElement), debugInfo);
|
||||
indexDebugNode(debugEl);
|
||||
return text;
|
||||
}
|
||||
|
||||
projectNodes(parentElement: any, nodes: any[]) {
|
||||
var debugParent = getDebugNode(parentElement);
|
||||
const debugParent = getDebugNode(parentElement);
|
||||
if (isPresent(debugParent) && debugParent instanceof DebugElement) {
|
||||
let debugElement = debugParent;
|
||||
const debugElement = debugParent;
|
||||
nodes.forEach((node) => { debugElement.addChild(getDebugNode(node)); });
|
||||
}
|
||||
this._delegate.projectNodes(parentElement, nodes);
|
||||
}
|
||||
|
||||
attachViewAfter(node: any, viewRootNodes: any[]) {
|
||||
var debugNode = getDebugNode(node);
|
||||
const debugNode = getDebugNode(node);
|
||||
if (isPresent(debugNode)) {
|
||||
var debugParent = debugNode.parent;
|
||||
const debugParent = debugNode.parent;
|
||||
if (viewRootNodes.length > 0 && isPresent(debugParent)) {
|
||||
var debugViewRootNodes: DebugNode[] = [];
|
||||
const debugViewRootNodes: DebugNode[] = [];
|
||||
viewRootNodes.forEach((rootNode) => debugViewRootNodes.push(getDebugNode(rootNode)));
|
||||
debugParent.insertChildrenAfter(debugNode, debugViewRootNodes);
|
||||
}
|
||||
@ -80,7 +80,7 @@ export class DebugDomRenderer implements Renderer {
|
||||
|
||||
detachView(viewRootNodes: any[]) {
|
||||
viewRootNodes.forEach((node) => {
|
||||
var debugNode = getDebugNode(node);
|
||||
const debugNode = getDebugNode(node);
|
||||
if (isPresent(debugNode) && isPresent(debugNode.parent)) {
|
||||
debugNode.parent.removeChild(debugNode);
|
||||
}
|
||||
@ -95,7 +95,7 @@ export class DebugDomRenderer implements Renderer {
|
||||
}
|
||||
|
||||
listen(renderElement: any, name: string, callback: Function): Function {
|
||||
var debugEl = getDebugNode(renderElement);
|
||||
const debugEl = getDebugNode(renderElement);
|
||||
if (isPresent(debugEl)) {
|
||||
debugEl.listeners.push(new EventListener(name, callback));
|
||||
}
|
||||
@ -107,7 +107,7 @@ export class DebugDomRenderer implements Renderer {
|
||||
}
|
||||
|
||||
setElementProperty(renderElement: any, propertyName: string, propertyValue: any) {
|
||||
var debugEl = getDebugNode(renderElement);
|
||||
const debugEl = getDebugNode(renderElement);
|
||||
if (isPresent(debugEl) && debugEl instanceof DebugElement) {
|
||||
debugEl.properties[propertyName] = propertyValue;
|
||||
}
|
||||
@ -115,7 +115,7 @@ export class DebugDomRenderer implements Renderer {
|
||||
}
|
||||
|
||||
setElementAttribute(renderElement: any, attributeName: string, attributeValue: string) {
|
||||
var debugEl = getDebugNode(renderElement);
|
||||
const debugEl = getDebugNode(renderElement);
|
||||
if (isPresent(debugEl) && debugEl instanceof DebugElement) {
|
||||
debugEl.attributes[attributeName] = attributeValue;
|
||||
}
|
||||
@ -127,7 +127,7 @@ export class DebugDomRenderer implements Renderer {
|
||||
}
|
||||
|
||||
setElementClass(renderElement: any, className: string, isAdd: boolean) {
|
||||
var debugEl = getDebugNode(renderElement);
|
||||
const debugEl = getDebugNode(renderElement);
|
||||
if (isPresent(debugEl) && debugEl instanceof DebugElement) {
|
||||
debugEl.classes[className] = isAdd;
|
||||
}
|
||||
@ -135,7 +135,7 @@ export class DebugDomRenderer implements Renderer {
|
||||
}
|
||||
|
||||
setElementStyle(renderElement: any, styleName: string, styleValue: string) {
|
||||
var debugEl = getDebugNode(renderElement);
|
||||
const debugEl = getDebugNode(renderElement);
|
||||
if (isPresent(debugEl) && debugEl instanceof DebugElement) {
|
||||
debugEl.styles[styleName] = styleValue;
|
||||
}
|
||||
|
@ -14,8 +14,8 @@ import {ReflectiveInjector} from './reflective_injector';
|
||||
import {ReflectiveKey} from './reflective_key';
|
||||
|
||||
function findFirstClosedCycle(keys: any[]): any[] {
|
||||
var res: any[] = [];
|
||||
for (var i = 0; i < keys.length; ++i) {
|
||||
const res: any[] = [];
|
||||
for (let i = 0; i < keys.length; ++i) {
|
||||
if (res.indexOf(keys[i]) > -1) {
|
||||
res.push(keys[i]);
|
||||
return res;
|
||||
@ -166,7 +166,7 @@ export class InstantiationError extends WrappedError {
|
||||
}
|
||||
|
||||
get message(): string {
|
||||
var first = stringify(this.keys[0].token);
|
||||
const first = stringify(this.keys[0].token);
|
||||
return `${this.originalError.message}: Error during instantiation of ${first}!${constructResolvingPath(this.keys)}.`;
|
||||
}
|
||||
|
||||
@ -225,9 +225,9 @@ export class NoAnnotationError extends BaseError {
|
||||
}
|
||||
|
||||
private static _genMessage(typeOrFunc: Type<any>|Function, params: any[][]) {
|
||||
var signature: string[] = [];
|
||||
for (var i = 0, ii = params.length; i < ii; i++) {
|
||||
var parameter = params[i];
|
||||
const signature: string[] = [];
|
||||
for (let i = 0, ii = params.length; i < ii; i++) {
|
||||
const parameter = params[i];
|
||||
if (!parameter || parameter.length == 0) {
|
||||
signature.push('?');
|
||||
} else {
|
||||
|
@ -49,7 +49,7 @@ export class ReflectiveProtoInjectorInlineStrategy implements ReflectiveProtoInj
|
||||
keyId9: number = null;
|
||||
|
||||
constructor(protoEI: ReflectiveProtoInjector, providers: ResolvedReflectiveProvider[]) {
|
||||
var length = providers.length;
|
||||
const length = providers.length;
|
||||
|
||||
if (length > 0) {
|
||||
this.provider0 = providers[0];
|
||||
@ -116,11 +116,11 @@ export class ReflectiveProtoInjectorDynamicStrategy implements ReflectiveProtoIn
|
||||
keyIds: number[];
|
||||
|
||||
constructor(protoInj: ReflectiveProtoInjector, public providers: ResolvedReflectiveProvider[]) {
|
||||
var len = providers.length;
|
||||
const len = providers.length;
|
||||
|
||||
this.keyIds = new Array(len);
|
||||
|
||||
for (var i = 0; i < len; i++) {
|
||||
for (let i = 0; i < len; i++) {
|
||||
this.keyIds[i] = providers[i].key.id;
|
||||
}
|
||||
}
|
||||
@ -192,8 +192,8 @@ export class ReflectiveInjectorInlineStrategy implements ReflectiveInjectorStrat
|
||||
}
|
||||
|
||||
getObjByKeyId(keyId: number): any {
|
||||
var p = this.protoStrategy;
|
||||
var inj = this.injector;
|
||||
const p = this.protoStrategy;
|
||||
const inj = this.injector;
|
||||
|
||||
if (p.keyId0 === keyId) {
|
||||
if (this.obj0 === UNDEFINED) {
|
||||
@ -419,7 +419,7 @@ export abstract class ReflectiveInjector implements Injector {
|
||||
* See {@link Injector#resolve} and {@link Injector#fromResolvedProviders}.
|
||||
*/
|
||||
static resolveAndCreate(providers: Provider[], parent: Injector = null): ReflectiveInjector {
|
||||
var ResolvedReflectiveProviders = ReflectiveInjector.resolve(providers);
|
||||
const ResolvedReflectiveProviders = ReflectiveInjector.resolve(providers);
|
||||
return ReflectiveInjector.fromResolvedProviders(ResolvedReflectiveProviders, parent);
|
||||
}
|
||||
|
||||
@ -615,13 +615,13 @@ export class ReflectiveInjector_ implements ReflectiveInjector {
|
||||
get internalStrategy(): any { return this._strategy; }
|
||||
|
||||
resolveAndCreateChild(providers: Provider[]): ReflectiveInjector {
|
||||
var ResolvedReflectiveProviders = ReflectiveInjector.resolve(providers);
|
||||
const ResolvedReflectiveProviders = ReflectiveInjector.resolve(providers);
|
||||
return this.createChildFromResolved(ResolvedReflectiveProviders);
|
||||
}
|
||||
|
||||
createChildFromResolved(providers: ResolvedReflectiveProvider[]): ReflectiveInjector {
|
||||
var proto = new ReflectiveProtoInjector(providers);
|
||||
var inj = new ReflectiveInjector_(proto);
|
||||
const proto = new ReflectiveProtoInjector(providers);
|
||||
const inj = new ReflectiveInjector_(proto);
|
||||
inj._parent = this;
|
||||
return inj;
|
||||
}
|
||||
@ -644,8 +644,8 @@ export class ReflectiveInjector_ implements ReflectiveInjector {
|
||||
|
||||
private _instantiateProvider(provider: ResolvedReflectiveProvider): any {
|
||||
if (provider.multiProvider) {
|
||||
var res = new Array(provider.resolvedFactories.length);
|
||||
for (var i = 0; i < provider.resolvedFactories.length; ++i) {
|
||||
const res = new Array(provider.resolvedFactories.length);
|
||||
for (let i = 0; i < provider.resolvedFactories.length; ++i) {
|
||||
res[i] = this._instantiate(provider, provider.resolvedFactories[i]);
|
||||
}
|
||||
return res;
|
||||
@ -657,30 +657,30 @@ export class ReflectiveInjector_ implements ReflectiveInjector {
|
||||
private _instantiate(
|
||||
provider: ResolvedReflectiveProvider,
|
||||
ResolvedReflectiveFactory: ResolvedReflectiveFactory): any {
|
||||
var factory = ResolvedReflectiveFactory.factory;
|
||||
var deps = ResolvedReflectiveFactory.dependencies;
|
||||
var length = deps.length;
|
||||
const factory = ResolvedReflectiveFactory.factory;
|
||||
const deps = ResolvedReflectiveFactory.dependencies;
|
||||
const length = deps.length;
|
||||
|
||||
var d0: any;
|
||||
var d1: any;
|
||||
var d2: any;
|
||||
var d3: any;
|
||||
var d4: any;
|
||||
var d5: any;
|
||||
var d6: any;
|
||||
var d7: any;
|
||||
var d8: any;
|
||||
var d9: any;
|
||||
var d10: any;
|
||||
var d11: any;
|
||||
var d12: any;
|
||||
var d13: any;
|
||||
var d14: any;
|
||||
var d15: any;
|
||||
var d16: any;
|
||||
var d17: any;
|
||||
var d18: any;
|
||||
var d19: any;
|
||||
let d0: any;
|
||||
let d1: any;
|
||||
let d2: any;
|
||||
let d3: any;
|
||||
let d4: any;
|
||||
let d5: any;
|
||||
let d6: any;
|
||||
let d7: any;
|
||||
let d8: any;
|
||||
let d9: any;
|
||||
let d10: any;
|
||||
let d11: any;
|
||||
let d12: any;
|
||||
let d13: any;
|
||||
let d14: any;
|
||||
let d15: any;
|
||||
let d16: any;
|
||||
let d17: any;
|
||||
let d18: any;
|
||||
let d19: any;
|
||||
try {
|
||||
d0 = length > 0 ? this._getByReflectiveDependency(provider, deps[0]) : null;
|
||||
d1 = length > 1 ? this._getByReflectiveDependency(provider, deps[1]) : null;
|
||||
@ -709,7 +709,7 @@ export class ReflectiveInjector_ implements ReflectiveInjector {
|
||||
throw e;
|
||||
}
|
||||
|
||||
var obj: any;
|
||||
let obj: any;
|
||||
try {
|
||||
switch (length) {
|
||||
case 0:
|
||||
@ -822,13 +822,13 @@ export class ReflectiveInjector_ implements ReflectiveInjector {
|
||||
|
||||
/** @internal */
|
||||
_getByKeySelf(key: ReflectiveKey, notFoundValue: any): any {
|
||||
var obj = this._strategy.getObjByKeyId(key.id);
|
||||
const obj = this._strategy.getObjByKeyId(key.id);
|
||||
return (obj !== UNDEFINED) ? obj : this._throwOrNull(key, notFoundValue);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
_getByKeyDefault(key: ReflectiveKey, notFoundValue: any, lowerBoundVisibility: Object): any {
|
||||
var inj: Injector;
|
||||
let inj: Injector;
|
||||
|
||||
if (lowerBoundVisibility instanceof SkipSelf) {
|
||||
inj = this._parent;
|
||||
@ -837,8 +837,8 @@ export class ReflectiveInjector_ implements ReflectiveInjector {
|
||||
}
|
||||
|
||||
while (inj instanceof ReflectiveInjector_) {
|
||||
var inj_ = <ReflectiveInjector_>inj;
|
||||
var obj = inj_._strategy.getObjByKeyId(key.id);
|
||||
const inj_ = <ReflectiveInjector_>inj;
|
||||
const obj = inj_._strategy.getObjByKeyId(key.id);
|
||||
if (obj !== UNDEFINED) return obj;
|
||||
inj = inj_._parent;
|
||||
}
|
||||
@ -859,11 +859,11 @@ export class ReflectiveInjector_ implements ReflectiveInjector {
|
||||
toString(): string { return this.displayName; }
|
||||
}
|
||||
|
||||
var INJECTOR_KEY = ReflectiveKey.get(Injector);
|
||||
const INJECTOR_KEY = ReflectiveKey.get(Injector);
|
||||
|
||||
function _mapProviders(injector: ReflectiveInjector_, fn: Function): any[] {
|
||||
var res: any[] = new Array(injector._proto.numberOfProviders);
|
||||
for (var i = 0; i < injector._proto.numberOfProviders; ++i) {
|
||||
const res: any[] = new Array(injector._proto.numberOfProviders);
|
||||
for (let i = 0; i < injector._proto.numberOfProviders; ++i) {
|
||||
res[i] = fn(injector._proto.getProviderAtIndex(i));
|
||||
}
|
||||
return res;
|
||||
|
@ -68,7 +68,7 @@ export class KeyRegistry {
|
||||
return this._allKeys.get(token);
|
||||
}
|
||||
|
||||
var newKey = new ReflectiveKey(token, ReflectiveKey.numberOfKeys);
|
||||
const newKey = new ReflectiveKey(token, ReflectiveKey.numberOfKeys);
|
||||
this._allKeys.set(token, newKey);
|
||||
return newKey;
|
||||
}
|
||||
@ -76,4 +76,4 @@ export class KeyRegistry {
|
||||
get numberOfKeys(): number { return this._allKeys.size; }
|
||||
}
|
||||
|
||||
var _globalKeyRegistry = new KeyRegistry();
|
||||
const _globalKeyRegistry = new KeyRegistry();
|
||||
|
@ -235,7 +235,7 @@ function _extractToken(
|
||||
let upperBoundVisibility: any = null;
|
||||
|
||||
for (let i = 0; i < metadata.length; ++i) {
|
||||
let paramMetadata = metadata[i];
|
||||
const paramMetadata = metadata[i];
|
||||
|
||||
if (paramMetadata instanceof Type) {
|
||||
token = paramMetadata;
|
||||
|
@ -15,7 +15,7 @@ export class AnimationViewContext {
|
||||
private _players = new ViewAnimationMap();
|
||||
|
||||
onAllActiveAnimationsDone(callback: () => any): void {
|
||||
var activeAnimationPlayers = this._players.getAllPlayers();
|
||||
const activeAnimationPlayers = this._players.getAllPlayers();
|
||||
// we check for the length to avoid having GroupAnimationPlayer
|
||||
// issue an unnecessary microtask when zero players are passed in
|
||||
if (activeAnimationPlayers.length) {
|
||||
@ -35,7 +35,7 @@ export class AnimationViewContext {
|
||||
if (removeAllAnimations) {
|
||||
this._players.findAllPlayersByElement(element).forEach(player => player.destroy());
|
||||
} else {
|
||||
var player = this._players.find(element, animationName);
|
||||
const player = this._players.find(element, animationName);
|
||||
if (player) {
|
||||
player.destroy();
|
||||
}
|
||||
|
@ -107,11 +107,11 @@ export class ComponentFactory<C> {
|
||||
create(
|
||||
injector: Injector, projectableNodes: any[][] = null,
|
||||
rootSelectorOrNode: string|any = null): ComponentRef<C> {
|
||||
var vu: ViewUtils = injector.get(ViewUtils);
|
||||
const vu: ViewUtils = injector.get(ViewUtils);
|
||||
if (!projectableNodes) {
|
||||
projectableNodes = [];
|
||||
}
|
||||
var hostView: AppView<any> = new this._viewClass(vu, null, null, null);
|
||||
const hostView: AppView<any> = new this._viewClass(vu, null, null, null);
|
||||
return hostView.createHostView(rootSelectorOrNode, injector, projectableNodes);
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ export class CodegenComponentFactoryResolver implements ComponentFactoryResolver
|
||||
|
||||
constructor(factories: ComponentFactory<any>[], private _parent: ComponentFactoryResolver) {
|
||||
for (let i = 0; i < factories.length; i++) {
|
||||
let factory = factories[i];
|
||||
const factory = factories[i];
|
||||
this._factories.set(factory.componentType, factory);
|
||||
}
|
||||
}
|
||||
|
@ -31,14 +31,14 @@ export class DebugContext implements RenderDebugInfo {
|
||||
|
||||
get context() { return this._view.context; }
|
||||
get component() {
|
||||
var staticNodeInfo = this._staticNodeInfo;
|
||||
const staticNodeInfo = this._staticNodeInfo;
|
||||
if (isPresent(staticNodeInfo) && isPresent(staticNodeInfo.componentToken)) {
|
||||
return this.injector.get(staticNodeInfo.componentToken);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
get componentRenderElement() {
|
||||
var componentView = this._view;
|
||||
let componentView = this._view;
|
||||
while (isPresent(componentView.parentView) && componentView.type !== ViewType.COMPONENT) {
|
||||
componentView = <DebugAppView<any>>componentView.parentView;
|
||||
}
|
||||
@ -53,17 +53,17 @@ export class DebugContext implements RenderDebugInfo {
|
||||
}
|
||||
}
|
||||
get providerTokens(): any[] {
|
||||
var staticNodeInfo = this._staticNodeInfo;
|
||||
const staticNodeInfo = this._staticNodeInfo;
|
||||
return isPresent(staticNodeInfo) ? staticNodeInfo.providerTokens : null;
|
||||
}
|
||||
get source(): string {
|
||||
return `${this._view.componentType.templateUrl}:${this._tplRow}:${this._tplCol}`;
|
||||
}
|
||||
get references(): {[key: string]: any} {
|
||||
var varValues: {[key: string]: string} = {};
|
||||
var staticNodeInfo = this._staticNodeInfo;
|
||||
const varValues: {[key: string]: string} = {};
|
||||
const staticNodeInfo = this._staticNodeInfo;
|
||||
if (isPresent(staticNodeInfo)) {
|
||||
var refs = staticNodeInfo.refTokens;
|
||||
const refs = staticNodeInfo.refTokens;
|
||||
Object.keys(refs).forEach(refName => {
|
||||
const refToken = refs[refName];
|
||||
let varValue: any;
|
||||
|
@ -65,7 +65,7 @@ export class NgModuleFactory<T> {
|
||||
if (!parentInjector) {
|
||||
parentInjector = Injector.NULL;
|
||||
}
|
||||
var instance = new this._injectorClass(parentInjector);
|
||||
const instance = new this._injectorClass(parentInjector);
|
||||
instance.create();
|
||||
return instance;
|
||||
}
|
||||
@ -95,7 +95,7 @@ export abstract class NgModuleInjector<T> extends CodegenComponentFactoryResolve
|
||||
if (token === Injector || token === ComponentFactoryResolver) {
|
||||
return this;
|
||||
}
|
||||
var result = this.getInternal(token, _UNDEFINED);
|
||||
const result = this.getInternal(token, _UNDEFINED);
|
||||
return result === _UNDEFINED ? this.parent.get(token, notFoundValue) : result;
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ let moduleFactories = new Map<string, NgModuleFactory<any>>();
|
||||
* @experimental
|
||||
*/
|
||||
export function registerModuleFactory(id: string, factory: NgModuleFactory<any>) {
|
||||
let existing = moduleFactories.get(id);
|
||||
const existing = moduleFactories.get(id);
|
||||
if (existing) {
|
||||
throw new Error(`Duplicate module registered for ${id
|
||||
} - ${existing.moduleType.name} vs ${factory.moduleType.name}`);
|
||||
@ -42,7 +42,7 @@ export function clearModulesForTest() {
|
||||
* @experimental
|
||||
*/
|
||||
export function getModuleFactory(id: string): NgModuleFactory<any> {
|
||||
let factory = moduleFactories.get(id);
|
||||
const factory = moduleFactories.get(id);
|
||||
if (!factory) throw new Error(`No module with ID ${id} loaded`);
|
||||
return factory;
|
||||
}
|
||||
|
@ -59,7 +59,9 @@ export class SystemJsNgModuleLoader implements NgModuleFactoryLoader {
|
||||
|
||||
private loadAndCompile(path: string): Promise<NgModuleFactory<any>> {
|
||||
let [module, exportName] = path.split(_SEPARATOR);
|
||||
if (exportName === undefined) exportName = 'default';
|
||||
if (exportName === undefined) {
|
||||
exportName = 'default';
|
||||
}
|
||||
|
||||
return System.import(module)
|
||||
.then((module: any) => module[exportName])
|
||||
|
@ -23,7 +23,7 @@ import {ViewRef_} from './view_ref';
|
||||
import {ViewType} from './view_type';
|
||||
import {ViewUtils, addToArray} from './view_utils';
|
||||
|
||||
var _scope_check: WtfScopeFn = wtfCreateScope(`AppView#check(ascii id)`);
|
||||
const _scope_check: WtfScopeFn = wtfCreateScope(`AppView#check(ascii id)`);
|
||||
|
||||
/**
|
||||
* @experimental
|
||||
@ -150,9 +150,9 @@ export abstract class AppView<T> {
|
||||
if (this.cdMode === ChangeDetectorStatus.Destroyed) {
|
||||
return;
|
||||
}
|
||||
var hostElement = this.type === ViewType.COMPONENT ? this.parentElement : null;
|
||||
const hostElement = this.type === ViewType.COMPONENT ? this.parentElement : null;
|
||||
if (this.disposables) {
|
||||
for (var i = 0; i < this.disposables.length; i++) {
|
||||
for (let i = 0; i < this.disposables.length; i++) {
|
||||
this.disposables[i]();
|
||||
}
|
||||
}
|
||||
@ -266,7 +266,7 @@ export abstract class AppView<T> {
|
||||
case ViewType.COMPONENT:
|
||||
if (this.parentView.type === ViewType.HOST) {
|
||||
const nodes = this.parentView._hostProjectableNodes[ngContentIndex] || [];
|
||||
for (var i = 0; i < nodes.length; i++) {
|
||||
for (let i = 0; i < nodes.length; i++) {
|
||||
cb(nodes[i], c);
|
||||
}
|
||||
} else {
|
||||
@ -293,7 +293,7 @@ export abstract class AppView<T> {
|
||||
dirtyParentQueriesInternal(): void {}
|
||||
|
||||
detectChanges(throwOnChange: boolean): void {
|
||||
var s = _scope_check(this.clazz);
|
||||
const s = _scope_check(this.clazz);
|
||||
if (this.cdMode === ChangeDetectorStatus.Checked ||
|
||||
this.cdMode === ChangeDetectorStatus.Errored ||
|
||||
this.cdMode === ChangeDetectorStatus.Detached)
|
||||
@ -429,7 +429,7 @@ export class DebugAppView<T> extends AppView<T> {
|
||||
}
|
||||
|
||||
eventHandler<E, R>(cb: (eventName: string, event?: E) => R): (eventName: string, event?: E) => R {
|
||||
var superHandler = super.eventHandler(cb);
|
||||
const superHandler = super.eventHandler(cb);
|
||||
return (eventName: string, event?: any) => {
|
||||
this._resetDebug();
|
||||
try {
|
||||
|
@ -39,7 +39,7 @@ export class ViewContainer {
|
||||
|
||||
detectChangesInNestedViews(throwOnChange: boolean): void {
|
||||
if (this.nestedViews) {
|
||||
for (var i = 0; i < this.nestedViews.length; i++) {
|
||||
for (let i = 0; i < this.nestedViews.length; i++) {
|
||||
this.nestedViews[i].detectChanges(throwOnChange);
|
||||
}
|
||||
}
|
||||
@ -47,7 +47,7 @@ export class ViewContainer {
|
||||
|
||||
destroyNestedViews(): void {
|
||||
if (this.nestedViews) {
|
||||
for (var i = 0; i < this.nestedViews.length; i++) {
|
||||
for (let i = 0; i < this.nestedViews.length; i++) {
|
||||
this.nestedViews[i].destroy();
|
||||
}
|
||||
}
|
||||
@ -55,16 +55,16 @@ export class ViewContainer {
|
||||
|
||||
visitNestedViewRootNodes<C>(cb: (node: any, ctx: C) => void, c: C): void {
|
||||
if (this.nestedViews) {
|
||||
for (var i = 0; i < this.nestedViews.length; i++) {
|
||||
for (let i = 0; i < this.nestedViews.length; i++) {
|
||||
this.nestedViews[i].visitRootNodesInternal(cb, c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mapNestedViews(nestedViewClass: any, callback: Function): any[] {
|
||||
var result: any[] = [];
|
||||
const result: any[] = [];
|
||||
if (this.nestedViews) {
|
||||
for (var i = 0; i < this.nestedViews.length; i++) {
|
||||
for (let i = 0; i < this.nestedViews.length; i++) {
|
||||
const nestedView = this.nestedViews[i];
|
||||
if (nestedView.clazz === nestedViewClass) {
|
||||
result.push(callback(nestedView));
|
||||
@ -72,7 +72,7 @@ export class ViewContainer {
|
||||
}
|
||||
}
|
||||
if (this.projectedViews) {
|
||||
for (var i = 0; i < this.projectedViews.length; i++) {
|
||||
for (let i = 0; i < this.projectedViews.length; i++) {
|
||||
const projectedView = this.projectedViews[i];
|
||||
if (projectedView.clazz === nestedViewClass) {
|
||||
result.push(callback(projectedView));
|
||||
@ -83,11 +83,11 @@ export class ViewContainer {
|
||||
}
|
||||
|
||||
moveView(view: AppView<any>, currentIndex: number) {
|
||||
var previousIndex = this.nestedViews.indexOf(view);
|
||||
const previousIndex = this.nestedViews.indexOf(view);
|
||||
if (view.type === ViewType.COMPONENT) {
|
||||
throw new Error(`Component views can't be moved!`);
|
||||
}
|
||||
var nestedViews = this.nestedViews;
|
||||
let nestedViews = this.nestedViews;
|
||||
if (nestedViews == null) {
|
||||
nestedViews = [];
|
||||
this.nestedViews = nestedViews;
|
||||
@ -102,7 +102,7 @@ export class ViewContainer {
|
||||
if (view.type === ViewType.COMPONENT) {
|
||||
throw new Error(`Component views can't be moved!`);
|
||||
}
|
||||
var nestedViews = this.nestedViews;
|
||||
let nestedViews = this.nestedViews;
|
||||
if (nestedViews == null) {
|
||||
nestedViews = [];
|
||||
this.nestedViews = nestedViews;
|
||||
|
@ -133,7 +133,7 @@ export class ViewContainerRef_ implements ViewContainerRef {
|
||||
|
||||
get(index: number): ViewRef { return this._element.nestedViews[index].ref; }
|
||||
get length(): number {
|
||||
var views = this._element.nestedViews;
|
||||
const views = this._element.nestedViews;
|
||||
return isPresent(views) ? views.length : 0;
|
||||
}
|
||||
|
||||
@ -147,7 +147,7 @@ export class ViewContainerRef_ implements ViewContainerRef {
|
||||
// to the methods below.
|
||||
createEmbeddedView<C>(templateRef: TemplateRef<C>, context: C = null, index: number = -1):
|
||||
EmbeddedViewRef<C> {
|
||||
var viewRef: EmbeddedViewRef<any> = templateRef.createEmbeddedView(context);
|
||||
const viewRef: EmbeddedViewRef<any> = templateRef.createEmbeddedView(context);
|
||||
this.insert(viewRef, index);
|
||||
return viewRef;
|
||||
}
|
||||
@ -159,9 +159,9 @@ export class ViewContainerRef_ implements ViewContainerRef {
|
||||
createComponent<C>(
|
||||
componentFactory: ComponentFactory<C>, index: number = -1, injector: Injector = null,
|
||||
projectableNodes: any[][] = null): ComponentRef<C> {
|
||||
var s = this._createComponentInContainerScope();
|
||||
var contextInjector = injector || this._element.parentInjector;
|
||||
var componentRef = componentFactory.create(contextInjector, projectableNodes);
|
||||
const s = this._createComponentInContainerScope();
|
||||
const contextInjector = injector || this._element.parentInjector;
|
||||
const componentRef = componentFactory.create(contextInjector, projectableNodes);
|
||||
this.insert(componentRef.hostView, index);
|
||||
return wtfLeave(s, componentRef);
|
||||
}
|
||||
@ -171,17 +171,17 @@ export class ViewContainerRef_ implements ViewContainerRef {
|
||||
|
||||
// TODO(i): refactor insert+remove into move
|
||||
insert(viewRef: ViewRef, index: number = -1): ViewRef {
|
||||
var s = this._insertScope();
|
||||
const s = this._insertScope();
|
||||
if (index == -1) index = this.length;
|
||||
var viewRef_ = <ViewRef_<any>>viewRef;
|
||||
const viewRef_ = <ViewRef_<any>>viewRef;
|
||||
this._element.attachView(viewRef_.internalView, index);
|
||||
return wtfLeave(s, viewRef_);
|
||||
}
|
||||
|
||||
move(viewRef: ViewRef, currentIndex: number): ViewRef {
|
||||
var s = this._insertScope();
|
||||
const s = this._insertScope();
|
||||
if (currentIndex == -1) return;
|
||||
var viewRef_ = <ViewRef_<any>>viewRef;
|
||||
const viewRef_ = <ViewRef_<any>>viewRef;
|
||||
this._element.moveView(viewRef_.internalView, currentIndex);
|
||||
return wtfLeave(s, viewRef_);
|
||||
}
|
||||
|
@ -346,7 +346,7 @@ export function createRenderElement(
|
||||
renderer: Renderer, parentElement: any, name: string, attrs: InlineArray<string>,
|
||||
debugInfo?: RenderDebugInfo): any {
|
||||
const el = renderer.createElement(parentElement, name, debugInfo);
|
||||
for (var i = 0; i < attrs.length; i += 2) {
|
||||
for (let i = 0; i < attrs.length; i += 2) {
|
||||
renderer.setElementAttribute(el, attrs.get(i), attrs.get(i + 1));
|
||||
}
|
||||
return el;
|
||||
@ -355,10 +355,10 @@ export function createRenderElement(
|
||||
export function selectOrCreateRenderHostElement(
|
||||
renderer: Renderer, elementName: string, attrs: InlineArray<string>,
|
||||
rootSelectorOrNode: string | any, debugInfo?: RenderDebugInfo): any {
|
||||
var hostElement: any;
|
||||
let hostElement: any;
|
||||
if (isPresent(rootSelectorOrNode)) {
|
||||
hostElement = renderer.selectRootElement(rootSelectorOrNode, debugInfo);
|
||||
for (var i = 0; i < attrs.length; i += 2) {
|
||||
for (let i = 0; i < attrs.length; i += 2) {
|
||||
renderer.setElementAttribute(hostElement, attrs.get(i), attrs.get(i + 1));
|
||||
}
|
||||
} else {
|
||||
@ -371,7 +371,7 @@ export function subscribeToRenderElement(
|
||||
view: AppView<any>, element: any, eventNamesAndTargets: InlineArray<string>,
|
||||
listener: (eventName: string, event: any) => any) {
|
||||
const disposables = createEmptyInlineArray(eventNamesAndTargets.length / 2);
|
||||
for (var i = 0; i < eventNamesAndTargets.length; i += 2) {
|
||||
for (let i = 0; i < eventNamesAndTargets.length; i += 2) {
|
||||
const eventName = eventNamesAndTargets.get(i);
|
||||
const eventTarget = eventNamesAndTargets.get(i + 1);
|
||||
let disposable: Function;
|
||||
@ -387,7 +387,7 @@ export function subscribeToRenderElement(
|
||||
}
|
||||
|
||||
function disposeInlineArray(disposables: InlineArray<Function>) {
|
||||
for (var i = 0; i < disposables.length; i++) {
|
||||
for (let i = 0; i < disposables.length; i++) {
|
||||
disposables.get(i)();
|
||||
}
|
||||
}
|
||||
|
@ -34,11 +34,11 @@ interface Events {
|
||||
|
||||
export interface Scope { (...args: any[] /** TODO #9100 */): any; }
|
||||
|
||||
var trace: Trace;
|
||||
var events: Events;
|
||||
let trace: Trace;
|
||||
let events: Events;
|
||||
|
||||
export function detectWTF(): boolean {
|
||||
var wtf: WTF = (global as any /** TODO #9100 */)['wtf'];
|
||||
const wtf: WTF = (global as any /** TODO #9100 */)['wtf'];
|
||||
if (wtf) {
|
||||
trace = wtf['trace'];
|
||||
if (trace) {
|
||||
|
@ -23,7 +23,7 @@ export class ReflectionCapabilities implements PlatformReflectionCapabilities {
|
||||
|
||||
/** @internal */
|
||||
_zipTypesAndAnnotations(paramTypes: any[], paramAnnotations: any[]): any[][] {
|
||||
var result: any[][];
|
||||
let result: any[][];
|
||||
|
||||
if (typeof paramTypes === 'undefined') {
|
||||
result = new Array(paramAnnotations.length);
|
||||
@ -31,7 +31,7 @@ export class ReflectionCapabilities implements PlatformReflectionCapabilities {
|
||||
result = new Array(paramTypes.length);
|
||||
}
|
||||
|
||||
for (var i = 0; i < result.length; i++) {
|
||||
for (let i = 0; i < result.length; i++) {
|
||||
// TS outputs Object for parameters without types, while Traceur omits
|
||||
// the annotations. For now we preserve the Traceur behavior to aid
|
||||
// migration, but this can be revisited.
|
||||
|
@ -176,4 +176,4 @@ export function setTestabilityGetter(getter: GetTestability): void {
|
||||
_testabilityGetter = getter;
|
||||
}
|
||||
|
||||
var _testabilityGetter: GetTestability = new _NoopGetTestability();
|
||||
let _testabilityGetter: GetTestability = new _NoopGetTestability();
|
||||
|
@ -238,7 +238,7 @@ export function Class(clsDef: ClassDefinition): Type<any> {
|
||||
}
|
||||
}
|
||||
|
||||
for (let key in clsDef) {
|
||||
for (const key in clsDef) {
|
||||
if (key !== 'extends' && key !== 'prototype' && clsDef.hasOwnProperty(key)) {
|
||||
proto[key] = applyParams(clsDef[key], key);
|
||||
}
|
||||
|
@ -15,9 +15,9 @@ import {beforeEach, describe, expect, it} from '../../testing/testing_internal';
|
||||
|
||||
export function main() {
|
||||
describe('ActiveAnimationsPlayersMap', function() {
|
||||
var playersMap: any /** TODO #9100 */;
|
||||
var elementNode: any /** TODO #9100 */;
|
||||
var animationName = 'animationName';
|
||||
let playersMap: any /** TODO #9100 */;
|
||||
let elementNode: any /** TODO #9100 */;
|
||||
const animationName = 'animationName';
|
||||
|
||||
beforeEach(() => {
|
||||
playersMap = new ViewAnimationMap();
|
||||
@ -30,7 +30,7 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should register a player an allow it to be accessed', () => {
|
||||
var player = new MockAnimationPlayer();
|
||||
const player = new MockAnimationPlayer();
|
||||
playersMap.set(elementNode, animationName, player);
|
||||
|
||||
expect(playersMap.find(elementNode, animationName)).toBe(player);
|
||||
@ -40,7 +40,7 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should remove a registered player when remove() is called', () => {
|
||||
var player = new MockAnimationPlayer();
|
||||
const player = new MockAnimationPlayer();
|
||||
playersMap.set(elementNode, animationName, player);
|
||||
expect(playersMap.find(elementNode, animationName)).toBe(player);
|
||||
expect(countPlayers(playersMap)).toEqual(1);
|
||||
@ -50,8 +50,8 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should allow multiple players to be registered on the same element', () => {
|
||||
var player1 = new MockAnimationPlayer();
|
||||
var player2 = new MockAnimationPlayer();
|
||||
const player1 = new MockAnimationPlayer();
|
||||
const player2 = new MockAnimationPlayer();
|
||||
playersMap.set(elementNode, 'myAnimation1', player1);
|
||||
playersMap.set(elementNode, 'myAnimation2', player2);
|
||||
expect(countPlayers(playersMap)).toEqual(2);
|
||||
@ -59,8 +59,8 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should only allow one player to be set for a given element/animationName pair', () => {
|
||||
var player1 = new MockAnimationPlayer();
|
||||
var player2 = new MockAnimationPlayer();
|
||||
const player1 = new MockAnimationPlayer();
|
||||
const player2 = new MockAnimationPlayer();
|
||||
playersMap.set(elementNode, animationName, player1);
|
||||
expect(playersMap.find(elementNode, animationName)).toBe(player1);
|
||||
expect(countPlayers(playersMap)).toEqual(1);
|
||||
|
@ -13,7 +13,7 @@ import {beforeEach, describe, expect, it} from '../../testing/testing_internal';
|
||||
|
||||
export function main() {
|
||||
describe('AnimationGroupPlayer', function() {
|
||||
var players: any /** TODO #9100 */;
|
||||
let players: any /** TODO #9100 */;
|
||||
beforeEach(() => {
|
||||
players = [
|
||||
new MockAnimationPlayer(),
|
||||
@ -22,10 +22,10 @@ export function main() {
|
||||
];
|
||||
});
|
||||
|
||||
var assertLastStatus =
|
||||
const assertLastStatus =
|
||||
(player: MockAnimationPlayer, status: string, match: boolean, iOffset: number = 0) => {
|
||||
var index = player.log.length - 1 + iOffset;
|
||||
var actual = player.log.length > 0 ? player.log[index] : null;
|
||||
const index = player.log.length - 1 + iOffset;
|
||||
const actual = player.log.length > 0 ? player.log[index] : null;
|
||||
if (match) {
|
||||
expect(actual).toEqual(status);
|
||||
} else {
|
||||
@ -33,12 +33,12 @@ export function main() {
|
||||
}
|
||||
};
|
||||
|
||||
var assertPlaying = (player: MockAnimationPlayer, isPlaying: boolean) => {
|
||||
const assertPlaying = (player: MockAnimationPlayer, isPlaying: boolean) => {
|
||||
assertLastStatus(player, 'play', isPlaying);
|
||||
};
|
||||
|
||||
it('should play and pause all players in parallel', () => {
|
||||
var group = new AnimationGroupPlayer(players);
|
||||
const group = new AnimationGroupPlayer(players);
|
||||
|
||||
assertPlaying(players[0], false);
|
||||
assertPlaying(players[1], false);
|
||||
@ -58,8 +58,8 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should finish when all players have finished', () => {
|
||||
var group = new AnimationGroupPlayer(players);
|
||||
var completed = false;
|
||||
const group = new AnimationGroupPlayer(players);
|
||||
let completed = false;
|
||||
group.onDone(() => completed = true);
|
||||
|
||||
group.play();
|
||||
@ -80,7 +80,7 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should restart all the players', () => {
|
||||
var group = new AnimationGroupPlayer(players);
|
||||
const group = new AnimationGroupPlayer(players);
|
||||
|
||||
group.play();
|
||||
|
||||
@ -96,9 +96,9 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should not destroy the inner the players when finished', () => {
|
||||
var group = new AnimationGroupPlayer(players);
|
||||
const group = new AnimationGroupPlayer(players);
|
||||
|
||||
var completed = false;
|
||||
let completed = false;
|
||||
group.onDone(() => completed = true);
|
||||
|
||||
expect(completed).toBeFalsy();
|
||||
@ -122,8 +122,8 @@ export function main() {
|
||||
|
||||
it('should not call destroy automatically when finished even if a parent player finishes',
|
||||
() => {
|
||||
var group = new AnimationGroupPlayer(players);
|
||||
var parent = new AnimationGroupPlayer([group, new MockAnimationPlayer()]);
|
||||
const group = new AnimationGroupPlayer(players);
|
||||
const parent = new AnimationGroupPlayer([group, new MockAnimationPlayer()]);
|
||||
|
||||
group.play();
|
||||
|
||||
@ -145,7 +145,7 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should function without any players', () => {
|
||||
var group = new AnimationGroupPlayer([]);
|
||||
const group = new AnimationGroupPlayer([]);
|
||||
group.onDone(() => {});
|
||||
group.pause();
|
||||
group.play();
|
||||
@ -155,8 +155,8 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should run the onStart method when started but only once', () => {
|
||||
var player = new AnimationGroupPlayer([]);
|
||||
var calls = 0;
|
||||
const player = new AnimationGroupPlayer([]);
|
||||
let calls = 0;
|
||||
player.onStart(() => calls++);
|
||||
expect(calls).toEqual(0);
|
||||
player.play();
|
||||
@ -167,8 +167,8 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should call onDone after the next microtask if no players are provided', fakeAsync(() => {
|
||||
var group = new AnimationGroupPlayer([]);
|
||||
var completed = false;
|
||||
const group = new AnimationGroupPlayer([]);
|
||||
let completed = false;
|
||||
group.onDone(() => completed = true);
|
||||
expect(completed).toEqual(false);
|
||||
flushMicrotasks();
|
||||
@ -177,11 +177,11 @@ export function main() {
|
||||
|
||||
it('should not allow the player to be destroyed if it already has been destroyed unless reset',
|
||||
fakeAsync(() => {
|
||||
var p1 = new MockAnimationPlayer();
|
||||
var p2 = new MockAnimationPlayer();
|
||||
var innerPlayers = [p1, p2];
|
||||
const p1 = new MockAnimationPlayer();
|
||||
const p2 = new MockAnimationPlayer();
|
||||
const innerPlayers = [p1, p2];
|
||||
|
||||
var groupPlayer = new AnimationGroupPlayer(innerPlayers);
|
||||
const groupPlayer = new AnimationGroupPlayer(innerPlayers);
|
||||
expect(p1.log[p1.log.length - 1]).not.toContain('destroy');
|
||||
expect(p2.log[p2.log.length - 1]).not.toContain('destroy');
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -13,8 +13,8 @@ import {describe, expect, it} from '../../testing/testing_internal';
|
||||
export function main() {
|
||||
describe('NoOpAnimationPlayer', function() {
|
||||
it('should call onDone after the next microtask when constructed', fakeAsync(() => {
|
||||
var player = new NoOpAnimationPlayer();
|
||||
var completed = false;
|
||||
const player = new NoOpAnimationPlayer();
|
||||
let completed = false;
|
||||
player.onDone(() => completed = true);
|
||||
expect(completed).toEqual(false);
|
||||
flushMicrotasks();
|
||||
@ -22,7 +22,7 @@ export function main() {
|
||||
}));
|
||||
|
||||
it('should be able to run each of the player methods', fakeAsync(() => {
|
||||
var player = new NoOpAnimationPlayer();
|
||||
const player = new NoOpAnimationPlayer();
|
||||
player.pause();
|
||||
player.play();
|
||||
player.finish();
|
||||
@ -31,8 +31,8 @@ export function main() {
|
||||
}));
|
||||
|
||||
it('should run the onStart method when started but only once', fakeAsync(() => {
|
||||
var player = new NoOpAnimationPlayer();
|
||||
var calls = 0;
|
||||
const player = new NoOpAnimationPlayer();
|
||||
let calls = 0;
|
||||
player.onStart(() => calls++);
|
||||
expect(calls).toEqual(0);
|
||||
player.play();
|
||||
|
@ -13,7 +13,7 @@ import {beforeEach, describe, expect, it} from '../../testing/testing_internal';
|
||||
|
||||
export function main() {
|
||||
describe('AnimationSequencePlayer', function() {
|
||||
var players: any /** TODO #9100 */;
|
||||
let players: any /** TODO #9100 */;
|
||||
beforeEach(() => {
|
||||
players = [
|
||||
new MockAnimationPlayer(),
|
||||
@ -22,10 +22,10 @@ export function main() {
|
||||
];
|
||||
});
|
||||
|
||||
var assertLastStatus =
|
||||
const assertLastStatus =
|
||||
(player: MockAnimationPlayer, status: string, match: boolean, iOffset: number = 0) => {
|
||||
var index = player.log.length - 1 + iOffset;
|
||||
var actual = player.log.length > 0 ? player.log[index] : null;
|
||||
const index = player.log.length - 1 + iOffset;
|
||||
const actual = player.log.length > 0 ? player.log[index] : null;
|
||||
if (match) {
|
||||
expect(actual).toEqual(status);
|
||||
} else {
|
||||
@ -33,12 +33,12 @@ export function main() {
|
||||
}
|
||||
};
|
||||
|
||||
var assertPlaying = (player: MockAnimationPlayer, isPlaying: boolean) => {
|
||||
const assertPlaying = (player: MockAnimationPlayer, isPlaying: boolean) => {
|
||||
assertLastStatus(player, 'play', isPlaying);
|
||||
};
|
||||
|
||||
it('should pause/play the active player', () => {
|
||||
var sequence = new AnimationSequencePlayer(players);
|
||||
const sequence = new AnimationSequencePlayer(players);
|
||||
|
||||
assertPlaying(players[0], false);
|
||||
assertPlaying(players[1], false);
|
||||
@ -78,9 +78,9 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should finish when all players have finished', () => {
|
||||
var sequence = new AnimationSequencePlayer(players);
|
||||
const sequence = new AnimationSequencePlayer(players);
|
||||
|
||||
var completed = false;
|
||||
let completed = false;
|
||||
sequence.onDone(() => completed = true);
|
||||
sequence.play();
|
||||
|
||||
@ -100,7 +100,7 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should restart all the players', () => {
|
||||
var sequence = new AnimationSequencePlayer(players);
|
||||
const sequence = new AnimationSequencePlayer(players);
|
||||
|
||||
sequence.play();
|
||||
|
||||
@ -122,9 +122,9 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should finish all the players', () => {
|
||||
var sequence = new AnimationSequencePlayer(players);
|
||||
const sequence = new AnimationSequencePlayer(players);
|
||||
|
||||
var completed = false;
|
||||
let completed = false;
|
||||
sequence.onDone(() => completed = true);
|
||||
|
||||
sequence.play();
|
||||
@ -144,8 +144,8 @@ export function main() {
|
||||
|
||||
it('should not call destroy automatically when finished even if a parent player is present',
|
||||
() => {
|
||||
var sequence = new AnimationSequencePlayer(players);
|
||||
var parent = new AnimationSequencePlayer([sequence, new MockAnimationPlayer()]);
|
||||
const sequence = new AnimationSequencePlayer(players);
|
||||
const parent = new AnimationSequencePlayer([sequence, new MockAnimationPlayer()]);
|
||||
|
||||
sequence.play();
|
||||
|
||||
@ -167,7 +167,7 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should function without any players', () => {
|
||||
var sequence = new AnimationSequencePlayer([]);
|
||||
const sequence = new AnimationSequencePlayer([]);
|
||||
sequence.onDone(() => {});
|
||||
sequence.pause();
|
||||
sequence.play();
|
||||
@ -177,8 +177,8 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should run the onStart method when started but only once', () => {
|
||||
var player = new AnimationSequencePlayer([]);
|
||||
var calls = 0;
|
||||
const player = new AnimationSequencePlayer([]);
|
||||
let calls = 0;
|
||||
player.onStart(() => calls++);
|
||||
expect(calls).toEqual(0);
|
||||
player.play();
|
||||
@ -189,8 +189,8 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should call onDone after the next microtask if no players are provided', fakeAsync(() => {
|
||||
var sequence = new AnimationSequencePlayer([]);
|
||||
var completed = false;
|
||||
const sequence = new AnimationSequencePlayer([]);
|
||||
let completed = false;
|
||||
sequence.onDone(() => completed = true);
|
||||
expect(completed).toEqual(false);
|
||||
flushMicrotasks();
|
||||
@ -199,11 +199,11 @@ export function main() {
|
||||
|
||||
it('should not allow the player to be destroyed if it already has been destroyed unless reset',
|
||||
fakeAsync(() => {
|
||||
var p1 = new MockAnimationPlayer();
|
||||
var p2 = new MockAnimationPlayer();
|
||||
var innerPlayers = [p1, p2];
|
||||
const p1 = new MockAnimationPlayer();
|
||||
const p2 = new MockAnimationPlayer();
|
||||
const innerPlayers = [p1, p2];
|
||||
|
||||
var sequencePlayer = new AnimationSequencePlayer(innerPlayers);
|
||||
const sequencePlayer = new AnimationSequencePlayer(innerPlayers);
|
||||
expect(p1.log[p1.log.length - 1]).not.toContain('destroy');
|
||||
expect(p2.log[p2.log.length - 1]).not.toContain('destroy');
|
||||
|
||||
|
@ -19,15 +19,15 @@ export function main() {
|
||||
describe('prepareFinalAnimationStyles', () => {
|
||||
it('should set all non-shared styles to the provided null value between the two sets of styles',
|
||||
() => {
|
||||
var styles = {opacity: 0, color: 'red'};
|
||||
var newStyles = {background: 'red'};
|
||||
var flag = '*';
|
||||
var result = animationUtils.prepareFinalAnimationStyles(styles, newStyles, flag);
|
||||
const styles = {opacity: 0, color: 'red'};
|
||||
const newStyles = {background: 'red'};
|
||||
const flag = '*';
|
||||
const result = animationUtils.prepareFinalAnimationStyles(styles, newStyles, flag);
|
||||
expect(result).toEqual({opacity: flag, color: flag, background: 'red'});
|
||||
});
|
||||
|
||||
it('should handle an empty set of styles', () => {
|
||||
var value = '*';
|
||||
const value = '*';
|
||||
|
||||
expect(animationUtils.prepareFinalAnimationStyles({}, {opacity: '0'}, value)).toEqual({
|
||||
opacity: '0'
|
||||
@ -39,10 +39,10 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should set all AUTO styles to the null value', () => {
|
||||
var styles = {opacity: 0};
|
||||
var newStyles = {color: '*', border: '*'};
|
||||
var flag = '*';
|
||||
var result = animationUtils.prepareFinalAnimationStyles(styles, newStyles, null);
|
||||
const styles = {opacity: 0};
|
||||
const newStyles = {color: '*', border: '*'};
|
||||
const flag = '*';
|
||||
const result = animationUtils.prepareFinalAnimationStyles(styles, newStyles, null);
|
||||
expect(result).toEqual({opacity: null, color: null, border: null});
|
||||
});
|
||||
|
||||
@ -50,17 +50,17 @@ export function main() {
|
||||
|
||||
describe('balanceAnimationKeyframes', () => {
|
||||
it('should balance both the starting and final keyframes with thep provided styles', () => {
|
||||
var collectedStyles = {width: 100, height: 200};
|
||||
const collectedStyles = {width: 100, height: 200};
|
||||
|
||||
var finalStyles = {background: 'red', border: '1px solid black'};
|
||||
const finalStyles = {background: 'red', border: '1px solid black'};
|
||||
|
||||
var keyframes = [
|
||||
const keyframes = [
|
||||
new AnimationKeyframe(0, new AnimationStyles([{height: 100, opacity: 1}])),
|
||||
new AnimationKeyframe(
|
||||
1, new AnimationStyles([{background: 'blue', left: '100px', top: '100px'}]))
|
||||
];
|
||||
|
||||
var result =
|
||||
const result =
|
||||
animationUtils.balanceAnimationKeyframes(collectedStyles, finalStyles, keyframes);
|
||||
|
||||
expect(animationUtils.flattenStyles(result[0].styles.styles)).toEqual({
|
||||
@ -85,12 +85,12 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should perform balancing when no collected and final styles are provided', () => {
|
||||
var keyframes = [
|
||||
const keyframes = [
|
||||
new AnimationKeyframe(0, new AnimationStyles([{height: 100, opacity: 1}])),
|
||||
new AnimationKeyframe(1, new AnimationStyles([{width: 100}]))
|
||||
];
|
||||
|
||||
var result = animationUtils.balanceAnimationKeyframes({}, {}, keyframes);
|
||||
const result = animationUtils.balanceAnimationKeyframes({}, {}, keyframes);
|
||||
|
||||
expect(animationUtils.flattenStyles(result[0].styles.styles))
|
||||
.toEqual({'height': 100, 'opacity': 1, 'width': '*'});
|
||||
@ -102,9 +102,10 @@ export function main() {
|
||||
|
||||
describe('clearStyles', () => {
|
||||
it('should set all the style values to "null"', () => {
|
||||
var styles: {[key: string]: string | number} = {'opacity': 0, 'width': 100, 'color': 'red'};
|
||||
var expectedResult: {[key: string]:
|
||||
string | number} = {'opacity': null, 'width': null, 'color': null};
|
||||
const styles: {[key: string]:
|
||||
string | number} = {'opacity': 0, 'width': 100, 'color': 'red'};
|
||||
const expectedResult: {[key: string]: string |
|
||||
number} = {'opacity': null, 'width': null, 'color': null};
|
||||
expect(animationUtils.clearStyles(styles)).toEqual(expectedResult);
|
||||
});
|
||||
|
||||
@ -114,11 +115,11 @@ export function main() {
|
||||
|
||||
describe('collectAndResolveStyles', () => {
|
||||
it('should keep a record of the styles as they are called', () => {
|
||||
var styles1 = [{'opacity': 0, 'width': 100}];
|
||||
const styles1 = [{'opacity': 0, 'width': 100}];
|
||||
|
||||
var styles2 = [{'height': 999, 'opacity': 1}];
|
||||
const styles2 = [{'height': 999, 'opacity': 1}];
|
||||
|
||||
var collection: {[key: string]: string | number} = {};
|
||||
const collection: {[key: string]: string | number} = {};
|
||||
|
||||
expect(animationUtils.collectAndResolveStyles(collection, styles1)).toEqual(styles1);
|
||||
expect(collection).toEqual({'opacity': 0, 'width': 100});
|
||||
@ -128,11 +129,11 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should resolve styles if they contain a FILL_STYLE_FLAG value', () => {
|
||||
var styles1 = [{'opacity': 0, 'width': FILL_STYLE_FLAG}];
|
||||
const styles1 = [{'opacity': 0, 'width': FILL_STYLE_FLAG}];
|
||||
|
||||
var styles2 = [{'height': 999, 'opacity': FILL_STYLE_FLAG}];
|
||||
const styles2 = [{'height': 999, 'opacity': FILL_STYLE_FLAG}];
|
||||
|
||||
var collection = {};
|
||||
const collection = {};
|
||||
|
||||
expect(animationUtils.collectAndResolveStyles(collection, styles1)).toEqual([
|
||||
{'opacity': 0, 'width': AUTO_STYLE}
|
||||
|
@ -26,8 +26,8 @@ class SomeComponent {
|
||||
|
||||
export function main() {
|
||||
describe('bootstrap', () => {
|
||||
var mockConsole: MockConsole;
|
||||
var fakeDoc: Document;
|
||||
let mockConsole: MockConsole;
|
||||
let fakeDoc: Document;
|
||||
|
||||
beforeEach(() => {
|
||||
fakeDoc = getDOM().createHtmlDocument();
|
||||
@ -74,7 +74,7 @@ export function main() {
|
||||
beforeEach(() => { TestBed.configureTestingModule({imports: [createModule()]}); });
|
||||
|
||||
it('should throw when reentering tick', inject([ApplicationRef], (ref: ApplicationRef_) => {
|
||||
var cdRef = <any>new SpyChangeDetectorRef();
|
||||
const cdRef = <any>new SpyChangeDetectorRef();
|
||||
try {
|
||||
ref.registerChangeDetector(cdRef);
|
||||
cdRef.spy('detectChanges').and.callFake(() => ref.tick());
|
||||
@ -126,14 +126,14 @@ export function main() {
|
||||
});
|
||||
|
||||
describe('bootstrapModule', () => {
|
||||
var defaultPlatform: PlatformRef;
|
||||
let defaultPlatform: PlatformRef;
|
||||
beforeEach(
|
||||
inject([PlatformRef], (_platform: PlatformRef) => { defaultPlatform = _platform; }));
|
||||
|
||||
it('should wait for asynchronous app initializers', async(() => {
|
||||
let resolve: (result: any) => void;
|
||||
let promise: Promise<any> = new Promise((res) => { resolve = res; });
|
||||
var initializerDone = false;
|
||||
const promise: Promise<any> = new Promise((res) => { resolve = res; });
|
||||
let initializerDone = false;
|
||||
setTimeout(() => {
|
||||
resolve(true);
|
||||
initializerDone = true;
|
||||
@ -214,13 +214,13 @@ export function main() {
|
||||
});
|
||||
|
||||
describe('bootstrapModuleFactory', () => {
|
||||
var defaultPlatform: PlatformRef;
|
||||
let defaultPlatform: PlatformRef;
|
||||
beforeEach(
|
||||
inject([PlatformRef], (_platform: PlatformRef) => { defaultPlatform = _platform; }));
|
||||
it('should wait for asynchronous app initializers', async(() => {
|
||||
let resolve: (result: any) => void;
|
||||
let promise: Promise<any> = new Promise((res) => { resolve = res; });
|
||||
var initializerDone = false;
|
||||
const promise: Promise<any> = new Promise((res) => { resolve = res; });
|
||||
let initializerDone = false;
|
||||
setTimeout(() => {
|
||||
resolve(true);
|
||||
initializerDone = true;
|
||||
|
@ -28,12 +28,12 @@ class ComplexItem {
|
||||
export function main() {
|
||||
describe('iterable differ', function() {
|
||||
describe('DefaultIterableDiffer', function() {
|
||||
var differ: any /** TODO #9100 */;
|
||||
let differ: any /** TODO #9100 */;
|
||||
|
||||
beforeEach(() => { differ = new DefaultIterableDiffer(); });
|
||||
|
||||
it('should support list and iterables', () => {
|
||||
var f = new DefaultIterableDifferFactory();
|
||||
const f = new DefaultIterableDifferFactory();
|
||||
expect(f.supports([])).toBeTruthy();
|
||||
expect(f.supports(new TestIterable())).toBeTruthy();
|
||||
expect(f.supports(new Map())).toBeFalsy();
|
||||
@ -41,7 +41,7 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should support iterables', () => {
|
||||
let l = new TestIterable();
|
||||
const l = new TestIterable();
|
||||
|
||||
differ.check(l);
|
||||
expect(differ.toString()).toEqual(iterableChangesAsString({collection: []}));
|
||||
@ -64,7 +64,7 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should detect additions', () => {
|
||||
let l: any[] /** TODO #9100 */ = [];
|
||||
const l: any[] /** TODO #9100 */ = [];
|
||||
differ.check(l);
|
||||
expect(differ.toString()).toEqual(iterableChangesAsString({collection: []}));
|
||||
|
||||
@ -106,7 +106,7 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should handle swapping element', () => {
|
||||
let l = [1, 2];
|
||||
const l = [1, 2];
|
||||
differ.check(l);
|
||||
|
||||
l.length = 0;
|
||||
@ -121,7 +121,7 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should handle incremental swapping element', () => {
|
||||
let l = ['a', 'b', 'c'];
|
||||
const l = ['a', 'b', 'c'];
|
||||
differ.check(l);
|
||||
|
||||
l.splice(1, 1);
|
||||
@ -144,7 +144,7 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should detect changes in list', () => {
|
||||
let l: any[] /** TODO #9100 */ = [];
|
||||
const l: any[] /** TODO #9100 */ = [];
|
||||
differ.check(l);
|
||||
|
||||
l.push('a');
|
||||
@ -193,11 +193,11 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should test string by value rather than by reference (Dart)', () => {
|
||||
let l = ['a', 'boo'];
|
||||
const l = ['a', 'boo'];
|
||||
differ.check(l);
|
||||
|
||||
var b = 'b';
|
||||
var oo = 'oo';
|
||||
const b = 'b';
|
||||
const oo = 'oo';
|
||||
l[1] = b + oo;
|
||||
differ.check(l);
|
||||
expect(differ.toString())
|
||||
@ -205,7 +205,7 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should ignore [NaN] != [NaN] (JS)', () => {
|
||||
let l = [NaN];
|
||||
const l = [NaN];
|
||||
differ.check(l);
|
||||
differ.check(l);
|
||||
expect(differ.toString())
|
||||
@ -213,7 +213,7 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should detect [NaN] moves', () => {
|
||||
let l: any[] = [NaN, NaN];
|
||||
const l: any[] = [NaN, NaN];
|
||||
differ.check(l);
|
||||
|
||||
l.unshift('foo');
|
||||
@ -227,7 +227,7 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should remove and add same item', () => {
|
||||
let l = ['a', 'b', 'c'];
|
||||
const l = ['a', 'b', 'c'];
|
||||
differ.check(l);
|
||||
|
||||
l.splice(1, 1);
|
||||
@ -251,7 +251,7 @@ export function main() {
|
||||
|
||||
|
||||
it('should support duplicates', () => {
|
||||
let l = ['a', 'a', 'a', 'b', 'b'];
|
||||
const l = ['a', 'a', 'a', 'b', 'b'];
|
||||
differ.check(l);
|
||||
|
||||
l.splice(0, 1);
|
||||
@ -265,7 +265,7 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should support insertions/moves', () => {
|
||||
let l = ['a', 'a', 'b', 'b'];
|
||||
const l = ['a', 'a', 'b', 'b'];
|
||||
differ.check(l);
|
||||
|
||||
l.splice(0, 0, 'b');
|
||||
@ -279,7 +279,7 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should not report unnecessary moves', () => {
|
||||
let l = ['a', 'b', 'c'];
|
||||
const l = ['a', 'b', 'c'];
|
||||
differ.check(l);
|
||||
|
||||
l.length = 0;
|
||||
@ -296,8 +296,8 @@ export function main() {
|
||||
|
||||
describe('forEachOperation', () => {
|
||||
function stringifyItemChange(record: any, p: number, c: number, originalIndex: number) {
|
||||
var suffix = originalIndex == null ? '' : ' [o=' + originalIndex + ']';
|
||||
var value = record.item;
|
||||
const suffix = originalIndex == null ? '' : ' [o=' + originalIndex + ']';
|
||||
const value = record.item;
|
||||
if (record.currentIndex == null) {
|
||||
return `REMOVE ${value} (${p} -> VOID)${suffix}`;
|
||||
} else if (record.previousIndex == null) {
|
||||
@ -309,7 +309,7 @@ export function main() {
|
||||
|
||||
function modifyArrayUsingOperation(
|
||||
arr: number[], endData: any[], prev: number, next: number) {
|
||||
var value: number = null;
|
||||
let value: number = null;
|
||||
if (prev == null) {
|
||||
value = endData[next];
|
||||
arr.splice(next, 0, value);
|
||||
@ -326,15 +326,15 @@ export function main() {
|
||||
|
||||
it('should trigger a series of insert/move/remove changes for inputs that have been diffed',
|
||||
() => {
|
||||
var startData = [0, 1, 2, 3, 4, 5];
|
||||
var endData = [6, 2, 7, 0, 4, 8];
|
||||
const startData = [0, 1, 2, 3, 4, 5];
|
||||
const endData = [6, 2, 7, 0, 4, 8];
|
||||
|
||||
differ = differ.diff(startData);
|
||||
differ = differ.diff(endData);
|
||||
|
||||
var operations: string[] = [];
|
||||
const operations: string[] = [];
|
||||
differ.forEachOperation((item: any, prev: number, next: number) => {
|
||||
var value = modifyArrayUsingOperation(startData, endData, prev, next);
|
||||
const value = modifyArrayUsingOperation(startData, endData, prev, next);
|
||||
operations.push(stringifyItemChange(item, prev, next, item.previousIndex));
|
||||
});
|
||||
|
||||
@ -349,15 +349,15 @@ export function main() {
|
||||
|
||||
it('should consider inserting/removing/moving items with respect to items that have not moved at all',
|
||||
() => {
|
||||
var startData = [0, 1, 2, 3];
|
||||
var endData = [2, 1];
|
||||
const startData = [0, 1, 2, 3];
|
||||
const endData = [2, 1];
|
||||
|
||||
differ = differ.diff(startData);
|
||||
differ = differ.diff(endData);
|
||||
|
||||
var operations: string[] = [];
|
||||
const operations: string[] = [];
|
||||
differ.forEachOperation((item: any, prev: number, next: number) => {
|
||||
var value = modifyArrayUsingOperation(startData, endData, prev, next);
|
||||
const value = modifyArrayUsingOperation(startData, endData, prev, next);
|
||||
operations.push(stringifyItemChange(item, prev, next, item.previousIndex));
|
||||
});
|
||||
|
||||
@ -369,15 +369,15 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should be able to manage operations within a criss/cross of move operations', () => {
|
||||
var startData = [1, 2, 3, 4, 5, 6];
|
||||
var endData = [3, 6, 4, 9, 1, 2];
|
||||
const startData = [1, 2, 3, 4, 5, 6];
|
||||
const endData = [3, 6, 4, 9, 1, 2];
|
||||
|
||||
differ = differ.diff(startData);
|
||||
differ = differ.diff(endData);
|
||||
|
||||
var operations: string[] = [];
|
||||
const operations: string[] = [];
|
||||
differ.forEachOperation((item: any, prev: number, next: number) => {
|
||||
var value = modifyArrayUsingOperation(startData, endData, prev, next);
|
||||
const value = modifyArrayUsingOperation(startData, endData, prev, next);
|
||||
operations.push(stringifyItemChange(item, prev, next, item.previousIndex));
|
||||
});
|
||||
|
||||
@ -390,15 +390,15 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should skip moves for multiple nodes that have not moved', () => {
|
||||
var startData = [0, 1, 2, 3, 4];
|
||||
var endData = [4, 1, 2, 3, 0, 5];
|
||||
const startData = [0, 1, 2, 3, 4];
|
||||
const endData = [4, 1, 2, 3, 0, 5];
|
||||
|
||||
differ = differ.diff(startData);
|
||||
differ = differ.diff(endData);
|
||||
|
||||
var operations: string[] = [];
|
||||
const operations: string[] = [];
|
||||
differ.forEachOperation((item: any, prev: number, next: number) => {
|
||||
var value = modifyArrayUsingOperation(startData, endData, prev, next);
|
||||
const value = modifyArrayUsingOperation(startData, endData, prev, next);
|
||||
operations.push(stringifyItemChange(item, prev, next, item.previousIndex));
|
||||
});
|
||||
|
||||
@ -411,15 +411,15 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should not fail', () => {
|
||||
var startData = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
|
||||
var endData = [10, 11, 1, 5, 7, 8, 0, 5, 3, 6];
|
||||
const startData = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
|
||||
const endData = [10, 11, 1, 5, 7, 8, 0, 5, 3, 6];
|
||||
|
||||
differ = differ.diff(startData);
|
||||
differ = differ.diff(endData);
|
||||
|
||||
var operations: string[] = [];
|
||||
const operations: string[] = [];
|
||||
differ.forEachOperation((item: any, prev: number, next: number) => {
|
||||
var value = modifyArrayUsingOperation(startData, endData, prev, next);
|
||||
const value = modifyArrayUsingOperation(startData, endData, prev, next);
|
||||
operations.push(stringifyItemChange(item, prev, next, item.previousIndex));
|
||||
});
|
||||
|
||||
@ -437,15 +437,15 @@ export function main() {
|
||||
() => {
|
||||
differ = new DefaultIterableDiffer((index: number) => index);
|
||||
|
||||
var startData = [1, 2, 3, 4];
|
||||
var endData = [5, 6, 7, 8];
|
||||
const startData = [1, 2, 3, 4];
|
||||
const endData = [5, 6, 7, 8];
|
||||
|
||||
differ = differ.diff(startData);
|
||||
differ = differ.diff(endData);
|
||||
|
||||
var operations: string[] = [];
|
||||
const operations: string[] = [];
|
||||
differ.forEachOperation((item: any, prev: number, next: number) => {
|
||||
var value = modifyArrayUsingOperation(startData, endData, prev, next);
|
||||
const value = modifyArrayUsingOperation(startData, endData, prev, next);
|
||||
operations.push(stringifyItemChange(item, prev, next, item.previousIndex));
|
||||
});
|
||||
|
||||
@ -478,11 +478,11 @@ export function main() {
|
||||
});
|
||||
|
||||
describe('trackBy function by id', function() {
|
||||
var differ: any /** TODO #9100 */;
|
||||
let differ: any /** TODO #9100 */;
|
||||
|
||||
var trackByItemId = (index: number, item: any): any => item.id;
|
||||
const trackByItemId = (index: number, item: any): any => item.id;
|
||||
|
||||
var buildItemList = (list: string[]) => list.map((val) => new ItemWithId(val));
|
||||
const buildItemList = (list: string[]) => list.map((val) => new ItemWithId(val));
|
||||
|
||||
beforeEach(() => { differ = new DefaultIterableDiffer(trackByItemId); });
|
||||
|
||||
@ -553,7 +553,7 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should track removals normally', () => {
|
||||
let l = buildItemList(['a', 'b', 'c']);
|
||||
const l = buildItemList(['a', 'b', 'c']);
|
||||
differ.check(l);
|
||||
|
||||
l.splice(2, 1);
|
||||
@ -566,9 +566,9 @@ export function main() {
|
||||
});
|
||||
});
|
||||
describe('trackBy function by index', function() {
|
||||
var differ: any /** TODO #9100 */;
|
||||
let differ: any /** TODO #9100 */;
|
||||
|
||||
var trackByIndex = (index: number, item: any): number => index;
|
||||
const trackByIndex = (index: number, item: any): number => index;
|
||||
|
||||
beforeEach(() => { differ = new DefaultIterableDiffer(trackByIndex); });
|
||||
|
||||
|
@ -14,8 +14,8 @@ import {kvChangesAsString} from '../../change_detection/util';
|
||||
export function main() {
|
||||
describe('keyvalue differ', function() {
|
||||
describe('DefaultKeyValueDiffer', function() {
|
||||
var differ: DefaultKeyValueDiffer;
|
||||
var m: Map<any, any>;
|
||||
let differ: DefaultKeyValueDiffer;
|
||||
let m: Map<any, any>;
|
||||
|
||||
beforeEach(() => {
|
||||
differ = new DefaultKeyValueDiffer();
|
||||
@ -55,7 +55,7 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should expose previous and current value', () => {
|
||||
var previous: any /** TODO #9100 */, current: any /** TODO #9100 */;
|
||||
let previous: any /** TODO #9100 */, current: any /** TODO #9100 */;
|
||||
|
||||
m.set(1, 10);
|
||||
differ.check(m);
|
||||
@ -137,7 +137,7 @@ export function main() {
|
||||
|
||||
describe('JsObject changes', () => {
|
||||
it('should support JS Object', () => {
|
||||
var f = new DefaultKeyValueDifferFactory();
|
||||
const f = new DefaultKeyValueDifferFactory();
|
||||
expect(f.supports({})).toBeTruthy();
|
||||
expect(f.supports('not supported')).toBeFalsy();
|
||||
expect(f.supports(0)).toBeFalsy();
|
||||
|
@ -14,9 +14,9 @@ import {SpyIterableDifferFactory} from '../../spies';
|
||||
|
||||
export function main() {
|
||||
describe('IterableDiffers', function() {
|
||||
var factory1: any /** TODO #9100 */;
|
||||
var factory2: any /** TODO #9100 */;
|
||||
var factory3: any /** TODO #9100 */;
|
||||
let factory1: any /** TODO #9100 */;
|
||||
let factory2: any /** TODO #9100 */;
|
||||
let factory3: any /** TODO #9100 */;
|
||||
|
||||
beforeEach(() => {
|
||||
factory1 = new SpyIterableDifferFactory();
|
||||
@ -25,7 +25,7 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should throw when no suitable implementation found', () => {
|
||||
var differs = new IterableDiffers([]);
|
||||
const differs = new IterableDiffers([]);
|
||||
expect(() => differs.find('some object'))
|
||||
.toThrowError(/Cannot find a differ supporting object 'some object'/);
|
||||
});
|
||||
@ -35,7 +35,7 @@ export function main() {
|
||||
factory2.spy('supports').and.returnValue(true);
|
||||
factory3.spy('supports').and.returnValue(true);
|
||||
|
||||
var differs = IterableDiffers.create(<any>[factory1, factory2, factory3]);
|
||||
const differs = IterableDiffers.create(<any>[factory1, factory2, factory3]);
|
||||
expect(differs.find('some object')).toBe(factory2);
|
||||
});
|
||||
|
||||
@ -43,25 +43,25 @@ export function main() {
|
||||
factory1.spy('supports').and.returnValue(true);
|
||||
factory2.spy('supports').and.returnValue(false);
|
||||
|
||||
var parent = IterableDiffers.create(<any>[factory1]);
|
||||
var child = IterableDiffers.create(<any>[factory2], parent);
|
||||
const parent = IterableDiffers.create(<any>[factory1]);
|
||||
const child = IterableDiffers.create(<any>[factory2], parent);
|
||||
|
||||
expect(child.factories).toEqual([factory2, factory1]);
|
||||
});
|
||||
|
||||
describe('.extend()', () => {
|
||||
it('should throw if calling extend when creating root injector', () => {
|
||||
var injector = ReflectiveInjector.resolveAndCreate([IterableDiffers.extend([])]);
|
||||
const injector = ReflectiveInjector.resolveAndCreate([IterableDiffers.extend([])]);
|
||||
|
||||
expect(() => injector.get(IterableDiffers))
|
||||
.toThrowError(/Cannot extend IterableDiffers without a parent injector/);
|
||||
});
|
||||
|
||||
it('should extend di-inherited diffesr', () => {
|
||||
var parent = new IterableDiffers([factory1]);
|
||||
var injector =
|
||||
const parent = new IterableDiffers([factory1]);
|
||||
const injector =
|
||||
ReflectiveInjector.resolveAndCreate([{provide: IterableDiffers, useValue: parent}]);
|
||||
var childInjector = injector.resolveAndCreateChild([IterableDiffers.extend([factory2])]);
|
||||
const childInjector = injector.resolveAndCreateChild([IterableDiffers.extend([factory2])]);
|
||||
|
||||
expect(injector.get(IterableDiffers).factories).toEqual([factory1]);
|
||||
expect(childInjector.get(IterableDiffers).factories).toEqual([factory2, factory1]);
|
||||
|
@ -95,12 +95,12 @@ export function main() {
|
||||
|
||||
it('should auto detect changes if autoDetectChanges is called', () => {
|
||||
|
||||
let componentFixture = TestBed.createComponent(AutoDetectComp);
|
||||
const componentFixture = TestBed.createComponent(AutoDetectComp);
|
||||
expect(componentFixture.ngZone).not.toBeNull();
|
||||
componentFixture.autoDetectChanges();
|
||||
expect(componentFixture.nativeElement).toHaveText('1');
|
||||
|
||||
let element = componentFixture.debugElement.children[0];
|
||||
const element = componentFixture.debugElement.children[0];
|
||||
dispatchEvent(element.nativeElement, 'click');
|
||||
|
||||
expect(componentFixture.isStable()).toBe(true);
|
||||
@ -110,10 +110,10 @@ export function main() {
|
||||
it('should auto detect changes if ComponentFixtureAutoDetect is provided as true',
|
||||
withModule({providers: [{provide: ComponentFixtureAutoDetect, useValue: true}]}, () => {
|
||||
|
||||
let componentFixture = TestBed.createComponent(AutoDetectComp);
|
||||
const componentFixture = TestBed.createComponent(AutoDetectComp);
|
||||
expect(componentFixture.nativeElement).toHaveText('1');
|
||||
|
||||
let element = componentFixture.debugElement.children[0];
|
||||
const element = componentFixture.debugElement.children[0];
|
||||
dispatchEvent(element.nativeElement, 'click');
|
||||
|
||||
expect(componentFixture.nativeElement).toHaveText('11');
|
||||
@ -121,11 +121,11 @@ export function main() {
|
||||
|
||||
it('should signal through whenStable when the fixture is stable (autoDetectChanges)',
|
||||
async(() => {
|
||||
let componentFixture = TestBed.createComponent(AsyncComp);
|
||||
const componentFixture = TestBed.createComponent(AsyncComp);
|
||||
componentFixture.autoDetectChanges();
|
||||
expect(componentFixture.nativeElement).toHaveText('1');
|
||||
|
||||
let element = componentFixture.debugElement.children[0];
|
||||
const element = componentFixture.debugElement.children[0];
|
||||
dispatchEvent(element.nativeElement, 'click');
|
||||
expect(componentFixture.nativeElement).toHaveText('1');
|
||||
|
||||
@ -140,12 +140,12 @@ export function main() {
|
||||
|
||||
it('should signal through isStable when the fixture is stable (no autoDetectChanges)',
|
||||
async(() => {
|
||||
let componentFixture = TestBed.createComponent(AsyncComp);
|
||||
const componentFixture = TestBed.createComponent(AsyncComp);
|
||||
|
||||
componentFixture.detectChanges();
|
||||
expect(componentFixture.nativeElement).toHaveText('1');
|
||||
|
||||
let element = componentFixture.debugElement.children[0];
|
||||
const element = componentFixture.debugElement.children[0];
|
||||
dispatchEvent(element.nativeElement, 'click');
|
||||
expect(componentFixture.nativeElement).toHaveText('1');
|
||||
|
||||
@ -161,11 +161,11 @@ export function main() {
|
||||
it('should wait for macroTask(setTimeout) while checking for whenStable ' +
|
||||
'(autoDetectChanges)',
|
||||
async(() => {
|
||||
let componentFixture = TestBed.createComponent(AsyncTimeoutComp);
|
||||
const componentFixture = TestBed.createComponent(AsyncTimeoutComp);
|
||||
componentFixture.autoDetectChanges();
|
||||
expect(componentFixture.nativeElement).toHaveText('1');
|
||||
|
||||
let element = componentFixture.debugElement.children[0];
|
||||
const element = componentFixture.debugElement.children[0];
|
||||
dispatchEvent(element.nativeElement, 'click');
|
||||
expect(componentFixture.nativeElement).toHaveText('1');
|
||||
|
||||
@ -182,11 +182,11 @@ export function main() {
|
||||
'(no autoDetectChanges)',
|
||||
async(() => {
|
||||
|
||||
let componentFixture = TestBed.createComponent(AsyncTimeoutComp);
|
||||
const componentFixture = TestBed.createComponent(AsyncTimeoutComp);
|
||||
componentFixture.detectChanges();
|
||||
expect(componentFixture.nativeElement).toHaveText('1');
|
||||
|
||||
let element = componentFixture.debugElement.children[0];
|
||||
const element = componentFixture.debugElement.children[0];
|
||||
dispatchEvent(element.nativeElement, 'click');
|
||||
expect(componentFixture.nativeElement).toHaveText('1');
|
||||
|
||||
@ -204,12 +204,12 @@ export function main() {
|
||||
'(autoDetectChanges)',
|
||||
async(() => {
|
||||
|
||||
let componentFixture = TestBed.createComponent(NestedAsyncTimeoutComp);
|
||||
const componentFixture = TestBed.createComponent(NestedAsyncTimeoutComp);
|
||||
|
||||
componentFixture.autoDetectChanges();
|
||||
expect(componentFixture.nativeElement).toHaveText('1');
|
||||
|
||||
let element = componentFixture.debugElement.children[0];
|
||||
const element = componentFixture.debugElement.children[0];
|
||||
dispatchEvent(element.nativeElement, 'click');
|
||||
expect(componentFixture.nativeElement).toHaveText('1');
|
||||
|
||||
@ -226,11 +226,11 @@ export function main() {
|
||||
'(no autoDetectChanges)',
|
||||
async(() => {
|
||||
|
||||
let componentFixture = TestBed.createComponent(NestedAsyncTimeoutComp);
|
||||
const componentFixture = TestBed.createComponent(NestedAsyncTimeoutComp);
|
||||
componentFixture.detectChanges();
|
||||
expect(componentFixture.nativeElement).toHaveText('1');
|
||||
|
||||
let element = componentFixture.debugElement.children[0];
|
||||
const element = componentFixture.debugElement.children[0];
|
||||
dispatchEvent(element.nativeElement, 'click');
|
||||
expect(componentFixture.nativeElement).toHaveText('1');
|
||||
|
||||
@ -246,13 +246,13 @@ export function main() {
|
||||
|
||||
it('should stabilize after async task in change detection (autoDetectChanges)', async(() => {
|
||||
|
||||
let componentFixture = TestBed.createComponent(AsyncChangeComp);
|
||||
const componentFixture = TestBed.createComponent(AsyncChangeComp);
|
||||
|
||||
componentFixture.autoDetectChanges();
|
||||
componentFixture.whenStable().then((_) => {
|
||||
expect(componentFixture.nativeElement).toHaveText('1');
|
||||
|
||||
let element = componentFixture.debugElement.children[0];
|
||||
const element = componentFixture.debugElement.children[0];
|
||||
dispatchEvent(element.nativeElement, 'click');
|
||||
|
||||
componentFixture.whenStable().then(
|
||||
@ -262,7 +262,7 @@ export function main() {
|
||||
|
||||
it('should stabilize after async task in change detection(no autoDetectChanges)', async(() => {
|
||||
|
||||
let componentFixture = TestBed.createComponent(AsyncChangeComp);
|
||||
const componentFixture = TestBed.createComponent(AsyncChangeComp);
|
||||
componentFixture.detectChanges();
|
||||
componentFixture.whenStable().then((_) => {
|
||||
// Run detectChanges again so that stabilized value is reflected in the
|
||||
@ -270,7 +270,7 @@ export function main() {
|
||||
componentFixture.detectChanges();
|
||||
expect(componentFixture.nativeElement).toHaveText('1');
|
||||
|
||||
let element = componentFixture.debugElement.children[0];
|
||||
const element = componentFixture.debugElement.children[0];
|
||||
dispatchEvent(element.nativeElement, 'click');
|
||||
componentFixture.detectChanges();
|
||||
|
||||
@ -291,7 +291,7 @@ export function main() {
|
||||
|
||||
it('calling autoDetectChanges raises an error', () => {
|
||||
|
||||
let componentFixture = TestBed.createComponent(SimpleComp);
|
||||
const componentFixture = TestBed.createComponent(SimpleComp);
|
||||
expect(() => {
|
||||
componentFixture.autoDetectChanges();
|
||||
}).toThrowError(/Cannot call autoDetectChanges when ComponentFixtureNoNgZone is set/);
|
||||
@ -299,7 +299,7 @@ export function main() {
|
||||
|
||||
it('should instantiate a component with valid DOM', async(() => {
|
||||
|
||||
let componentFixture = TestBed.createComponent(SimpleComp);
|
||||
const componentFixture = TestBed.createComponent(SimpleComp);
|
||||
|
||||
expect(componentFixture.ngZone).toBeNull();
|
||||
componentFixture.detectChanges();
|
||||
@ -308,7 +308,7 @@ export function main() {
|
||||
|
||||
it('should allow changing members of the component', async(() => {
|
||||
|
||||
let componentFixture = TestBed.createComponent(MyIfComp);
|
||||
const componentFixture = TestBed.createComponent(MyIfComp);
|
||||
|
||||
componentFixture.detectChanges();
|
||||
expect(componentFixture.nativeElement).toHaveText('MyIf()');
|
||||
|
@ -201,7 +201,7 @@ export function main() {
|
||||
it('should list all component child elements', () => {
|
||||
fixture = TestBed.createComponent(ParentComp);
|
||||
fixture.detectChanges();
|
||||
var childEls = fixture.debugElement.children;
|
||||
const childEls = fixture.debugElement.children;
|
||||
|
||||
// The root component has 3 elements in its view.
|
||||
expect(childEls.length).toEqual(3);
|
||||
@ -209,18 +209,18 @@ export function main() {
|
||||
expect(getDOM().hasClass(childEls[1].nativeElement, 'parent')).toBe(true);
|
||||
expect(getDOM().hasClass(childEls[2].nativeElement, 'child-comp-class')).toBe(true);
|
||||
|
||||
var nested = childEls[0].children;
|
||||
const nested = childEls[0].children;
|
||||
expect(nested.length).toEqual(1);
|
||||
expect(getDOM().hasClass(nested[0].nativeElement, 'parentnested')).toBe(true);
|
||||
|
||||
var childComponent = childEls[2];
|
||||
const childComponent = childEls[2];
|
||||
|
||||
var childCompChildren = childComponent.children;
|
||||
const childCompChildren = childComponent.children;
|
||||
expect(childCompChildren.length).toEqual(2);
|
||||
expect(getDOM().hasClass(childCompChildren[0].nativeElement, 'child')).toBe(true);
|
||||
expect(getDOM().hasClass(childCompChildren[1].nativeElement, 'child')).toBe(true);
|
||||
|
||||
var childNested = childCompChildren[0].children;
|
||||
const childNested = childCompChildren[0].children;
|
||||
expect(childNested.length).toEqual(1);
|
||||
expect(getDOM().hasClass(childNested[0].nativeElement, 'childnested')).toBe(true);
|
||||
});
|
||||
@ -229,14 +229,14 @@ export function main() {
|
||||
fixture = TestBed.createComponent(ConditionalParentComp);
|
||||
fixture.detectChanges();
|
||||
|
||||
var childEls = fixture.debugElement.children;
|
||||
const childEls = fixture.debugElement.children;
|
||||
|
||||
// The root component has 2 elements in its view.
|
||||
expect(childEls.length).toEqual(2);
|
||||
expect(getDOM().hasClass(childEls[0].nativeElement, 'parent')).toBe(true);
|
||||
expect(getDOM().hasClass(childEls[1].nativeElement, 'cond-content-comp-class')).toBe(true);
|
||||
|
||||
var conditionalContentComp = childEls[1];
|
||||
const conditionalContentComp = childEls[1];
|
||||
|
||||
expect(conditionalContentComp.children.length).toEqual(0);
|
||||
|
||||
@ -250,11 +250,11 @@ export function main() {
|
||||
fixture = TestBed.createComponent(UsingFor);
|
||||
fixture.detectChanges();
|
||||
|
||||
var childEls = fixture.debugElement.children;
|
||||
const childEls = fixture.debugElement.children;
|
||||
expect(childEls.length).toEqual(4);
|
||||
|
||||
// The 4th child is the <ul>
|
||||
var list = childEls[3];
|
||||
const list = childEls[3];
|
||||
|
||||
expect(list.children.length).toEqual(3);
|
||||
});
|
||||
@ -262,7 +262,7 @@ export function main() {
|
||||
it('should list element attributes', () => {
|
||||
fixture = TestBed.createComponent(TestApp);
|
||||
fixture.detectChanges();
|
||||
var bankElem = fixture.debugElement.children[0];
|
||||
const bankElem = fixture.debugElement.children[0];
|
||||
|
||||
expect(bankElem.attributes['bank']).toEqual('RBC');
|
||||
expect(bankElem.attributes['account']).toEqual('4747');
|
||||
@ -271,7 +271,7 @@ export function main() {
|
||||
it('should list element classes', () => {
|
||||
fixture = TestBed.createComponent(TestApp);
|
||||
fixture.detectChanges();
|
||||
var bankElem = fixture.debugElement.children[0];
|
||||
const bankElem = fixture.debugElement.children[0];
|
||||
|
||||
expect(bankElem.classes['closed']).toBe(true);
|
||||
expect(bankElem.classes['open']).toBe(false);
|
||||
@ -280,7 +280,7 @@ export function main() {
|
||||
it('should list element styles', () => {
|
||||
fixture = TestBed.createComponent(TestApp);
|
||||
fixture.detectChanges();
|
||||
var bankElem = fixture.debugElement.children[0];
|
||||
const bankElem = fixture.debugElement.children[0];
|
||||
|
||||
expect(bankElem.styles['width']).toEqual('200px');
|
||||
expect(bankElem.styles['color']).toEqual('red');
|
||||
@ -290,7 +290,7 @@ export function main() {
|
||||
fixture = TestBed.createComponent(ParentComp);
|
||||
fixture.detectChanges();
|
||||
|
||||
var childTestEls = fixture.debugElement.queryAll(By.css('child-comp'));
|
||||
const childTestEls = fixture.debugElement.queryAll(By.css('child-comp'));
|
||||
|
||||
expect(childTestEls.length).toBe(1);
|
||||
expect(getDOM().hasClass(childTestEls[0].nativeElement, 'child-comp-class')).toBe(true);
|
||||
@ -300,7 +300,7 @@ export function main() {
|
||||
fixture = TestBed.createComponent(ParentComp);
|
||||
fixture.detectChanges();
|
||||
|
||||
var childTestEls = fixture.debugElement.queryAll(By.directive(MessageDir));
|
||||
const childTestEls = fixture.debugElement.queryAll(By.directive(MessageDir));
|
||||
|
||||
expect(childTestEls.length).toBe(4);
|
||||
expect(getDOM().hasClass(childTestEls[0].nativeElement, 'parent')).toBe(true);
|
||||
|
@ -13,7 +13,7 @@ import {describe, expect, it} from '@angular/core/testing/testing_internal';
|
||||
export function main() {
|
||||
describe('forwardRef', function() {
|
||||
it('should wrap and unwrap the reference', () => {
|
||||
var ref = forwardRef(() => String);
|
||||
const ref = forwardRef(() => String);
|
||||
expect(ref instanceof Type).toBe(true);
|
||||
expect(resolveForwardRef(ref)).toBe(String);
|
||||
});
|
||||
|
@ -74,7 +74,7 @@ class NoAnnotations {
|
||||
function factoryFn(a: any) {}
|
||||
|
||||
export function main() {
|
||||
var dynamicProviders = [
|
||||
const dynamicProviders = [
|
||||
{provide: 'provider0', useValue: 1}, {provide: 'provider1', useValue: 1},
|
||||
{provide: 'provider2', useValue: 1}, {provide: 'provider3', useValue: 1},
|
||||
{provide: 'provider4', useValue: 1}, {provide: 'provider5', useValue: 1},
|
||||
@ -90,7 +90,7 @@ export function main() {
|
||||
}].forEach((context) => {
|
||||
function createInjector(
|
||||
providers: Provider[], parent: ReflectiveInjector = null): ReflectiveInjector_ {
|
||||
var resolvedProviders = ReflectiveInjector.resolve(providers.concat(context['providers']));
|
||||
const resolvedProviders = ReflectiveInjector.resolve(providers.concat(context['providers']));
|
||||
if (isPresent(parent)) {
|
||||
return <ReflectiveInjector_>parent.createChildFromResolved(resolvedProviders);
|
||||
} else {
|
||||
@ -100,28 +100,28 @@ export function main() {
|
||||
|
||||
describe(`injector ${context['strategy']}`, () => {
|
||||
it('should use the right strategy', () => {
|
||||
var injector = createInjector([]);
|
||||
const injector = createInjector([]);
|
||||
expect(injector.internalStrategy).toBeAnInstanceOf(context['strategyClass']);
|
||||
});
|
||||
|
||||
it('should instantiate a class without dependencies', () => {
|
||||
var injector = createInjector([Engine]);
|
||||
var engine = injector.get(Engine);
|
||||
const injector = createInjector([Engine]);
|
||||
const engine = injector.get(Engine);
|
||||
|
||||
expect(engine).toBeAnInstanceOf(Engine);
|
||||
});
|
||||
|
||||
it('should resolve dependencies based on type information', () => {
|
||||
var injector = createInjector([Engine, Car]);
|
||||
var car = injector.get(Car);
|
||||
const injector = createInjector([Engine, Car]);
|
||||
const car = injector.get(Car);
|
||||
|
||||
expect(car).toBeAnInstanceOf(Car);
|
||||
expect(car.engine).toBeAnInstanceOf(Engine);
|
||||
});
|
||||
|
||||
it('should resolve dependencies based on @Inject annotation', () => {
|
||||
var injector = createInjector([TurboEngine, Engine, CarWithInject]);
|
||||
var car = injector.get(CarWithInject);
|
||||
const injector = createInjector([TurboEngine, Engine, CarWithInject]);
|
||||
const car = injector.get(CarWithInject);
|
||||
|
||||
expect(car).toBeAnInstanceOf(CarWithInject);
|
||||
expect(car.engine).toBeAnInstanceOf(TurboEngine);
|
||||
@ -144,28 +144,28 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should cache instances', () => {
|
||||
var injector = createInjector([Engine]);
|
||||
const injector = createInjector([Engine]);
|
||||
|
||||
var e1 = injector.get(Engine);
|
||||
var e2 = injector.get(Engine);
|
||||
const e1 = injector.get(Engine);
|
||||
const e2 = injector.get(Engine);
|
||||
|
||||
expect(e1).toBe(e2);
|
||||
});
|
||||
|
||||
it('should provide to a value', () => {
|
||||
var injector = createInjector([{provide: Engine, useValue: 'fake engine'}]);
|
||||
const injector = createInjector([{provide: Engine, useValue: 'fake engine'}]);
|
||||
|
||||
var engine = injector.get(Engine);
|
||||
const engine = injector.get(Engine);
|
||||
expect(engine).toEqual('fake engine');
|
||||
});
|
||||
|
||||
it('should provide to a factory', () => {
|
||||
function sportsCarFactory(e: any /** TODO #9100 */) { return new SportsCar(e); }
|
||||
|
||||
var injector =
|
||||
const injector =
|
||||
createInjector([Engine, {provide: Car, useFactory: sportsCarFactory, deps: [Engine]}]);
|
||||
|
||||
var car = injector.get(Car);
|
||||
const car = injector.get(Car);
|
||||
expect(car).toBeAnInstanceOf(SportsCar);
|
||||
expect(car.engine).toBeAnInstanceOf(Engine);
|
||||
});
|
||||
@ -173,7 +173,7 @@ export function main() {
|
||||
it('should throw when using a factory with more than 20 dependencies', () => {
|
||||
function factoryWithTooManyArgs() { return new Car(null); }
|
||||
|
||||
var injector = createInjector([
|
||||
const injector = createInjector([
|
||||
Engine, {
|
||||
provide: Car,
|
||||
useFactory: factoryWithTooManyArgs,
|
||||
@ -195,52 +195,52 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should supporting provider to null', () => {
|
||||
var injector = createInjector([{provide: Engine, useValue: null}]);
|
||||
var engine = injector.get(Engine);
|
||||
const injector = createInjector([{provide: Engine, useValue: null}]);
|
||||
const engine = injector.get(Engine);
|
||||
expect(engine).toBeNull();
|
||||
});
|
||||
|
||||
it('should provide to an alias', () => {
|
||||
var injector = createInjector([
|
||||
const injector = createInjector([
|
||||
Engine, {provide: SportsCar, useClass: SportsCar},
|
||||
{provide: Car, useExisting: SportsCar}
|
||||
]);
|
||||
|
||||
var car = injector.get(Car);
|
||||
var sportsCar = injector.get(SportsCar);
|
||||
const car = injector.get(Car);
|
||||
const sportsCar = injector.get(SportsCar);
|
||||
expect(car).toBeAnInstanceOf(SportsCar);
|
||||
expect(car).toBe(sportsCar);
|
||||
});
|
||||
|
||||
it('should support multiProviders', () => {
|
||||
var injector = createInjector([
|
||||
const injector = createInjector([
|
||||
Engine, {provide: Car, useClass: SportsCar, multi: true},
|
||||
{provide: Car, useClass: CarWithOptionalEngine, multi: true}
|
||||
]);
|
||||
|
||||
var cars = injector.get(Car);
|
||||
const cars = injector.get(Car);
|
||||
expect(cars.length).toEqual(2);
|
||||
expect(cars[0]).toBeAnInstanceOf(SportsCar);
|
||||
expect(cars[1]).toBeAnInstanceOf(CarWithOptionalEngine);
|
||||
});
|
||||
|
||||
it('should support multiProviders that are created using useExisting', () => {
|
||||
var injector = createInjector(
|
||||
const injector = createInjector(
|
||||
[Engine, SportsCar, {provide: Car, useExisting: SportsCar, multi: true}]);
|
||||
|
||||
var cars = injector.get(Car);
|
||||
const cars = injector.get(Car);
|
||||
expect(cars.length).toEqual(1);
|
||||
expect(cars[0]).toBe(injector.get(SportsCar));
|
||||
});
|
||||
|
||||
it('should throw when the aliased provider does not exist', () => {
|
||||
var injector = createInjector([{provide: 'car', useExisting: SportsCar}]);
|
||||
var e = `No provider for ${stringify(SportsCar)}! (car -> ${stringify(SportsCar)})`;
|
||||
const injector = createInjector([{provide: 'car', useExisting: SportsCar}]);
|
||||
const e = `No provider for ${stringify(SportsCar)}! (car -> ${stringify(SportsCar)})`;
|
||||
expect(() => injector.get('car')).toThrowError(e);
|
||||
});
|
||||
|
||||
it('should handle forwardRef in useExisting', () => {
|
||||
var injector = createInjector([
|
||||
const injector = createInjector([
|
||||
{provide: 'originalEngine', useClass: forwardRef(() => Engine)},
|
||||
{provide: 'aliasedEngine', useExisting: <any>forwardRef(() => 'originalEngine')}
|
||||
]);
|
||||
@ -248,37 +248,37 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should support overriding factory dependencies', () => {
|
||||
var injector = createInjector(
|
||||
const injector = createInjector(
|
||||
[Engine, {provide: Car, useFactory: (e: Engine) => new SportsCar(e), deps: [Engine]}]);
|
||||
|
||||
var car = injector.get(Car);
|
||||
const car = injector.get(Car);
|
||||
expect(car).toBeAnInstanceOf(SportsCar);
|
||||
expect(car.engine).toBeAnInstanceOf(Engine);
|
||||
});
|
||||
|
||||
it('should support optional dependencies', () => {
|
||||
var injector = createInjector([CarWithOptionalEngine]);
|
||||
const injector = createInjector([CarWithOptionalEngine]);
|
||||
|
||||
var car = injector.get(CarWithOptionalEngine);
|
||||
const car = injector.get(CarWithOptionalEngine);
|
||||
expect(car.engine).toEqual(null);
|
||||
});
|
||||
|
||||
it('should flatten passed-in providers', () => {
|
||||
var injector = createInjector([[[Engine, Car]]]);
|
||||
const injector = createInjector([[[Engine, Car]]]);
|
||||
|
||||
var car = injector.get(Car);
|
||||
const car = injector.get(Car);
|
||||
expect(car).toBeAnInstanceOf(Car);
|
||||
});
|
||||
|
||||
it('should use the last provider when there are multiple providers for same token', () => {
|
||||
var injector = createInjector(
|
||||
const injector = createInjector(
|
||||
[{provide: Engine, useClass: Engine}, {provide: Engine, useClass: TurboEngine}]);
|
||||
|
||||
expect(injector.get(Engine)).toBeAnInstanceOf(TurboEngine);
|
||||
});
|
||||
|
||||
it('should use non-type tokens', () => {
|
||||
var injector = createInjector([{provide: 'token', useValue: 'value'}]);
|
||||
const injector = createInjector([{provide: 'token', useValue: 'value'}]);
|
||||
|
||||
expect(injector.get('token')).toEqual('value');
|
||||
});
|
||||
@ -290,26 +290,26 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should provide itself', () => {
|
||||
var parent = createInjector([]);
|
||||
var child = parent.resolveAndCreateChild([]);
|
||||
const parent = createInjector([]);
|
||||
const child = parent.resolveAndCreateChild([]);
|
||||
|
||||
expect(child.get(Injector)).toBe(child);
|
||||
});
|
||||
|
||||
it('should throw when no provider defined', () => {
|
||||
var injector = createInjector([]);
|
||||
const injector = createInjector([]);
|
||||
expect(() => injector.get('NonExisting')).toThrowError('No provider for NonExisting!');
|
||||
});
|
||||
|
||||
it('should show the full path when no provider', () => {
|
||||
var injector = createInjector([CarWithDashboard, Engine, Dashboard]);
|
||||
const injector = createInjector([CarWithDashboard, Engine, Dashboard]);
|
||||
expect(() => injector.get(CarWithDashboard))
|
||||
.toThrowError(
|
||||
`No provider for DashboardSoftware! (${stringify(CarWithDashboard)} -> ${stringify(Dashboard)} -> DashboardSoftware)`);
|
||||
});
|
||||
|
||||
it('should throw when trying to instantiate a cyclic dependency', () => {
|
||||
var injector = createInjector([Car, {provide: Engine, useClass: CyclicEngine}]);
|
||||
const injector = createInjector([Car, {provide: Engine, useClass: CyclicEngine}]);
|
||||
|
||||
expect(() => injector.get(Car))
|
||||
.toThrowError(
|
||||
@ -317,10 +317,10 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should show the full path when error happens in a constructor', () => {
|
||||
var providers =
|
||||
const providers =
|
||||
ReflectiveInjector.resolve([Car, {provide: Engine, useClass: BrokenEngine}]);
|
||||
var proto = new ReflectiveProtoInjector([providers[0], providers[1]]);
|
||||
var injector = new ReflectiveInjector_(proto);
|
||||
const proto = new ReflectiveProtoInjector([providers[0], providers[1]]);
|
||||
const injector = new ReflectiveInjector_(proto);
|
||||
|
||||
try {
|
||||
injector.get(Car);
|
||||
@ -334,9 +334,9 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should instantiate an object after a failed attempt', () => {
|
||||
var isBroken = true;
|
||||
let isBroken = true;
|
||||
|
||||
var injector = createInjector([
|
||||
const injector = createInjector([
|
||||
Car,
|
||||
{provide: Engine, useFactory: (() => isBroken ? new BrokenEngine() : new Engine())}
|
||||
]);
|
||||
@ -350,7 +350,7 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should support null values', () => {
|
||||
var injector = createInjector([{provide: 'null', useValue: null}]);
|
||||
const injector = createInjector([{provide: 'null', useValue: null}]);
|
||||
expect(injector.get('null')).toBe(null);
|
||||
});
|
||||
|
||||
@ -359,52 +359,52 @@ export function main() {
|
||||
|
||||
describe('child', () => {
|
||||
it('should load instances from parent injector', () => {
|
||||
var parent = ReflectiveInjector.resolveAndCreate([Engine]);
|
||||
var child = parent.resolveAndCreateChild([]);
|
||||
const parent = ReflectiveInjector.resolveAndCreate([Engine]);
|
||||
const child = parent.resolveAndCreateChild([]);
|
||||
|
||||
var engineFromParent = parent.get(Engine);
|
||||
var engineFromChild = child.get(Engine);
|
||||
const engineFromParent = parent.get(Engine);
|
||||
const engineFromChild = child.get(Engine);
|
||||
|
||||
expect(engineFromChild).toBe(engineFromParent);
|
||||
});
|
||||
|
||||
it('should not use the child providers when resolving the dependencies of a parent provider',
|
||||
() => {
|
||||
var parent = ReflectiveInjector.resolveAndCreate([Car, Engine]);
|
||||
var child = parent.resolveAndCreateChild([{provide: Engine, useClass: TurboEngine}]);
|
||||
const parent = ReflectiveInjector.resolveAndCreate([Car, Engine]);
|
||||
const child = parent.resolveAndCreateChild([{provide: Engine, useClass: TurboEngine}]);
|
||||
|
||||
var carFromChild = child.get(Car);
|
||||
const carFromChild = child.get(Car);
|
||||
expect(carFromChild.engine).toBeAnInstanceOf(Engine);
|
||||
});
|
||||
|
||||
it('should create new instance in a child injector', () => {
|
||||
var parent = ReflectiveInjector.resolveAndCreate([Engine]);
|
||||
var child = parent.resolveAndCreateChild([{provide: Engine, useClass: TurboEngine}]);
|
||||
const parent = ReflectiveInjector.resolveAndCreate([Engine]);
|
||||
const child = parent.resolveAndCreateChild([{provide: Engine, useClass: TurboEngine}]);
|
||||
|
||||
var engineFromParent = parent.get(Engine);
|
||||
var engineFromChild = child.get(Engine);
|
||||
const engineFromParent = parent.get(Engine);
|
||||
const engineFromChild = child.get(Engine);
|
||||
|
||||
expect(engineFromParent).not.toBe(engineFromChild);
|
||||
expect(engineFromChild).toBeAnInstanceOf(TurboEngine);
|
||||
});
|
||||
|
||||
it('should give access to parent', () => {
|
||||
var parent = ReflectiveInjector.resolveAndCreate([]);
|
||||
var child = parent.resolveAndCreateChild([]);
|
||||
const parent = ReflectiveInjector.resolveAndCreate([]);
|
||||
const child = parent.resolveAndCreateChild([]);
|
||||
expect(child.parent).toBe(parent);
|
||||
});
|
||||
});
|
||||
|
||||
describe('resolveAndInstantiate', () => {
|
||||
it('should instantiate an object in the context of the injector', () => {
|
||||
var inj = ReflectiveInjector.resolveAndCreate([Engine]);
|
||||
var car = inj.resolveAndInstantiate(Car);
|
||||
const inj = ReflectiveInjector.resolveAndCreate([Engine]);
|
||||
const car = inj.resolveAndInstantiate(Car);
|
||||
expect(car).toBeAnInstanceOf(Car);
|
||||
expect(car.engine).toBe(inj.get(Engine));
|
||||
});
|
||||
|
||||
it('should not store the instantiated object in the injector', () => {
|
||||
var inj = ReflectiveInjector.resolveAndCreate([Engine]);
|
||||
const inj = ReflectiveInjector.resolveAndCreate([Engine]);
|
||||
inj.resolveAndInstantiate(Car);
|
||||
expect(() => inj.get(Car)).toThrowError();
|
||||
});
|
||||
@ -412,8 +412,8 @@ export function main() {
|
||||
|
||||
describe('instantiate', () => {
|
||||
it('should instantiate an object in the context of the injector', () => {
|
||||
var inj = ReflectiveInjector.resolveAndCreate([Engine]);
|
||||
var car = inj.instantiateResolved(ReflectiveInjector.resolve([Car])[0]);
|
||||
const inj = ReflectiveInjector.resolveAndCreate([Engine]);
|
||||
const car = inj.instantiateResolved(ReflectiveInjector.resolve([Car])[0]);
|
||||
expect(car).toBeAnInstanceOf(Car);
|
||||
expect(car.engine).toBe(inj.get(Engine));
|
||||
});
|
||||
@ -422,7 +422,7 @@ export function main() {
|
||||
describe('depedency resolution', () => {
|
||||
describe('@Self()', () => {
|
||||
it('should return a dependency from self', () => {
|
||||
var inj = ReflectiveInjector.resolveAndCreate([
|
||||
const inj = ReflectiveInjector.resolveAndCreate([
|
||||
Engine,
|
||||
{provide: Car, useFactory: (e: Engine) => new Car(e), deps: [[Engine, new Self()]]}
|
||||
]);
|
||||
@ -431,8 +431,8 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should throw when not requested provider on self', () => {
|
||||
var parent = ReflectiveInjector.resolveAndCreate([Engine]);
|
||||
var child = parent.resolveAndCreateChild([
|
||||
const parent = ReflectiveInjector.resolveAndCreate([Engine]);
|
||||
const child = parent.resolveAndCreateChild([
|
||||
{provide: Car, useFactory: (e: Engine) => new Car(e), deps: [[Engine, new Self()]]}
|
||||
]);
|
||||
|
||||
@ -443,8 +443,8 @@ export function main() {
|
||||
|
||||
describe('default', () => {
|
||||
it('should not skip self', () => {
|
||||
var parent = ReflectiveInjector.resolveAndCreate([Engine]);
|
||||
var child = parent.resolveAndCreateChild([
|
||||
const parent = ReflectiveInjector.resolveAndCreate([Engine]);
|
||||
const child = parent.resolveAndCreateChild([
|
||||
{provide: Engine, useClass: TurboEngine},
|
||||
{provide: Car, useFactory: (e: Engine) => new Car(e), deps: [Engine]}
|
||||
]);
|
||||
@ -456,7 +456,7 @@ export function main() {
|
||||
|
||||
describe('resolve', () => {
|
||||
it('should resolve and flatten', () => {
|
||||
var providers = ReflectiveInjector.resolve([Engine, [BrokenEngine]]);
|
||||
const providers = ReflectiveInjector.resolve([Engine, [BrokenEngine]]);
|
||||
providers.forEach(function(b) {
|
||||
if (!b) return; // the result is a sparse array
|
||||
expect(b instanceof ResolvedReflectiveProvider_).toBe(true);
|
||||
@ -464,7 +464,7 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should support multi providers', () => {
|
||||
var provider = ReflectiveInjector.resolve([
|
||||
const provider = ReflectiveInjector.resolve([
|
||||
{provide: Engine, useClass: BrokenEngine, multi: true},
|
||||
{provide: Engine, useClass: TurboEngine, multi: true}
|
||||
])[0];
|
||||
@ -476,7 +476,7 @@ export function main() {
|
||||
|
||||
|
||||
it('should support providers as hash', () => {
|
||||
var provider = ReflectiveInjector.resolve([
|
||||
const provider = ReflectiveInjector.resolve([
|
||||
{provide: Engine, useClass: BrokenEngine, multi: true},
|
||||
{provide: Engine, useClass: TurboEngine, multi: true}
|
||||
])[0];
|
||||
@ -487,7 +487,7 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should support multi providers with only one provider', () => {
|
||||
var provider =
|
||||
const provider =
|
||||
ReflectiveInjector.resolve([{provide: Engine, useClass: BrokenEngine, multi: true}])[0];
|
||||
|
||||
expect(provider.key.token).toBe(Engine);
|
||||
@ -508,7 +508,7 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should resolve forward references', () => {
|
||||
var providers = ReflectiveInjector.resolve([
|
||||
const providers = ReflectiveInjector.resolve([
|
||||
forwardRef(() => Engine),
|
||||
[{provide: forwardRef(() => BrokenEngine), useClass: forwardRef(() => Engine)}], {
|
||||
provide: forwardRef(() => String),
|
||||
@ -517,9 +517,9 @@ export function main() {
|
||||
}
|
||||
]);
|
||||
|
||||
var engineProvider = providers[0];
|
||||
var brokenEngineProvider = providers[1];
|
||||
var stringProvider = providers[2];
|
||||
const engineProvider = providers[0];
|
||||
const brokenEngineProvider = providers[1];
|
||||
const stringProvider = providers[2];
|
||||
|
||||
expect(engineProvider.resolvedFactories[0].factory() instanceof Engine).toBe(true);
|
||||
expect(brokenEngineProvider.resolvedFactories[0].factory() instanceof Engine).toBe(true);
|
||||
@ -528,21 +528,21 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should support overriding factory dependencies with dependency annotations', () => {
|
||||
var providers = ReflectiveInjector.resolve([{
|
||||
const providers = ReflectiveInjector.resolve([{
|
||||
provide: 'token',
|
||||
useFactory: (e: any /** TODO #9100 */) => 'result',
|
||||
deps: [[new Inject('dep')]]
|
||||
}]);
|
||||
|
||||
var provider = providers[0];
|
||||
const provider = providers[0];
|
||||
|
||||
expect(provider.resolvedFactories[0].dependencies[0].key.token).toEqual('dep');
|
||||
});
|
||||
|
||||
it('should allow declaring dependencies with flat arrays', () => {
|
||||
var resolved = ReflectiveInjector.resolve(
|
||||
const resolved = ReflectiveInjector.resolve(
|
||||
[{provide: 'token', useFactory: (e: any) => e, deps: [new Inject('dep')]}]);
|
||||
var nestedResolved = ReflectiveInjector.resolve(
|
||||
const nestedResolved = ReflectiveInjector.resolve(
|
||||
[{provide: 'token', useFactory: (e: any) => e, deps: [[new Inject('dep')]]}]);
|
||||
expect(resolved[0].resolvedFactories[0].dependencies[0].key.token)
|
||||
.toEqual(nestedResolved[0].resolvedFactories[0].dependencies[0].key.token);
|
||||
|
@ -10,7 +10,7 @@ import {KeyRegistry} from '@angular/core/src/di/reflective_key';
|
||||
|
||||
export function main() {
|
||||
describe('key', function() {
|
||||
var registry: KeyRegistry;
|
||||
let registry: KeyRegistry;
|
||||
|
||||
beforeEach(function() { registry = new KeyRegistry(); });
|
||||
|
||||
|
@ -32,7 +32,7 @@ export function main() {
|
||||
|
||||
it('should invoke lifecycle methods ngOnChanges > ngOnInit > ngDoCheck > ngAfterContentChecked',
|
||||
() => {
|
||||
let fixture = TestBed.createComponent(MyComp5);
|
||||
const fixture = TestBed.createComponent(MyComp5);
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(log.result())
|
||||
|
@ -13,27 +13,27 @@ import {el, stringifyElement} from '@angular/platform-browser/testing/browser_ut
|
||||
export function main() {
|
||||
describe('dom adapter', () => {
|
||||
it('should not coalesque text nodes', () => {
|
||||
var el1 = el('<div>a</div>');
|
||||
var el2 = el('<div>b</div>');
|
||||
const el1 = el('<div>a</div>');
|
||||
const el2 = el('<div>b</div>');
|
||||
getDOM().appendChild(el2, getDOM().firstChild(el1));
|
||||
expect(getDOM().childNodes(el2).length).toBe(2);
|
||||
|
||||
var el2Clone = getDOM().clone(el2);
|
||||
const el2Clone = getDOM().clone(el2);
|
||||
expect(getDOM().childNodes(el2Clone).length).toBe(2);
|
||||
});
|
||||
|
||||
it('should clone correctly', () => {
|
||||
var el1 = el('<div x="y">a<span>b</span></div>');
|
||||
var clone = getDOM().clone(el1);
|
||||
const el1 = el('<div x="y">a<span>b</span></div>');
|
||||
const clone = getDOM().clone(el1);
|
||||
|
||||
expect(clone).not.toBe(el1);
|
||||
getDOM().setAttribute(clone, 'test', '1');
|
||||
expect(stringifyElement(clone)).toEqual('<div test="1" x="y">a<span>b</span></div>');
|
||||
expect(getDOM().getAttribute(el1, 'test')).toBeFalsy();
|
||||
|
||||
var cNodes = getDOM().childNodes(clone);
|
||||
var firstChild = cNodes[0];
|
||||
var secondChild = cNodes[1];
|
||||
const cNodes = getDOM().childNodes(clone);
|
||||
const firstChild = cNodes[0];
|
||||
const secondChild = cNodes[1];
|
||||
expect(getDOM().parentElement(firstChild)).toBe(clone);
|
||||
expect(getDOM().nextSibling(firstChild)).toBe(secondChild);
|
||||
expect(getDOM().isTextNode(firstChild)).toBe(true);
|
||||
@ -45,21 +45,21 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should be able to create text nodes and use them with the other APIs', () => {
|
||||
var t = getDOM().createTextNode('hello');
|
||||
const t = getDOM().createTextNode('hello');
|
||||
expect(getDOM().isTextNode(t)).toBe(true);
|
||||
var d = getDOM().createElement('div');
|
||||
const d = getDOM().createElement('div');
|
||||
getDOM().appendChild(d, t);
|
||||
expect(getDOM().getInnerHTML(d)).toEqual('hello');
|
||||
});
|
||||
|
||||
it('should set className via the class attribute', () => {
|
||||
var d = getDOM().createElement('div');
|
||||
const d = getDOM().createElement('div');
|
||||
getDOM().setAttribute(d, 'class', 'class1');
|
||||
expect(d.className).toEqual('class1');
|
||||
});
|
||||
|
||||
it('should allow to remove nodes without parents', () => {
|
||||
var d = getDOM().createElement('div');
|
||||
const d = getDOM().createElement('div');
|
||||
expect(() => getDOM().remove(d)).not.toThrow();
|
||||
});
|
||||
|
||||
@ -71,12 +71,12 @@ export function main() {
|
||||
() => { expect(getDOM().getBaseHref()).toBeNull(); });
|
||||
|
||||
it('should return the value of the base element', () => {
|
||||
var baseEl = getDOM().createElement('base');
|
||||
const baseEl = getDOM().createElement('base');
|
||||
getDOM().setAttribute(baseEl, 'href', '/drop/bass/connon/');
|
||||
var headEl = getDOM().defaultDoc().head;
|
||||
const headEl = getDOM().defaultDoc().head;
|
||||
getDOM().appendChild(headEl, baseEl);
|
||||
|
||||
var baseHref = getDOM().getBaseHref();
|
||||
const baseHref = getDOM().getBaseHref();
|
||||
getDOM().removeChild(headEl, baseEl);
|
||||
getDOM().resetBaseElement();
|
||||
|
||||
@ -84,12 +84,12 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should return a relative url', () => {
|
||||
var baseEl = getDOM().createElement('base');
|
||||
const baseEl = getDOM().createElement('base');
|
||||
getDOM().setAttribute(baseEl, 'href', 'base');
|
||||
var headEl = getDOM().defaultDoc().head;
|
||||
const headEl = getDOM().defaultDoc().head;
|
||||
getDOM().appendChild(headEl, baseEl);
|
||||
|
||||
var baseHref = getDOM().getBaseHref();
|
||||
const baseHref = getDOM().getBaseHref();
|
||||
getDOM().removeChild(headEl, baseEl);
|
||||
getDOM().resetBaseElement();
|
||||
|
||||
|
@ -12,7 +12,7 @@ export function main() {
|
||||
describe('Shim', () => {
|
||||
|
||||
it('should provide correct function.name ', () => {
|
||||
var functionWithoutName = identity(() => function(_: any /** TODO #9100 */) {});
|
||||
const functionWithoutName = identity(() => function(_: any /** TODO #9100 */) {});
|
||||
function foo(_: any /** TODO #9100 */){};
|
||||
|
||||
expect((<any>functionWithoutName).name).toBeFalsy();
|
||||
|
@ -24,8 +24,8 @@ class _CustomException {
|
||||
|
||||
export function main() {
|
||||
function errorToString(error: any) {
|
||||
var logger = new MockConsole();
|
||||
var errorHandler = new ErrorHandler(false);
|
||||
const logger = new MockConsole();
|
||||
const errorHandler = new ErrorHandler(false);
|
||||
errorHandler._console = logger as any;
|
||||
errorHandler.handleError(error);
|
||||
return logger.res.join('\n');
|
||||
@ -41,29 +41,29 @@ export function main() {
|
||||
|
||||
describe('ErrorHandler', () => {
|
||||
it('should output exception', () => {
|
||||
var e = errorToString(new Error('message!'));
|
||||
const e = errorToString(new Error('message!'));
|
||||
expect(e).toContain('message!');
|
||||
});
|
||||
|
||||
it('should output stackTrace', () => {
|
||||
var error = new Error('message!');
|
||||
var stack = getStack(error);
|
||||
const error = new Error('message!');
|
||||
const stack = getStack(error);
|
||||
if (stack) {
|
||||
var e = errorToString(error);
|
||||
const e = errorToString(error);
|
||||
expect(e).toContain(stack);
|
||||
}
|
||||
});
|
||||
|
||||
describe('context', () => {
|
||||
it('should print nested context', () => {
|
||||
var cause = new Error('message!');
|
||||
var stack = getStack(cause);
|
||||
var context = {
|
||||
const cause = new Error('message!');
|
||||
const stack = getStack(cause);
|
||||
const context = {
|
||||
source: 'context!',
|
||||
toString() { return 'Context'; }
|
||||
} as any as DebugContext;
|
||||
var original = new ViewWrappedError(cause, context);
|
||||
var e = errorToString(new WrappedError('message', original));
|
||||
const original = new ViewWrappedError(cause, context);
|
||||
const e = errorToString(new WrappedError('message', original));
|
||||
expect(e).toEqual(
|
||||
stack ? `EXCEPTION: message caused by: Error in context! caused by: message!
|
||||
ORIGINAL EXCEPTION: message!
|
||||
@ -80,27 +80,27 @@ Context`);
|
||||
|
||||
describe('original exception', () => {
|
||||
it('should print original exception message if available (original is Error)', () => {
|
||||
var realOriginal = new Error('inner');
|
||||
var original = new WrappedError('wrapped', realOriginal);
|
||||
var e = errorToString(new WrappedError('wrappedwrapped', original));
|
||||
const realOriginal = new Error('inner');
|
||||
const original = new WrappedError('wrapped', realOriginal);
|
||||
const e = errorToString(new WrappedError('wrappedwrapped', original));
|
||||
expect(e).toContain('inner');
|
||||
});
|
||||
|
||||
it('should print original exception message if available (original is not Error)', () => {
|
||||
var realOriginal = new _CustomException();
|
||||
var original = new WrappedError('wrapped', realOriginal);
|
||||
var e = errorToString(new WrappedError('wrappedwrapped', original));
|
||||
const realOriginal = new _CustomException();
|
||||
const original = new WrappedError('wrapped', realOriginal);
|
||||
const e = errorToString(new WrappedError('wrappedwrapped', original));
|
||||
expect(e).toContain('custom');
|
||||
});
|
||||
});
|
||||
|
||||
describe('original stack', () => {
|
||||
it('should print original stack if available', () => {
|
||||
var realOriginal = new Error('inner');
|
||||
var stack = getStack(realOriginal);
|
||||
const realOriginal = new Error('inner');
|
||||
const stack = getStack(realOriginal);
|
||||
if (stack) {
|
||||
var original = new WrappedError('wrapped', realOriginal);
|
||||
var e = errorToString(new WrappedError('wrappedwrapped', original));
|
||||
const original = new WrappedError('wrapped', realOriginal);
|
||||
const e = errorToString(new WrappedError('wrappedwrapped', original));
|
||||
expect(e).toContain(stack);
|
||||
}
|
||||
});
|
||||
|
@ -17,7 +17,7 @@ export function main() {
|
||||
it('should call next with values',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
|
||||
let o = new Observable((sink: any /** TODO #9100 */) => { sink.next(1); });
|
||||
const o = new Observable((sink: any /** TODO #9100 */) => { sink.next(1); });
|
||||
|
||||
o.subscribe(v => {
|
||||
expect(v).toEqual(1);
|
||||
@ -29,7 +29,7 @@ export function main() {
|
||||
it('should call next and then complete',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
|
||||
let o = new Observable((sink: any /** TODO #9100 */) => {
|
||||
const o = new Observable((sink: any /** TODO #9100 */) => {
|
||||
sink.next(1);
|
||||
sink.complete();
|
||||
});
|
||||
@ -47,7 +47,7 @@ export function main() {
|
||||
it('should call error with errors',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
|
||||
let o = new Observable((sink: any /** TODO #9100 */) => { sink.error('oh noes!'); });
|
||||
const o = new Observable((sink: any /** TODO #9100 */) => { sink.error('oh noes!'); });
|
||||
|
||||
o.subscribe(
|
||||
v => {
|
||||
|
@ -18,7 +18,7 @@ const ProxyZoneSpec: {assertPresent: () => void} = (Zone as any)['ProxyZoneSpec'
|
||||
export function main() {
|
||||
describe('fake async', () => {
|
||||
it('should run synchronous code', () => {
|
||||
var ran = false;
|
||||
let ran = false;
|
||||
fakeAsync(() => { ran = true; })();
|
||||
|
||||
expect(ran).toEqual(true);
|
||||
@ -42,7 +42,7 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should flush microtasks before returning', () => {
|
||||
var thenRan = false;
|
||||
let thenRan = false;
|
||||
|
||||
fakeAsync(() => { resolvedPromise.then(_ => { thenRan = true; }); })();
|
||||
|
||||
@ -55,7 +55,7 @@ export function main() {
|
||||
|
||||
describe('Promise', () => {
|
||||
it('should run asynchronous code', fakeAsync(() => {
|
||||
var thenRan = false;
|
||||
let thenRan = false;
|
||||
resolvedPromise.then((_) => { thenRan = true; });
|
||||
|
||||
expect(thenRan).toEqual(false);
|
||||
@ -65,7 +65,7 @@ export function main() {
|
||||
}));
|
||||
|
||||
it('should run chained thens', fakeAsync(() => {
|
||||
var log = new Log();
|
||||
const log = new Log();
|
||||
|
||||
resolvedPromise.then((_) => log.add(1)).then((_) => log.add(2));
|
||||
|
||||
@ -76,7 +76,7 @@ export function main() {
|
||||
}));
|
||||
|
||||
it('should run Promise created in Promise', fakeAsync(() => {
|
||||
var log = new Log();
|
||||
const log = new Log();
|
||||
|
||||
resolvedPromise.then((_) => {
|
||||
log.add(1);
|
||||
@ -106,7 +106,7 @@ export function main() {
|
||||
|
||||
describe('timers', () => {
|
||||
it('should run queued zero duration timer on zero tick', fakeAsync(() => {
|
||||
var ran = false;
|
||||
let ran = false;
|
||||
setTimeout(() => { ran = true; }, 0);
|
||||
|
||||
expect(ran).toEqual(false);
|
||||
@ -117,7 +117,7 @@ export function main() {
|
||||
|
||||
|
||||
it('should run queued timer after sufficient clock ticks', fakeAsync(() => {
|
||||
var ran = false;
|
||||
let ran = false;
|
||||
setTimeout(() => { ran = true; }, 10);
|
||||
|
||||
tick(6);
|
||||
@ -128,7 +128,7 @@ export function main() {
|
||||
}));
|
||||
|
||||
it('should run queued timer only once', fakeAsync(() => {
|
||||
var cycles = 0;
|
||||
let cycles = 0;
|
||||
setTimeout(() => { cycles++; }, 10);
|
||||
|
||||
tick(10);
|
||||
@ -142,8 +142,8 @@ export function main() {
|
||||
}));
|
||||
|
||||
it('should not run cancelled timer', fakeAsync(() => {
|
||||
var ran = false;
|
||||
var id = setTimeout(() => { ran = true; }, 10);
|
||||
let ran = false;
|
||||
const id = setTimeout(() => { ran = true; }, 10);
|
||||
clearTimeout(id);
|
||||
|
||||
tick(10);
|
||||
@ -163,8 +163,8 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should run periodic timers', fakeAsync(() => {
|
||||
var cycles = 0;
|
||||
var id = setInterval(() => { cycles++; }, 10);
|
||||
let cycles = 0;
|
||||
const id = setInterval(() => { cycles++; }, 10);
|
||||
|
||||
tick(10);
|
||||
expect(cycles).toEqual(1);
|
||||
@ -178,8 +178,8 @@ export function main() {
|
||||
}));
|
||||
|
||||
it('should not run cancelled periodic timer', fakeAsync(() => {
|
||||
var ran = false;
|
||||
var id = setInterval(() => { ran = true; }, 10);
|
||||
let ran = false;
|
||||
const id = setInterval(() => { ran = true; }, 10);
|
||||
clearInterval(id);
|
||||
|
||||
tick(10);
|
||||
@ -187,8 +187,8 @@ export function main() {
|
||||
}));
|
||||
|
||||
it('should be able to cancel periodic timers from a callback', fakeAsync(() => {
|
||||
var cycles = 0;
|
||||
var id: any /** TODO #9100 */;
|
||||
let cycles = 0;
|
||||
let id: any /** TODO #9100 */;
|
||||
|
||||
id = setInterval(() => {
|
||||
cycles++;
|
||||
@ -203,8 +203,8 @@ export function main() {
|
||||
}));
|
||||
|
||||
it('should clear periodic timers', fakeAsync(() => {
|
||||
var cycles = 0;
|
||||
var id = setInterval(() => { cycles++; }, 10);
|
||||
let cycles = 0;
|
||||
const id = setInterval(() => { cycles++; }, 10);
|
||||
|
||||
tick(10);
|
||||
expect(cycles).toEqual(1);
|
||||
@ -221,13 +221,13 @@ export function main() {
|
||||
}));
|
||||
|
||||
it('should process microtasks before timers', fakeAsync(() => {
|
||||
var log = new Log();
|
||||
const log = new Log();
|
||||
|
||||
resolvedPromise.then((_) => log.add('microtask'));
|
||||
|
||||
setTimeout(() => log.add('timer'), 9);
|
||||
|
||||
var id = setInterval(() => log.add('periodic timer'), 10);
|
||||
const id = setInterval(() => log.add('periodic timer'), 10);
|
||||
|
||||
expect(log.result()).toEqual('');
|
||||
|
||||
@ -237,7 +237,7 @@ export function main() {
|
||||
}));
|
||||
|
||||
it('should process micro-tasks created in timers before next timers', fakeAsync(() => {
|
||||
var log = new Log();
|
||||
const log = new Log();
|
||||
|
||||
resolvedPromise.then((_) => log.add('microtask'));
|
||||
|
||||
@ -246,7 +246,7 @@ export function main() {
|
||||
resolvedPromise.then((_) => log.add('t microtask'));
|
||||
}, 9);
|
||||
|
||||
var id = setInterval(() => {
|
||||
const id = setInterval(() => {
|
||||
log.add('periodic timer');
|
||||
resolvedPromise.then((_) => log.add('pt microtask'));
|
||||
}, 10);
|
||||
@ -302,7 +302,7 @@ export function main() {
|
||||
|
||||
it('should allow fakeAsync zone to retroactively set a zoneSpec outside of fakeAsync', () => {
|
||||
ProxyZoneSpec.assertPresent();
|
||||
var state: string = 'not run';
|
||||
let state: string = 'not run';
|
||||
const testZone = Zone.current.fork({name: 'test-zone'});
|
||||
(fakeAsync(() => {
|
||||
testZone.run(() => {
|
||||
|
@ -42,7 +42,7 @@ export function main() {
|
||||
}
|
||||
|
||||
function queryDirs(el: DebugElement, dirType: Type<any>): any {
|
||||
var nodes = el.queryAllNodes(By.directive(dirType));
|
||||
const nodes = el.queryAllNodes(By.directive(dirType));
|
||||
return nodes.map(node => node.injector.get(dirType));
|
||||
}
|
||||
|
||||
@ -50,7 +50,7 @@ export function main() {
|
||||
function _bindSimpleProp<T>(bindAttr: string, compType: Type<T>): ComponentFixture<T>;
|
||||
function _bindSimpleProp<T>(
|
||||
bindAttr: string, compType: Type<T> = <any>TestComponent): ComponentFixture<T> {
|
||||
var template = `<div ${bindAttr}></div>`;
|
||||
const template = `<div ${bindAttr}></div>`;
|
||||
return createCompFixture(template, compType);
|
||||
}
|
||||
|
||||
@ -242,14 +242,14 @@ export function main() {
|
||||
}));
|
||||
|
||||
it('should report all changes on the first run including null values', fakeAsync(() => {
|
||||
var ctx = _bindSimpleValue('a', TestData);
|
||||
const ctx = _bindSimpleValue('a', TestData);
|
||||
ctx.componentInstance.a = null;
|
||||
ctx.detectChanges(false);
|
||||
expect(renderLog.log).toEqual(['someProp=null']);
|
||||
}));
|
||||
|
||||
it('should support simple chained property access', fakeAsync(() => {
|
||||
var ctx = _bindSimpleValue('address.city', Person);
|
||||
const ctx = _bindSimpleValue('address.city', Person);
|
||||
ctx.componentInstance.name = 'Victor';
|
||||
ctx.componentInstance.address = new Address('Grenoble');
|
||||
ctx.detectChanges(false);
|
||||
@ -258,28 +258,28 @@ export function main() {
|
||||
|
||||
describe('safe navigation operator', () => {
|
||||
it('should support reading properties of nulls', fakeAsync(() => {
|
||||
var ctx = _bindSimpleValue('address?.city', Person);
|
||||
const ctx = _bindSimpleValue('address?.city', Person);
|
||||
ctx.componentInstance.address = null;
|
||||
ctx.detectChanges(false);
|
||||
expect(renderLog.log).toEqual(['someProp=null']);
|
||||
}));
|
||||
|
||||
it('should support calling methods on nulls', fakeAsync(() => {
|
||||
var ctx = _bindSimpleValue('address?.toString()', Person);
|
||||
const ctx = _bindSimpleValue('address?.toString()', Person);
|
||||
ctx.componentInstance.address = null;
|
||||
ctx.detectChanges(false);
|
||||
expect(renderLog.log).toEqual(['someProp=null']);
|
||||
}));
|
||||
|
||||
it('should support reading properties on non nulls', fakeAsync(() => {
|
||||
var ctx = _bindSimpleValue('address?.city', Person);
|
||||
const ctx = _bindSimpleValue('address?.city', Person);
|
||||
ctx.componentInstance.address = new Address('MTV');
|
||||
ctx.detectChanges(false);
|
||||
expect(renderLog.log).toEqual(['someProp=MTV']);
|
||||
}));
|
||||
|
||||
it('should support calling methods on non nulls', fakeAsync(() => {
|
||||
var ctx = _bindSimpleValue('address?.toString()', Person);
|
||||
const ctx = _bindSimpleValue('address?.toString()', Person);
|
||||
ctx.componentInstance.address = new Address('MTV');
|
||||
ctx.detectChanges(false);
|
||||
expect(renderLog.log).toEqual(['someProp=MTV']);
|
||||
@ -317,27 +317,27 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should support method calls', fakeAsync(() => {
|
||||
var ctx = _bindSimpleValue('sayHi("Jim")', Person);
|
||||
const ctx = _bindSimpleValue('sayHi("Jim")', Person);
|
||||
ctx.detectChanges(false);
|
||||
expect(renderLog.log).toEqual(['someProp=Hi, Jim']);
|
||||
}));
|
||||
|
||||
it('should support function calls', fakeAsync(() => {
|
||||
var ctx = _bindSimpleValue('a()(99)', TestData);
|
||||
const ctx = _bindSimpleValue('a()(99)', TestData);
|
||||
ctx.componentInstance.a = () => (a: any) => a;
|
||||
ctx.detectChanges(false);
|
||||
expect(renderLog.log).toEqual(['someProp=99']);
|
||||
}));
|
||||
|
||||
it('should support chained method calls', fakeAsync(() => {
|
||||
var ctx = _bindSimpleValue('address.toString()', Person);
|
||||
const ctx = _bindSimpleValue('address.toString()', Person);
|
||||
ctx.componentInstance.address = new Address('MTV');
|
||||
ctx.detectChanges(false);
|
||||
expect(renderLog.log).toEqual(['someProp=MTV']);
|
||||
}));
|
||||
|
||||
it('should support NaN', fakeAsync(() => {
|
||||
var ctx = _bindSimpleValue('age', Person);
|
||||
const ctx = _bindSimpleValue('age', Person);
|
||||
ctx.componentInstance.age = NaN;
|
||||
ctx.detectChanges(false);
|
||||
|
||||
@ -349,7 +349,7 @@ export function main() {
|
||||
}));
|
||||
|
||||
it('should do simple watching', fakeAsync(() => {
|
||||
var ctx = _bindSimpleValue('name', Person);
|
||||
const ctx = _bindSimpleValue('name', Person);
|
||||
ctx.componentInstance.name = 'misko';
|
||||
|
||||
ctx.detectChanges(false);
|
||||
@ -366,26 +366,26 @@ export function main() {
|
||||
}));
|
||||
|
||||
it('should support literal array made of literals', fakeAsync(() => {
|
||||
var ctx = _bindSimpleValue('[1, 2]');
|
||||
const ctx = _bindSimpleValue('[1, 2]');
|
||||
ctx.detectChanges(false);
|
||||
expect(renderLog.loggedValues).toEqual([[1, 2]]);
|
||||
}));
|
||||
|
||||
it('should support empty literal array', fakeAsync(() => {
|
||||
var ctx = _bindSimpleValue('[]');
|
||||
const ctx = _bindSimpleValue('[]');
|
||||
ctx.detectChanges(false);
|
||||
expect(renderLog.loggedValues).toEqual([[]]);
|
||||
}));
|
||||
|
||||
it('should support literal array made of expressions', fakeAsync(() => {
|
||||
var ctx = _bindSimpleValue('[1, a]', TestData);
|
||||
const ctx = _bindSimpleValue('[1, a]', TestData);
|
||||
ctx.componentInstance.a = 2;
|
||||
ctx.detectChanges(false);
|
||||
expect(renderLog.loggedValues).toEqual([[1, 2]]);
|
||||
}));
|
||||
|
||||
it('should not recreate literal arrays unless their content changed', fakeAsync(() => {
|
||||
var ctx = _bindSimpleValue('[1, a]', TestData);
|
||||
const ctx = _bindSimpleValue('[1, a]', TestData);
|
||||
ctx.componentInstance.a = 2;
|
||||
ctx.detectChanges(false);
|
||||
ctx.detectChanges(false);
|
||||
@ -396,26 +396,26 @@ export function main() {
|
||||
}));
|
||||
|
||||
it('should support literal maps made of literals', fakeAsync(() => {
|
||||
var ctx = _bindSimpleValue('{z: 1}');
|
||||
const ctx = _bindSimpleValue('{z: 1}');
|
||||
ctx.detectChanges(false);
|
||||
expect(renderLog.loggedValues[0]['z']).toEqual(1);
|
||||
}));
|
||||
|
||||
it('should support empty literal map', fakeAsync(() => {
|
||||
var ctx = _bindSimpleValue('{}');
|
||||
const ctx = _bindSimpleValue('{}');
|
||||
ctx.detectChanges(false);
|
||||
expect(renderLog.loggedValues).toEqual([{}]);
|
||||
}));
|
||||
|
||||
it('should support literal maps made of expressions', fakeAsync(() => {
|
||||
var ctx = _bindSimpleValue('{z: a}');
|
||||
const ctx = _bindSimpleValue('{z: a}');
|
||||
ctx.componentInstance.a = 1;
|
||||
ctx.detectChanges(false);
|
||||
expect(renderLog.loggedValues[0]['z']).toEqual(1);
|
||||
}));
|
||||
|
||||
it('should not recreate literal maps unless their content changed', fakeAsync(() => {
|
||||
var ctx = _bindSimpleValue('{z: a}');
|
||||
const ctx = _bindSimpleValue('{z: a}');
|
||||
ctx.componentInstance.a = 1;
|
||||
ctx.detectChanges(false);
|
||||
ctx.detectChanges(false);
|
||||
@ -429,7 +429,7 @@ export function main() {
|
||||
|
||||
|
||||
it('should ignore empty bindings', fakeAsync(() => {
|
||||
var ctx = _bindSimpleProp('[someProp]', TestData);
|
||||
const ctx = _bindSimpleProp('[someProp]', TestData);
|
||||
ctx.componentInstance.a = 'value';
|
||||
ctx.detectChanges(false);
|
||||
|
||||
@ -437,7 +437,7 @@ export function main() {
|
||||
}));
|
||||
|
||||
it('should support interpolation', fakeAsync(() => {
|
||||
var ctx = _bindSimpleProp('someProp="B{{a}}A"', TestData);
|
||||
const ctx = _bindSimpleProp('someProp="B{{a}}A"', TestData);
|
||||
ctx.componentInstance.a = 'value';
|
||||
ctx.detectChanges(false);
|
||||
|
||||
@ -445,7 +445,7 @@ export function main() {
|
||||
}));
|
||||
|
||||
it('should output empty strings for null values in interpolation', fakeAsync(() => {
|
||||
var ctx = _bindSimpleProp('someProp="B{{a}}A"', TestData);
|
||||
const ctx = _bindSimpleProp('someProp="B{{a}}A"', TestData);
|
||||
ctx.componentInstance.a = null;
|
||||
ctx.detectChanges(false);
|
||||
|
||||
@ -456,7 +456,7 @@ export function main() {
|
||||
fakeAsync(() => { expect(_bindAndCheckSimpleValue('"$"')).toEqual(['someProp=$']); }));
|
||||
|
||||
it('should read locals', fakeAsync(() => {
|
||||
var ctx =
|
||||
const ctx =
|
||||
createCompFixture('<template testLocals let-local="someLocal">{{local}}</template>');
|
||||
ctx.detectChanges(false);
|
||||
|
||||
@ -465,14 +465,14 @@ export function main() {
|
||||
|
||||
describe('pipes', () => {
|
||||
it('should use the return value of the pipe', fakeAsync(() => {
|
||||
var ctx = _bindSimpleValue('name | countingPipe', Person);
|
||||
const ctx = _bindSimpleValue('name | countingPipe', Person);
|
||||
ctx.componentInstance.name = 'bob';
|
||||
ctx.detectChanges(false);
|
||||
expect(renderLog.loggedValues).toEqual(['bob state:0']);
|
||||
}));
|
||||
|
||||
it('should support arguments in pipes', fakeAsync(() => {
|
||||
var ctx = _bindSimpleValue('name | multiArgPipe:"one":address.city', Person);
|
||||
const ctx = _bindSimpleValue('name | multiArgPipe:"one":address.city', Person);
|
||||
ctx.componentInstance.name = 'value';
|
||||
ctx.componentInstance.address = new Address('two');
|
||||
ctx.detectChanges(false);
|
||||
@ -480,21 +480,22 @@ export function main() {
|
||||
}));
|
||||
|
||||
it('should associate pipes right-to-left', fakeAsync(() => {
|
||||
var ctx = _bindSimpleValue('name | multiArgPipe:"a":"b" | multiArgPipe:0:1', Person);
|
||||
const ctx = _bindSimpleValue('name | multiArgPipe:"a":"b" | multiArgPipe:0:1', Person);
|
||||
ctx.componentInstance.name = 'value';
|
||||
ctx.detectChanges(false);
|
||||
expect(renderLog.loggedValues).toEqual(['value a b default 0 1 default']);
|
||||
}));
|
||||
|
||||
it('should support calling pure pipes with different number of arguments', fakeAsync(() => {
|
||||
var ctx = _bindSimpleValue('name | multiArgPipe:"a":"b" | multiArgPipe:0:1:2', Person);
|
||||
const ctx =
|
||||
_bindSimpleValue('name | multiArgPipe:"a":"b" | multiArgPipe:0:1:2', Person);
|
||||
ctx.componentInstance.name = 'value';
|
||||
ctx.detectChanges(false);
|
||||
expect(renderLog.loggedValues).toEqual(['value a b default 0 1 2']);
|
||||
}));
|
||||
|
||||
it('should do nothing when no change', fakeAsync(() => {
|
||||
var ctx = _bindSimpleValue('"Megatron" | identityPipe', Person);
|
||||
const ctx = _bindSimpleValue('"Megatron" | identityPipe', Person);
|
||||
|
||||
ctx.detectChanges(false);
|
||||
|
||||
@ -507,7 +508,7 @@ export function main() {
|
||||
}));
|
||||
|
||||
it('should unwrap the wrapped value', fakeAsync(() => {
|
||||
var ctx = _bindSimpleValue('"Megatron" | wrappedPipe', Person);
|
||||
const ctx = _bindSimpleValue('"Megatron" | wrappedPipe', Person);
|
||||
|
||||
ctx.detectChanges(false);
|
||||
|
||||
@ -520,7 +521,7 @@ export function main() {
|
||||
}));
|
||||
|
||||
it('should call pure pipes only if the arguments change', fakeAsync(() => {
|
||||
var ctx = _bindSimpleValue('name | countingPipe', Person);
|
||||
const ctx = _bindSimpleValue('name | countingPipe', Person);
|
||||
// change from undefined -> null
|
||||
ctx.componentInstance.name = null;
|
||||
ctx.detectChanges(false);
|
||||
@ -550,7 +551,7 @@ export function main() {
|
||||
|
||||
it('should call pure pipes that are used multiple times only when the arguments change',
|
||||
fakeAsync(() => {
|
||||
var ctx = createCompFixture(
|
||||
const ctx = createCompFixture(
|
||||
`<div [someProp]="name | countingPipe"></div><div [someProp]="age | countingPipe"></div>` +
|
||||
'<div *ngFor="let x of [1,2]" [someProp]="address.city | countingPipe"></div>',
|
||||
Person);
|
||||
@ -573,7 +574,7 @@ export function main() {
|
||||
}));
|
||||
|
||||
it('should call impure pipes on each change detection run', fakeAsync(() => {
|
||||
var ctx = _bindSimpleValue('name | countingImpurePipe', Person);
|
||||
const ctx = _bindSimpleValue('name | countingImpurePipe', Person);
|
||||
ctx.componentInstance.name = 'bob';
|
||||
ctx.detectChanges(false);
|
||||
expect(renderLog.loggedValues).toEqual(['bob state:0']);
|
||||
@ -584,9 +585,9 @@ export function main() {
|
||||
|
||||
describe('event expressions', () => {
|
||||
it('should support field assignments', fakeAsync(() => {
|
||||
var ctx = _bindSimpleProp('(event)="b=a=$event"');
|
||||
var childEl = ctx.debugElement.children[0];
|
||||
var evt = 'EVENT';
|
||||
const ctx = _bindSimpleProp('(event)="b=a=$event"');
|
||||
const childEl = ctx.debugElement.children[0];
|
||||
const evt = 'EVENT';
|
||||
childEl.triggerEventHandler('event', evt);
|
||||
|
||||
expect(ctx.componentInstance.a).toEqual(evt);
|
||||
@ -594,17 +595,17 @@ export function main() {
|
||||
}));
|
||||
|
||||
it('should support keyed assignments', fakeAsync(() => {
|
||||
var ctx = _bindSimpleProp('(event)="a[0]=$event"');
|
||||
var childEl = ctx.debugElement.children[0];
|
||||
const ctx = _bindSimpleProp('(event)="a[0]=$event"');
|
||||
const childEl = ctx.debugElement.children[0];
|
||||
ctx.componentInstance.a = ['OLD'];
|
||||
var evt = 'EVENT';
|
||||
const evt = 'EVENT';
|
||||
childEl.triggerEventHandler('event', evt);
|
||||
expect(ctx.componentInstance.a).toEqual([evt]);
|
||||
}));
|
||||
|
||||
it('should support chains', fakeAsync(() => {
|
||||
var ctx = _bindSimpleProp('(event)="a=a+1; a=a+1;"');
|
||||
var childEl = ctx.debugElement.children[0];
|
||||
const ctx = _bindSimpleProp('(event)="a=a+1; a=a+1;"');
|
||||
const childEl = ctx.debugElement.children[0];
|
||||
ctx.componentInstance.a = 0;
|
||||
childEl.triggerEventHandler('event', 'EVENT');
|
||||
expect(ctx.componentInstance.a).toEqual(2);
|
||||
@ -617,8 +618,8 @@ export function main() {
|
||||
}));
|
||||
|
||||
it('should support short-circuiting', fakeAsync(() => {
|
||||
var ctx = _bindSimpleProp('(event)="true ? a = a + 1 : a = a + 1"');
|
||||
var childEl = ctx.debugElement.children[0];
|
||||
const ctx = _bindSimpleProp('(event)="true ? a = a + 1 : a = a + 1"');
|
||||
const childEl = ctx.debugElement.children[0];
|
||||
ctx.componentInstance.a = 0;
|
||||
childEl.triggerEventHandler('event', 'EVENT');
|
||||
expect(ctx.componentInstance.a).toEqual(1);
|
||||
@ -630,7 +631,7 @@ export function main() {
|
||||
describe('change notification', () => {
|
||||
describe('updating directives', () => {
|
||||
it('should happen without invoking the renderer', fakeAsync(() => {
|
||||
var ctx = createCompFixture('<div testDirective [a]="42"></div>');
|
||||
const ctx = createCompFixture('<div testDirective [a]="42"></div>');
|
||||
ctx.detectChanges(false);
|
||||
expect(renderLog.log).toEqual([]);
|
||||
expect(queryDirs(ctx.debugElement, TestDirective)[0].a).toEqual(42);
|
||||
@ -639,7 +640,7 @@ export function main() {
|
||||
|
||||
describe('reading directives', () => {
|
||||
it('should read directive properties', fakeAsync(() => {
|
||||
var ctx = createCompFixture(
|
||||
const ctx = createCompFixture(
|
||||
'<div testDirective [a]="42" ref-dir="testDirective" [someProp]="dir.a"></div>');
|
||||
ctx.detectChanges(false);
|
||||
expect(renderLog.loggedValues).toEqual([42]);
|
||||
@ -648,11 +649,11 @@ export function main() {
|
||||
|
||||
describe('ngOnChanges', () => {
|
||||
it('should notify the directive when a group of records changes', fakeAsync(() => {
|
||||
var ctx = createCompFixture(
|
||||
const ctx = createCompFixture(
|
||||
'<div [testDirective]="\'aName\'" [a]="1" [b]="2"></div><div [testDirective]="\'bName\'" [a]="4"></div>');
|
||||
ctx.detectChanges(false);
|
||||
|
||||
var dirs = queryDirs(ctx.debugElement, TestDirective);
|
||||
const dirs = queryDirs(ctx.debugElement, TestDirective);
|
||||
expect(dirs[0].changes).toEqual({'a': 1, 'b': 2, 'name': 'aName'});
|
||||
expect(dirs[1].changes).toEqual({'a': 4, 'name': 'bName'});
|
||||
}));
|
||||
@ -675,7 +676,7 @@ export function main() {
|
||||
|
||||
describe('ngOnInit', () => {
|
||||
it('should be called after ngOnChanges', fakeAsync(() => {
|
||||
var ctx = createCompFixture('<div testDirective="dir"></div>');
|
||||
const ctx = createCompFixture('<div testDirective="dir"></div>');
|
||||
expect(directiveLog.filter(['ngOnInit', 'ngOnChanges'])).toEqual([]);
|
||||
|
||||
ctx.detectChanges(false);
|
||||
@ -691,7 +692,7 @@ export function main() {
|
||||
}));
|
||||
|
||||
it('should only be called only once', fakeAsync(() => {
|
||||
var ctx = createCompFixture('<div testDirective="dir"></div>');
|
||||
const ctx = createCompFixture('<div testDirective="dir"></div>');
|
||||
|
||||
ctx.detectChanges(false);
|
||||
|
||||
@ -712,9 +713,9 @@ export function main() {
|
||||
}));
|
||||
|
||||
it('should not call ngOnInit again if it throws', fakeAsync(() => {
|
||||
var ctx = createCompFixture('<div testDirective="dir" throwOn="ngOnInit"></div>');
|
||||
const ctx = createCompFixture('<div testDirective="dir" throwOn="ngOnInit"></div>');
|
||||
|
||||
var errored = false;
|
||||
let errored = false;
|
||||
// First pass fails, but ngOnInit should be called.
|
||||
try {
|
||||
ctx.detectChanges(false);
|
||||
@ -738,7 +739,7 @@ export function main() {
|
||||
|
||||
describe('ngDoCheck', () => {
|
||||
it('should be called after ngOnInit', fakeAsync(() => {
|
||||
var ctx = createCompFixture('<div testDirective="dir"></div>');
|
||||
const ctx = createCompFixture('<div testDirective="dir"></div>');
|
||||
|
||||
ctx.detectChanges(false);
|
||||
expect(directiveLog.filter(['ngDoCheck', 'ngOnInit'])).toEqual([
|
||||
@ -748,7 +749,7 @@ export function main() {
|
||||
|
||||
it('should be called on every detectChanges run, except for checkNoChanges',
|
||||
fakeAsync(() => {
|
||||
var ctx = createCompFixture('<div testDirective="dir"></div>');
|
||||
const ctx = createCompFixture('<div testDirective="dir"></div>');
|
||||
|
||||
ctx.detectChanges(false);
|
||||
|
||||
@ -772,7 +773,7 @@ export function main() {
|
||||
describe('ngAfterContentInit', () => {
|
||||
it('should be called after processing the content children but before the view children',
|
||||
fakeAsync(() => {
|
||||
var ctx = createCompWithContentAndViewChild();
|
||||
const ctx = createCompWithContentAndViewChild();
|
||||
ctx.detectChanges(false);
|
||||
|
||||
expect(directiveLog.filter(['ngDoCheck', 'ngAfterContentInit'])).toEqual([
|
||||
@ -782,7 +783,7 @@ export function main() {
|
||||
}));
|
||||
|
||||
it('should only be called only once', fakeAsync(() => {
|
||||
var ctx = createCompFixture('<div testDirective="dir"></div>');
|
||||
const ctx = createCompFixture('<div testDirective="dir"></div>');
|
||||
|
||||
ctx.detectChanges(false);
|
||||
|
||||
@ -805,10 +806,10 @@ export function main() {
|
||||
}));
|
||||
|
||||
it('should not call ngAfterContentInit again if it throws', fakeAsync(() => {
|
||||
var ctx =
|
||||
const ctx =
|
||||
createCompFixture('<div testDirective="dir" throwOn="ngAfterContentInit"></div>');
|
||||
|
||||
var errored = false;
|
||||
let errored = false;
|
||||
// First pass fails, but ngAfterContentInit should be called.
|
||||
try {
|
||||
ctx.detectChanges(false);
|
||||
@ -836,7 +837,7 @@ export function main() {
|
||||
describe('ngAfterContentChecked', () => {
|
||||
it('should be called after the content children but before the view children',
|
||||
fakeAsync(() => {
|
||||
var ctx = createCompWithContentAndViewChild();
|
||||
const ctx = createCompWithContentAndViewChild();
|
||||
|
||||
ctx.detectChanges(false);
|
||||
|
||||
@ -849,7 +850,7 @@ export function main() {
|
||||
|
||||
it('should be called on every detectChanges run, except for checkNoChanges',
|
||||
fakeAsync(() => {
|
||||
var ctx = createCompFixture('<div testDirective="dir"></div>');
|
||||
const ctx = createCompFixture('<div testDirective="dir"></div>');
|
||||
|
||||
ctx.detectChanges(false);
|
||||
|
||||
@ -875,7 +876,7 @@ export function main() {
|
||||
|
||||
it('should be called in reverse order so the child is always notified before the parent',
|
||||
fakeAsync(() => {
|
||||
var ctx = createCompFixture(
|
||||
const ctx = createCompFixture(
|
||||
'<div testDirective="parent"><div testDirective="child"></div></div>');
|
||||
|
||||
ctx.detectChanges(false);
|
||||
@ -889,7 +890,7 @@ export function main() {
|
||||
|
||||
describe('ngAfterViewInit', () => {
|
||||
it('should be called after processing the view children', fakeAsync(() => {
|
||||
var ctx = createCompWithContentAndViewChild();
|
||||
const ctx = createCompWithContentAndViewChild();
|
||||
|
||||
ctx.detectChanges(false);
|
||||
|
||||
@ -900,7 +901,7 @@ export function main() {
|
||||
}));
|
||||
|
||||
it('should only be called only once', fakeAsync(() => {
|
||||
var ctx = createCompFixture('<div testDirective="dir"></div>');
|
||||
const ctx = createCompFixture('<div testDirective="dir"></div>');
|
||||
|
||||
ctx.detectChanges(false);
|
||||
|
||||
@ -921,10 +922,10 @@ export function main() {
|
||||
}));
|
||||
|
||||
it('should not call ngAfterViewInit again if it throws', fakeAsync(() => {
|
||||
var ctx =
|
||||
const ctx =
|
||||
createCompFixture('<div testDirective="dir" throwOn="ngAfterViewInit"></div>');
|
||||
|
||||
var errored = false;
|
||||
let errored = false;
|
||||
// First pass fails, but ngAfterViewInit should be called.
|
||||
try {
|
||||
ctx.detectChanges(false);
|
||||
@ -949,7 +950,7 @@ export function main() {
|
||||
|
||||
describe('ngAfterViewChecked', () => {
|
||||
it('should be called after processing the view children', fakeAsync(() => {
|
||||
var ctx = createCompWithContentAndViewChild();
|
||||
const ctx = createCompWithContentAndViewChild();
|
||||
|
||||
ctx.detectChanges(false);
|
||||
|
||||
@ -961,7 +962,7 @@ export function main() {
|
||||
|
||||
it('should be called on every detectChanges run, except for checkNoChanges',
|
||||
fakeAsync(() => {
|
||||
var ctx = createCompFixture('<div testDirective="dir"></div>');
|
||||
const ctx = createCompFixture('<div testDirective="dir"></div>');
|
||||
|
||||
ctx.detectChanges(false);
|
||||
|
||||
@ -987,7 +988,7 @@ export function main() {
|
||||
|
||||
it('should be called in reverse order so the child is always notified before the parent',
|
||||
fakeAsync(() => {
|
||||
var ctx = createCompFixture(
|
||||
const ctx = createCompFixture(
|
||||
'<div testDirective="parent"><div testDirective="child"></div></div>');
|
||||
|
||||
ctx.detectChanges(false);
|
||||
@ -1000,7 +1001,7 @@ export function main() {
|
||||
|
||||
describe('ngOnDestroy', () => {
|
||||
it('should be called on view destruction', fakeAsync(() => {
|
||||
var ctx = createCompFixture('<div testDirective="dir"></div>');
|
||||
const ctx = createCompFixture('<div testDirective="dir"></div>');
|
||||
ctx.detectChanges(false);
|
||||
|
||||
ctx.destroy();
|
||||
@ -1014,7 +1015,7 @@ export function main() {
|
||||
{selector: 'other-cmp', template: '<div testDirective="viewChild"></div>'})
|
||||
});
|
||||
|
||||
var ctx = createCompFixture(
|
||||
const ctx = createCompFixture(
|
||||
'<div testDirective="parent"><div *ngFor="let x of [0,1]" testDirective="contentChild{{x}}"></div>' +
|
||||
'<other-cmp></other-cmp></div>',
|
||||
TestComponent);
|
||||
@ -1030,7 +1031,7 @@ export function main() {
|
||||
|
||||
it('should be called in reverse order so the child is always notified before the parent',
|
||||
fakeAsync(() => {
|
||||
var ctx = createCompFixture(
|
||||
const ctx = createCompFixture(
|
||||
'<div testDirective="parent"><div testDirective="child"></div></div>');
|
||||
|
||||
ctx.detectChanges(false);
|
||||
@ -1042,7 +1043,7 @@ export function main() {
|
||||
}));
|
||||
|
||||
it('should deliver synchronous events to parent', fakeAsync(() => {
|
||||
var ctx = createCompFixture('<div (destroy)="a=$event" onDestroyDirective></div>');
|
||||
const ctx = createCompFixture('<div (destroy)="a=$event" onDestroyDirective></div>');
|
||||
|
||||
ctx.detectChanges(false);
|
||||
ctx.destroy();
|
||||
@ -1051,7 +1052,7 @@ export function main() {
|
||||
}));
|
||||
|
||||
it('should call ngOnDestroy on pipes', fakeAsync(() => {
|
||||
var ctx = createCompFixture('{{true | pipeWithOnDestroy }}');
|
||||
const ctx = createCompFixture('{{true | pipeWithOnDestroy }}');
|
||||
|
||||
ctx.detectChanges(false);
|
||||
ctx.destroy();
|
||||
@ -1065,7 +1066,7 @@ export function main() {
|
||||
TestBed.overrideDirective(
|
||||
TestDirective, {set: {providers: [InjectableWithLifecycle]}});
|
||||
|
||||
var ctx = createCompFixture('<div testDirective="dir"></div>', TestComponent);
|
||||
const ctx = createCompFixture('<div testDirective="dir"></div>', TestComponent);
|
||||
|
||||
ctx.debugElement.children[0].injector.get(InjectableWithLifecycle);
|
||||
ctx.detectChanges(false);
|
||||
@ -1116,8 +1117,8 @@ export function main() {
|
||||
|
||||
describe('mode', () => {
|
||||
it('Detached', fakeAsync(() => {
|
||||
var ctx = createCompFixture('<comp-with-ref></comp-with-ref>');
|
||||
var cmp: CompWithRef = queryDirs(ctx.debugElement, CompWithRef)[0];
|
||||
const ctx = createCompFixture('<comp-with-ref></comp-with-ref>');
|
||||
const cmp: CompWithRef = queryDirs(ctx.debugElement, CompWithRef)[0];
|
||||
cmp.value = 'hello';
|
||||
cmp.changeDetectorRef.detach();
|
||||
|
||||
@ -1127,8 +1128,8 @@ export function main() {
|
||||
}));
|
||||
|
||||
it('Reattaches', fakeAsync(() => {
|
||||
var ctx = createCompFixture('<comp-with-ref></comp-with-ref>');
|
||||
var cmp: CompWithRef = queryDirs(ctx.debugElement, CompWithRef)[0];
|
||||
const ctx = createCompFixture('<comp-with-ref></comp-with-ref>');
|
||||
const cmp: CompWithRef = queryDirs(ctx.debugElement, CompWithRef)[0];
|
||||
|
||||
cmp.value = 'hello';
|
||||
cmp.changeDetectorRef.detach();
|
||||
@ -1146,8 +1147,8 @@ export function main() {
|
||||
}));
|
||||
|
||||
it('Reattaches in the original cd mode', fakeAsync(() => {
|
||||
var ctx = createCompFixture('<push-cmp></push-cmp>');
|
||||
var cmp: PushComp = queryDirs(ctx.debugElement, PushComp)[0];
|
||||
const ctx = createCompFixture('<push-cmp></push-cmp>');
|
||||
const cmp: PushComp = queryDirs(ctx.debugElement, PushComp)[0];
|
||||
cmp.changeDetectorRef.detach();
|
||||
cmp.changeDetectorRef.reattach();
|
||||
|
||||
@ -1155,7 +1156,7 @@ export function main() {
|
||||
// on-push
|
||||
ctx.detectChanges();
|
||||
expect(cmp.renderCount).toBeGreaterThan(0);
|
||||
var count = cmp.renderCount;
|
||||
const count = cmp.renderCount;
|
||||
|
||||
ctx.detectChanges();
|
||||
expect(cmp.renderCount).toBe(count);
|
||||
@ -1166,7 +1167,7 @@ export function main() {
|
||||
|
||||
describe('multi directive order', () => {
|
||||
it('should follow the DI order for the same element', fakeAsync(() => {
|
||||
var ctx =
|
||||
const ctx =
|
||||
createCompFixture('<div orderCheck2="2" orderCheck0="0" orderCheck1="1"></div>');
|
||||
|
||||
ctx.detectChanges(false);
|
||||
@ -1525,7 +1526,7 @@ class Person {
|
||||
passThrough(val: any): any { return val; }
|
||||
|
||||
toString(): string {
|
||||
var address = this.address == null ? '' : ' address=' + this.address.toString();
|
||||
const address = this.address == null ? '' : ' address=' + this.address.toString();
|
||||
|
||||
return 'name=' + this.name + address;
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ class DummyConsole implements Console {
|
||||
|
||||
function declareTests({useJit}: {useJit: boolean}) {
|
||||
describe('@Component.entryComponents', function() {
|
||||
var console: DummyConsole;
|
||||
let console: DummyConsole;
|
||||
beforeEach(() => {
|
||||
console = new DummyConsole();
|
||||
TestBed.configureCompiler(
|
||||
@ -37,9 +37,9 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
|
||||
it('should resolve ComponentFactories from the same component', () => {
|
||||
const compFixture = TestBed.createComponent(MainComp);
|
||||
let mainComp: MainComp = compFixture.componentInstance;
|
||||
const mainComp: MainComp = compFixture.componentInstance;
|
||||
expect(compFixture.componentRef.injector.get(ComponentFactoryResolver)).toBe(mainComp.cfr);
|
||||
var cf = mainComp.cfr.resolveComponentFactory(ChildComp);
|
||||
const cf = mainComp.cfr.resolveComponentFactory(ChildComp);
|
||||
expect(cf.componentType).toBe(ChildComp);
|
||||
});
|
||||
|
||||
@ -47,9 +47,9 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
TestBed.resetTestingModule();
|
||||
TestBed.configureTestingModule(
|
||||
{declarations: [CompWithAnalyzeEntryComponentsProvider, NestedChildComp, ChildComp]});
|
||||
let compFixture = TestBed.createComponent(CompWithAnalyzeEntryComponentsProvider);
|
||||
let mainComp: CompWithAnalyzeEntryComponentsProvider = compFixture.componentInstance;
|
||||
let cfr: ComponentFactoryResolver =
|
||||
const compFixture = TestBed.createComponent(CompWithAnalyzeEntryComponentsProvider);
|
||||
const mainComp: CompWithAnalyzeEntryComponentsProvider = compFixture.componentInstance;
|
||||
const cfr: ComponentFactoryResolver =
|
||||
compFixture.componentRef.injector.get(ComponentFactoryResolver);
|
||||
expect(cfr.resolveComponentFactory(ChildComp).componentType).toBe(ChildComp);
|
||||
expect(cfr.resolveComponentFactory(NestedChildComp).componentType).toBe(NestedChildComp);
|
||||
@ -59,8 +59,8 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
TestBed.overrideComponent(MainComp, {set: {template: '<child></child>'}});
|
||||
|
||||
const compFixture = TestBed.createComponent(MainComp);
|
||||
let childCompEl = compFixture.debugElement.children[0];
|
||||
let childComp: ChildComp = childCompEl.componentInstance;
|
||||
const childCompEl = compFixture.debugElement.children[0];
|
||||
const childComp: ChildComp = childCompEl.componentInstance;
|
||||
// declared on ChildComp directly
|
||||
expect(childComp.cfr.resolveComponentFactory(NestedChildComp).componentType)
|
||||
.toBe(NestedChildComp);
|
||||
@ -73,8 +73,8 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
TestBed.overrideComponent(ChildComp, {set: {template: '<ng-content></ng-content>'}});
|
||||
|
||||
const compFixture = TestBed.createComponent(MainComp);
|
||||
let nestedChildCompEl = compFixture.debugElement.children[0].children[0];
|
||||
let nestedChildComp: NestedChildComp = nestedChildCompEl.componentInstance;
|
||||
const nestedChildCompEl = compFixture.debugElement.children[0].children[0];
|
||||
const nestedChildComp: NestedChildComp = nestedChildCompEl.componentInstance;
|
||||
expect(nestedChildComp.cfr.resolveComponentFactory(ChildComp).componentType).toBe(ChildComp);
|
||||
expect(() => nestedChildComp.cfr.resolveComponentFactory(NestedChildComp))
|
||||
.toThrow(new NoComponentFactoryError(NestedChildComp));
|
||||
|
@ -208,7 +208,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
|
||||
var nativeEl = fixture.debugElement.children[0].nativeElement;
|
||||
const nativeEl = fixture.debugElement.children[0].nativeElement;
|
||||
fixture.componentInstance.ctxProp = 'foo bar';
|
||||
fixture.detectChanges();
|
||||
|
||||
@ -244,7 +244,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
fixture.componentInstance.ctxProp = 'Hello World!';
|
||||
fixture.detectChanges();
|
||||
|
||||
var containerSpan = fixture.debugElement.children[0];
|
||||
const containerSpan = fixture.debugElement.children[0];
|
||||
|
||||
expect(containerSpan.children[0].injector.get(MyDir).dirProp).toEqual('Hello World!');
|
||||
expect(containerSpan.children[1].injector.get(MyDir).dirProp).toEqual('Hi there!');
|
||||
@ -263,7 +263,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
fixture.componentInstance.ctxProp = 'a';
|
||||
fixture.detectChanges();
|
||||
|
||||
var dir = fixture.debugElement.children[0].references['dir'];
|
||||
const dir = fixture.debugElement.children[0].references['dir'];
|
||||
expect(dir.dirProp).toEqual('aa');
|
||||
});
|
||||
});
|
||||
@ -289,7 +289,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
fixture.componentInstance.ctxProp = 'Hello World!';
|
||||
fixture.detectChanges();
|
||||
|
||||
var tc = fixture.debugElement.children[0];
|
||||
const tc = fixture.debugElement.children[0];
|
||||
|
||||
expect(tc.injector.get(MyDir).dirProp).toEqual('Hello World!');
|
||||
expect(tc.injector.get(ChildComp).dirProp).toEqual(null);
|
||||
@ -317,8 +317,8 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
|
||||
var tc = fixture.debugElement.children[0];
|
||||
var idDir = tc.injector.get(IdDir);
|
||||
const tc = fixture.debugElement.children[0];
|
||||
const idDir = tc.injector.get(IdDir);
|
||||
|
||||
fixture.componentInstance.ctxProp = 'some_id';
|
||||
fixture.detectChanges();
|
||||
@ -335,7 +335,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
|
||||
var tc = fixture.debugElement.children[0];
|
||||
const tc = fixture.debugElement.children[0];
|
||||
expect(tc.injector.get(EventDir)).not.toBe(null);
|
||||
});
|
||||
|
||||
@ -355,7 +355,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
var childNodesOfWrapper = getDOM().childNodes(fixture.nativeElement);
|
||||
const childNodesOfWrapper = getDOM().childNodes(fixture.nativeElement);
|
||||
// 1 template + 2 copies.
|
||||
expect(childNodesOfWrapper.length).toBe(3);
|
||||
expect(childNodesOfWrapper[1]).toHaveText('hello');
|
||||
@ -383,8 +383,8 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
fixture.componentInstance.ctxBoolProp = true;
|
||||
fixture.detectChanges();
|
||||
|
||||
var ngIfEl = fixture.debugElement.children[0];
|
||||
var someViewport: SomeViewport = ngIfEl.childNodes[0].injector.get(SomeViewport);
|
||||
const ngIfEl = fixture.debugElement.children[0];
|
||||
const someViewport: SomeViewport = ngIfEl.childNodes[0].injector.get(SomeViewport);
|
||||
expect(someViewport.container.length).toBe(2);
|
||||
expect(ngIfEl.children.length).toBe(2);
|
||||
|
||||
@ -401,7 +401,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
|
||||
var childNodesOfWrapper = getDOM().childNodes(fixture.nativeElement);
|
||||
const childNodesOfWrapper = getDOM().childNodes(fixture.nativeElement);
|
||||
expect(childNodesOfWrapper.length).toBe(1);
|
||||
expect(getDOM().isCommentNode(childNodesOfWrapper[0])).toBe(true);
|
||||
});
|
||||
@ -415,7 +415,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
var childNodesOfWrapper = getDOM().childNodes(fixture.nativeElement);
|
||||
const childNodesOfWrapper = getDOM().childNodes(fixture.nativeElement);
|
||||
// 1 template + 2 copies.
|
||||
expect(childNodesOfWrapper.length).toBe(3);
|
||||
expect(childNodesOfWrapper[1]).toHaveText('hello');
|
||||
@ -483,10 +483,10 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
|
||||
var pEl = fixture.debugElement.children[0];
|
||||
const pEl = fixture.debugElement.children[0];
|
||||
|
||||
var alice = pEl.children[0].references['alice'];
|
||||
var bob = pEl.children[1].references['bob'];
|
||||
const alice = pEl.children[0].references['alice'];
|
||||
const bob = pEl.children[1].references['bob'];
|
||||
expect(alice).toBeAnInstanceOf(ChildComp);
|
||||
expect(bob).toBeAnInstanceOf(ChildComp);
|
||||
expect(alice).not.toBe(bob);
|
||||
@ -507,7 +507,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
|
||||
var value = fixture.debugElement.children[0].children[0].references['alice'];
|
||||
const value = fixture.debugElement.children[0].children[0].references['alice'];
|
||||
expect(value).not.toBe(null);
|
||||
expect(value.tagName.toLowerCase()).toEqual('div');
|
||||
});
|
||||
@ -518,7 +518,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
|
||||
var value = fixture.debugElement.childNodes[0].references['alice'];
|
||||
const value = fixture.debugElement.childNodes[0].references['alice'];
|
||||
expect(value).toBeAnInstanceOf(TemplateRef_);
|
||||
});
|
||||
|
||||
@ -555,7 +555,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
|
||||
var cmp = fixture.debugElement.children[0].references['cmp'];
|
||||
const cmp = fixture.debugElement.children[0].references['cmp'];
|
||||
|
||||
fixture.detectChanges();
|
||||
expect(cmp.numberOfChecks).toEqual(1);
|
||||
@ -576,7 +576,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
|
||||
var cmp = fixture.debugElement.children[0].references['cmp'];
|
||||
const cmp = fixture.debugElement.children[0].references['cmp'];
|
||||
|
||||
fixture.componentInstance.ctxProp = 'one';
|
||||
fixture.detectChanges();
|
||||
@ -598,8 +598,8 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
tick();
|
||||
fixture.detectChanges();
|
||||
|
||||
var cmpEl = fixture.debugElement.children[0];
|
||||
var cmp: PushCmpWithHostEvent = cmpEl.injector.get(PushCmpWithHostEvent);
|
||||
const cmpEl = fixture.debugElement.children[0];
|
||||
const cmp: PushCmpWithHostEvent = cmpEl.injector.get(PushCmpWithHostEvent);
|
||||
cmp.ctxCallback = (_: any) => fixture.destroy();
|
||||
|
||||
expect(() => cmpEl.triggerEventHandler('click', <Event>{})).not.toThrow();
|
||||
@ -613,8 +613,8 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
|
||||
var cmpEl = fixture.debugElement.children[0];
|
||||
var cmp = cmpEl.componentInstance;
|
||||
const cmpEl = fixture.debugElement.children[0];
|
||||
const cmp = cmpEl.componentInstance;
|
||||
fixture.detectChanges();
|
||||
fixture.detectChanges();
|
||||
expect(cmp.numberOfChecks).toEqual(1);
|
||||
@ -647,7 +647,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
|
||||
var cmp = fixture.debugElement.children[0].references['cmp'];
|
||||
const cmp = fixture.debugElement.children[0].references['cmp'];
|
||||
|
||||
fixture.componentInstance.ctxProp = 'one';
|
||||
fixture.detectChanges();
|
||||
@ -668,7 +668,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
|
||||
tick();
|
||||
|
||||
var cmp: PushCmpWithAsyncPipe = fixture.debugElement.children[0].references['cmp'];
|
||||
const cmp: PushCmpWithAsyncPipe = fixture.debugElement.children[0].references['cmp'];
|
||||
fixture.detectChanges();
|
||||
expect(cmp.numberOfChecks).toEqual(1);
|
||||
|
||||
@ -699,7 +699,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
|
||||
var childComponent =
|
||||
const childComponent =
|
||||
fixture.debugElement.children[0].children[0].children[0].references['child'];
|
||||
expect(childComponent.myHost).toBeAnInstanceOf(SomeDirective);
|
||||
});
|
||||
@ -720,9 +720,9 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
var tc = fixture.debugElement.children[0].children[0].children[0];
|
||||
const tc = fixture.debugElement.children[0].children[0].children[0];
|
||||
|
||||
var childComponent = tc.references['child'];
|
||||
const childComponent = tc.references['child'];
|
||||
expect(childComponent.myHost).toBeAnInstanceOf(SomeDirective);
|
||||
});
|
||||
|
||||
@ -733,12 +733,12 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
|
||||
var tc = fixture.debugElement.children[0];
|
||||
var emitter = tc.injector.get(DirectiveEmittingEvent);
|
||||
var listener = tc.injector.get(DirectiveListeningEvent);
|
||||
const tc = fixture.debugElement.children[0];
|
||||
const emitter = tc.injector.get(DirectiveEmittingEvent);
|
||||
const listener = tc.injector.get(DirectiveListeningEvent);
|
||||
|
||||
expect(listener.msg).toEqual('');
|
||||
var eventCount = 0;
|
||||
let eventCount = 0;
|
||||
|
||||
emitter.event.subscribe({
|
||||
next: () => {
|
||||
@ -763,11 +763,11 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
|
||||
var tc = fixture.debugElement.childNodes[0];
|
||||
const tc = fixture.debugElement.childNodes[0];
|
||||
|
||||
var emitter = tc.injector.get(DirectiveEmittingEvent);
|
||||
var myComp = fixture.debugElement.injector.get(MyComp);
|
||||
var listener = tc.injector.get(DirectiveListeningEvent);
|
||||
const emitter = tc.injector.get(DirectiveEmittingEvent);
|
||||
const myComp = fixture.debugElement.injector.get(MyComp);
|
||||
const listener = tc.injector.get(DirectiveListeningEvent);
|
||||
|
||||
myComp.ctxProp = '';
|
||||
expect(listener.msg).toEqual('');
|
||||
@ -787,8 +787,8 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
const template = '<div [(control)]="ctxProp" two-way></div>';
|
||||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
var tc = fixture.debugElement.children[0];
|
||||
var dir = tc.injector.get(DirectiveWithTwoWayBinding);
|
||||
const tc = fixture.debugElement.children[0];
|
||||
const dir = tc.injector.get(DirectiveWithTwoWayBinding);
|
||||
|
||||
fixture.componentInstance.ctxProp = 'one';
|
||||
fixture.detectChanges();
|
||||
@ -807,8 +807,8 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
|
||||
var tc = fixture.debugElement.children[0];
|
||||
var listener = tc.injector.get(DirectiveListeningDomEvent);
|
||||
const tc = fixture.debugElement.children[0];
|
||||
const listener = tc.injector.get(DirectiveListeningDomEvent);
|
||||
|
||||
dispatchEvent(tc.nativeElement, 'domEvent');
|
||||
|
||||
@ -828,8 +828,8 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
|
||||
var tc = fixture.debugElement.children[0];
|
||||
var listener = tc.injector.get(DirectiveListeningDomEvent);
|
||||
const tc = fixture.debugElement.children[0];
|
||||
const listener = tc.injector.get(DirectiveListeningDomEvent);
|
||||
dispatchEvent(getDOM().getGlobalEventTarget('window'), 'domEvent');
|
||||
expect(listener.eventTypes).toEqual(['window_domEvent']);
|
||||
|
||||
@ -874,8 +874,8 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
|
||||
var tc = fixture.debugElement.children[0];
|
||||
var updateHost = tc.injector.get(DirectiveUpdatingHostProperties);
|
||||
const tc = fixture.debugElement.children[0];
|
||||
const updateHost = tc.injector.get(DirectiveUpdatingHostProperties);
|
||||
|
||||
updateHost.id = 'newId';
|
||||
|
||||
@ -898,7 +898,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
.createComponent(MyComp);
|
||||
fixture.detectChanges();
|
||||
|
||||
var tc = fixture.debugElement.children[0];
|
||||
const tc = fixture.debugElement.children[0];
|
||||
expect(tc.properties['id']).toBe('one');
|
||||
expect(tc.properties['title']).toBe(undefined);
|
||||
});
|
||||
@ -931,9 +931,9 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
{set: {template: `<div *ngFor="let id of ['forId']" host-listener></div>`}})
|
||||
.createComponent(MyComp);
|
||||
fixture.detectChanges();
|
||||
var tc = fixture.debugElement.children[0];
|
||||
const tc = fixture.debugElement.children[0];
|
||||
tc.triggerEventHandler('click', {});
|
||||
var dir: DirectiveWithHostListener = tc.injector.get(DirectiveWithHostListener);
|
||||
const dir: DirectiveWithHostListener = tc.injector.get(DirectiveWithHostListener);
|
||||
expect(dir.receivedArgs).toEqual(['one', undefined]);
|
||||
});
|
||||
|
||||
@ -962,8 +962,8 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
|
||||
var dispatchedEvent = getDOM().createMouseEvent('click');
|
||||
var dispatchedEvent2 = getDOM().createMouseEvent('click');
|
||||
const dispatchedEvent = getDOM().createMouseEvent('click');
|
||||
const dispatchedEvent2 = getDOM().createMouseEvent('click');
|
||||
getDOM().dispatchEvent(fixture.debugElement.children[0].nativeElement, dispatchedEvent);
|
||||
getDOM().dispatchEvent(fixture.debugElement.children[1].nativeElement, dispatchedEvent2);
|
||||
expect(getDOM().isPrevented(dispatchedEvent)).toBe(true);
|
||||
@ -984,10 +984,10 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
fixture.componentInstance.ctxBoolProp = true;
|
||||
fixture.detectChanges();
|
||||
|
||||
var tc = fixture.debugElement.children[0];
|
||||
const tc = fixture.debugElement.children[0];
|
||||
|
||||
var listener = tc.injector.get(DirectiveListeningDomEvent);
|
||||
var listenerother = tc.injector.get(DirectiveListeningDomEventOther);
|
||||
const listener = tc.injector.get(DirectiveListeningDomEvent);
|
||||
const listenerother = tc.injector.get(DirectiveListeningDomEventOther);
|
||||
dispatchEvent(getDOM().getGlobalEventTarget('window'), 'domEvent');
|
||||
expect(listener.eventTypes).toEqual(['window_domEvent']);
|
||||
expect(listenerother.eventType).toEqual('other_domEvent');
|
||||
@ -1026,10 +1026,10 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
});
|
||||
|
||||
it('should allow to create a ViewContainerRef at any bound location', async(() => {
|
||||
var fixture = TestBed.configureTestingModule({schemas: [NO_ERRORS_SCHEMA]})
|
||||
.createComponent(MyComp);
|
||||
var tc = fixture.debugElement.children[0].children[0];
|
||||
var dynamicVp: DynamicViewport = tc.injector.get(DynamicViewport);
|
||||
const fixture = TestBed.configureTestingModule({schemas: [NO_ERRORS_SCHEMA]})
|
||||
.createComponent(MyComp);
|
||||
const tc = fixture.debugElement.children[0].children[0];
|
||||
const dynamicVp: DynamicViewport = tc.injector.get(DynamicViewport);
|
||||
dynamicVp.create();
|
||||
fixture.detectChanges();
|
||||
expect(fixture.debugElement.children[0].children[1].nativeElement)
|
||||
@ -1037,10 +1037,10 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
}));
|
||||
|
||||
it('should allow to create multiple ViewContainerRef at a location', async(() => {
|
||||
var fixture = TestBed.configureTestingModule({schemas: [NO_ERRORS_SCHEMA]})
|
||||
.createComponent(MyComp);
|
||||
var tc = fixture.debugElement.children[0].children[0];
|
||||
var dynamicVp: DynamicViewport = tc.injector.get(DynamicViewport);
|
||||
const fixture = TestBed.configureTestingModule({schemas: [NO_ERRORS_SCHEMA]})
|
||||
.createComponent(MyComp);
|
||||
const tc = fixture.debugElement.children[0].children[0];
|
||||
const dynamicVp: DynamicViewport = tc.injector.get(DynamicViewport);
|
||||
dynamicVp.create();
|
||||
dynamicVp.create();
|
||||
fixture.detectChanges();
|
||||
@ -1057,8 +1057,8 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
|
||||
var tc = fixture.debugElement.children[0];
|
||||
var needsAttribute = tc.injector.get(NeedsAttribute);
|
||||
const tc = fixture.debugElement.children[0];
|
||||
const needsAttribute = tc.injector.get(NeedsAttribute);
|
||||
expect(needsAttribute.typeAttribute).toEqual('text');
|
||||
expect(needsAttribute.staticAttribute).toEqual('');
|
||||
expect(needsAttribute.fooAttribute).toEqual(null);
|
||||
@ -1101,7 +1101,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
|
||||
var comp = fixture.debugElement.children[0].children[0].references['consuming'];
|
||||
const comp = fixture.debugElement.children[0].children[0].references['consuming'];
|
||||
expect(comp.injectable).toBeAnInstanceOf(InjectableService);
|
||||
});
|
||||
|
||||
@ -1117,7 +1117,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
TestBed.overrideComponent(DirectiveProvidingInjectableInView, {set: {template}});
|
||||
const fixture = TestBed.createComponent(DirectiveProvidingInjectableInView);
|
||||
|
||||
var comp = fixture.debugElement.children[0].references['consuming'];
|
||||
const comp = fixture.debugElement.children[0].references['consuming'];
|
||||
expect(comp.injectable).toBeAnInstanceOf(InjectableService);
|
||||
});
|
||||
|
||||
@ -1145,7 +1145,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
|
||||
var comp = fixture.debugElement.children[0].children[0].references['dir'];
|
||||
const comp = fixture.debugElement.children[0].children[0].references['dir'];
|
||||
expect(comp.directive.injectable).toBeAnInstanceOf(InjectableService);
|
||||
});
|
||||
|
||||
@ -1167,13 +1167,13 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
|
||||
var gpComp = fixture.debugElement.children[0];
|
||||
var parentComp = gpComp.children[0];
|
||||
var childComp = parentComp.children[0];
|
||||
const gpComp = fixture.debugElement.children[0];
|
||||
const parentComp = gpComp.children[0];
|
||||
const childComp = parentComp.children[0];
|
||||
|
||||
var grandParent = gpComp.injector.get(GrandParentProvidingEventBus);
|
||||
var parent = parentComp.injector.get(ParentProvidingEventBus);
|
||||
var child = childComp.injector.get(ChildConsumingEventBus);
|
||||
const grandParent = gpComp.injector.get(GrandParentProvidingEventBus);
|
||||
const parent = parentComp.injector.get(ParentProvidingEventBus);
|
||||
const child = childComp.injector.get(ChildConsumingEventBus);
|
||||
|
||||
expect(grandParent.bus.name).toEqual('grandparent');
|
||||
expect(parent.bus.name).toEqual('parent');
|
||||
@ -1195,7 +1195,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
|
||||
var providing = fixture.debugElement.children[0].references['providing'];
|
||||
const providing = fixture.debugElement.children[0].references['providing'];
|
||||
expect(providing.created).toBe(false);
|
||||
|
||||
fixture.componentInstance.ctxBoolProp = true;
|
||||
@ -1295,7 +1295,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
TestBed.createComponent(MyComp);
|
||||
throw 'Should throw';
|
||||
} catch (e) {
|
||||
var c = e.context;
|
||||
const c = e.context;
|
||||
expect(getDOM().nodeName(c.componentRenderElement).toUpperCase()).toEqual('DIV');
|
||||
expect((<Injector>c.injector).get).toBeTruthy();
|
||||
}
|
||||
@ -1310,7 +1310,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
fixture.detectChanges();
|
||||
throw 'Should throw';
|
||||
} catch (e) {
|
||||
var c = e.context;
|
||||
const c = e.context;
|
||||
expect(getDOM().nodeName(c.renderNode).toUpperCase()).toEqual('INPUT');
|
||||
expect(getDOM().nodeName(c.componentRenderElement).toUpperCase()).toEqual('DIV');
|
||||
expect((<Injector>c.injector).get).toBeTruthy();
|
||||
@ -1330,7 +1330,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
fixture.detectChanges();
|
||||
throw 'Should throw';
|
||||
} catch (e) {
|
||||
var c = e.context;
|
||||
const c = e.context;
|
||||
expect(c.renderNode).toBeTruthy();
|
||||
expect(c.source).toContain(':0:5');
|
||||
}
|
||||
@ -1348,12 +1348,12 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
tick();
|
||||
|
||||
var tc = fixture.debugElement.children[0];
|
||||
const tc = fixture.debugElement.children[0];
|
||||
|
||||
try {
|
||||
tc.injector.get(DirectiveEmittingEvent).fireEvent('boom');
|
||||
} catch (e) {
|
||||
var c = e.context;
|
||||
const c = e.context;
|
||||
expect(getDOM().nodeName(c.renderNode).toUpperCase()).toEqual('SPAN');
|
||||
expect(getDOM().nodeName(c.componentRenderElement).toUpperCase()).toEqual('DIV');
|
||||
expect((<Injector>c.injector).get).toBeTruthy();
|
||||
@ -1457,7 +1457,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
fixture.componentInstance.ctxProp = 'TITLE';
|
||||
fixture.detectChanges();
|
||||
|
||||
var el = getDOM().querySelector(fixture.nativeElement, 'span');
|
||||
const el = getDOM().querySelector(fixture.nativeElement, 'span');
|
||||
expect(isBlank(el.title) || el.title == '').toBeTruthy();
|
||||
});
|
||||
|
||||
@ -1470,7 +1470,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
fixture.componentInstance.ctxProp = 'TITLE';
|
||||
fixture.detectChanges();
|
||||
|
||||
var el = getDOM().querySelector(fixture.nativeElement, 'span');
|
||||
const el = getDOM().querySelector(fixture.nativeElement, 'span');
|
||||
expect(el.title).toEqual('TITLE');
|
||||
});
|
||||
});
|
||||
@ -1526,7 +1526,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
|
||||
fixture.detectChanges();
|
||||
var dir = fixture.debugElement.children[0].injector.get(DirectiveWithPropDecorators);
|
||||
const dir = fixture.debugElement.children[0].injector.get(DirectiveWithPropDecorators);
|
||||
expect(dir.dirProp).toEqual('aaa');
|
||||
});
|
||||
|
||||
@ -1540,7 +1540,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
|
||||
fixture.detectChanges();
|
||||
var dir = fixture.debugElement.children[0].injector.get(DirectiveWithPropDecorators);
|
||||
const dir = fixture.debugElement.children[0].injector.get(DirectiveWithPropDecorators);
|
||||
dir.myAttr = 'aaa';
|
||||
|
||||
fixture.detectChanges();
|
||||
@ -1560,7 +1560,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
|
||||
tick();
|
||||
|
||||
var emitter =
|
||||
const emitter =
|
||||
fixture.debugElement.children[0].injector.get(DirectiveWithPropDecorators);
|
||||
emitter.fireEvent('fired !');
|
||||
|
||||
@ -1580,8 +1580,8 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
|
||||
fixture.detectChanges();
|
||||
var dir = fixture.debugElement.children[0].injector.get(DirectiveWithPropDecorators);
|
||||
var native = fixture.debugElement.children[0].nativeElement;
|
||||
const dir = fixture.debugElement.children[0].injector.get(DirectiveWithPropDecorators);
|
||||
const native = fixture.debugElement.children[0].nativeElement;
|
||||
getDOM().dispatchEvent(native, getDOM().createMouseEvent('click'));
|
||||
|
||||
expect(dir.target).toBe(native);
|
||||
@ -1599,7 +1599,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
|
||||
fixture.detectChanges();
|
||||
var native = fixture.debugElement.children[0].nativeElement;
|
||||
const native = fixture.debugElement.children[0].nativeElement;
|
||||
expect(native).toHaveText('No View Decorator: 123');
|
||||
});
|
||||
});
|
||||
@ -1613,15 +1613,15 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
|
||||
var el = fixture.nativeElement;
|
||||
var svg = getDOM().childNodes(el)[0];
|
||||
var use = getDOM().childNodes(svg)[0];
|
||||
const el = fixture.nativeElement;
|
||||
const svg = getDOM().childNodes(el)[0];
|
||||
const use = getDOM().childNodes(svg)[0];
|
||||
expect(getDOM().getProperty(<Element>svg, 'namespaceURI'))
|
||||
.toEqual('http://www.w3.org/2000/svg');
|
||||
expect(getDOM().getProperty(<Element>use, 'namespaceURI'))
|
||||
.toEqual('http://www.w3.org/2000/svg');
|
||||
|
||||
var firstAttribute = getDOM().getProperty(<Element>use, 'attributes')[0];
|
||||
const firstAttribute = getDOM().getProperty(<Element>use, 'attributes')[0];
|
||||
expect(firstAttribute.name).toEqual('xlink:href');
|
||||
expect(firstAttribute.namespaceURI).toEqual('http://www.w3.org/1999/xlink');
|
||||
});
|
||||
@ -1633,10 +1633,10 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
|
||||
var el = fixture.nativeElement;
|
||||
var svg = getDOM().childNodes(el)[0];
|
||||
var foreignObject = getDOM().childNodes(svg)[0];
|
||||
var p = getDOM().childNodes(foreignObject)[0];
|
||||
const el = fixture.nativeElement;
|
||||
const svg = getDOM().childNodes(el)[0];
|
||||
const foreignObject = getDOM().childNodes(svg)[0];
|
||||
const p = getDOM().childNodes(foreignObject)[0];
|
||||
expect(getDOM().getProperty(<Element>svg, 'namespaceURI'))
|
||||
.toEqual('http://www.w3.org/2000/svg');
|
||||
expect(getDOM().getProperty(<Element>foreignObject, 'namespaceURI'))
|
||||
@ -1654,7 +1654,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
TestBed.overrideComponent(SomeCmp, {set: {template}});
|
||||
const fixture = TestBed.createComponent(SomeCmp);
|
||||
|
||||
let useEl = getDOM().firstChild(fixture.nativeElement);
|
||||
const useEl = getDOM().firstChild(fixture.nativeElement);
|
||||
expect(getDOM().getAttributeNS(useEl, 'http://www.w3.org/1999/xlink', 'href'))
|
||||
.toEqual('#id');
|
||||
});
|
||||
@ -1665,8 +1665,8 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
TestBed.overrideComponent(SomeCmp, {set: {template}});
|
||||
const fixture = TestBed.createComponent(SomeCmp);
|
||||
|
||||
let cmp = fixture.componentInstance;
|
||||
let useEl = getDOM().firstChild(fixture.nativeElement);
|
||||
const cmp = fixture.componentInstance;
|
||||
const useEl = getDOM().firstChild(fixture.nativeElement);
|
||||
|
||||
cmp.value = '#id';
|
||||
fixture.detectChanges();
|
||||
@ -1721,7 +1721,7 @@ class SimpleImperativeViewComponent {
|
||||
done: any;
|
||||
|
||||
constructor(self: ElementRef, renderer: Renderer) {
|
||||
var hostElement = self.nativeElement;
|
||||
const hostElement = self.nativeElement;
|
||||
getDOM().appendChild(hostElement, el('hello imp view'));
|
||||
}
|
||||
}
|
||||
@ -1731,7 +1731,7 @@ class DynamicViewport {
|
||||
private componentFactory: ComponentFactory<ChildCompUsingService>;
|
||||
private injector: Injector;
|
||||
constructor(private vc: ViewContainerRef, componentFactoryResolver: ComponentFactoryResolver) {
|
||||
var myService = new MyService();
|
||||
const myService = new MyService();
|
||||
myService.greeting = 'dynamic greet';
|
||||
|
||||
this.injector = ReflectiveInjector.resolveAndCreate(
|
||||
@ -1988,7 +1988,7 @@ class DirectiveListeningDomEvent {
|
||||
onBodyEvent(eventType: string) { this.eventTypes.push('body_' + eventType); }
|
||||
}
|
||||
|
||||
var globalCounter = 0;
|
||||
let globalCounter = 0;
|
||||
@Directive({selector: '[listenerother]', host: {'(window:domEvent)': 'onEvent($event.type)'}})
|
||||
class DirectiveListeningDomEventOther {
|
||||
eventType: string;
|
||||
@ -2222,8 +2222,8 @@ class SomeImperativeViewport {
|
||||
}
|
||||
if (value) {
|
||||
this.view = this.vc.createEmbeddedView(this.templateRef);
|
||||
var nodes = this.view.rootNodes;
|
||||
for (var i = 0; i < nodes.length; i++) {
|
||||
const nodes = this.view.rootNodes;
|
||||
for (let i = 0; i < nodes.length; i++) {
|
||||
getDOM().appendChild(this.anchor, nodes[i]);
|
||||
}
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
|
||||
fixture.detectChanges();
|
||||
var q = fixture.debugElement.children[0].references['q'];
|
||||
const q = fixture.debugElement.children[0].references['q'];
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(q.textDirChildren.length).toEqual(1);
|
||||
@ -139,7 +139,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
|
||||
fixture.detectChanges();
|
||||
var q = fixture.debugElement.children[0].references['q'];
|
||||
const q = fixture.debugElement.children[0].references['q'];
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(q.textDirChildren.length).toEqual(1);
|
||||
|
@ -109,9 +109,9 @@ export function main() {
|
||||
|
||||
function declareTests({useJit}: {useJit: boolean}) {
|
||||
describe('NgModule', () => {
|
||||
var compiler: Compiler;
|
||||
var injector: Injector;
|
||||
var console: DummyConsole;
|
||||
let compiler: Compiler;
|
||||
let injector: Injector;
|
||||
let console: DummyConsole;
|
||||
|
||||
beforeEach(() => {
|
||||
console = new DummyConsole();
|
||||
@ -129,8 +129,8 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
}
|
||||
|
||||
function createComp<T>(compType: Type<T>, moduleType: Type<any>): ComponentFixture<T> {
|
||||
let ngModule = createModule(moduleType);
|
||||
var cf = ngModule.componentFactoryResolver.resolveComponentFactory(compType);
|
||||
const ngModule = createModule(moduleType);
|
||||
const cf = ngModule.componentFactoryResolver.resolveComponentFactory(compType);
|
||||
return new ComponentFixture(cf.create(injector), null, false);
|
||||
}
|
||||
|
||||
@ -268,7 +268,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
|
||||
it('should register loaded modules', () => {
|
||||
createModule(SomeModule);
|
||||
let factory = getModuleFactory(token);
|
||||
const factory = getModuleFactory(token);
|
||||
expect(factory).toBeTruthy();
|
||||
expect(factory.moduleType).toBe(SomeModule);
|
||||
});
|
||||
@ -613,23 +613,23 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
() => { expect(createInjector([]).get(moduleType)).toBeAnInstanceOf(moduleType); });
|
||||
|
||||
it('should instantiate a class without dependencies', () => {
|
||||
var injector = createInjector([Engine]);
|
||||
var engine = injector.get(Engine);
|
||||
const injector = createInjector([Engine]);
|
||||
const engine = injector.get(Engine);
|
||||
|
||||
expect(engine).toBeAnInstanceOf(Engine);
|
||||
});
|
||||
|
||||
it('should resolve dependencies based on type information', () => {
|
||||
var injector = createInjector([Engine, Car]);
|
||||
var car = injector.get(Car);
|
||||
const injector = createInjector([Engine, Car]);
|
||||
const car = injector.get(Car);
|
||||
|
||||
expect(car).toBeAnInstanceOf(Car);
|
||||
expect(car.engine).toBeAnInstanceOf(Engine);
|
||||
});
|
||||
|
||||
it('should resolve dependencies based on @Inject annotation', () => {
|
||||
var injector = createInjector([TurboEngine, Engine, CarWithInject]);
|
||||
var car = injector.get(CarWithInject);
|
||||
const injector = createInjector([TurboEngine, Engine, CarWithInject]);
|
||||
const car = injector.get(CarWithInject);
|
||||
|
||||
expect(car).toBeAnInstanceOf(CarWithInject);
|
||||
expect(car.engine).toBeAnInstanceOf(TurboEngine);
|
||||
@ -646,79 +646,79 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
});
|
||||
|
||||
it('should cache instances', () => {
|
||||
var injector = createInjector([Engine]);
|
||||
const injector = createInjector([Engine]);
|
||||
|
||||
var e1 = injector.get(Engine);
|
||||
var e2 = injector.get(Engine);
|
||||
const e1 = injector.get(Engine);
|
||||
const e2 = injector.get(Engine);
|
||||
|
||||
expect(e1).toBe(e2);
|
||||
});
|
||||
|
||||
it('should provide to a value', () => {
|
||||
var injector = createInjector([{provide: Engine, useValue: 'fake engine'}]);
|
||||
const injector = createInjector([{provide: Engine, useValue: 'fake engine'}]);
|
||||
|
||||
var engine = injector.get(Engine);
|
||||
const engine = injector.get(Engine);
|
||||
expect(engine).toEqual('fake engine');
|
||||
});
|
||||
|
||||
it('should provide to a factory', () => {
|
||||
function sportsCarFactory(e: Engine) { return new SportsCar(e); }
|
||||
|
||||
var injector =
|
||||
const injector =
|
||||
createInjector([Engine, {provide: Car, useFactory: sportsCarFactory, deps: [Engine]}]);
|
||||
|
||||
var car = injector.get(Car);
|
||||
const car = injector.get(Car);
|
||||
expect(car).toBeAnInstanceOf(SportsCar);
|
||||
expect(car.engine).toBeAnInstanceOf(Engine);
|
||||
});
|
||||
|
||||
it('should supporting provider to null', () => {
|
||||
var injector = createInjector([{provide: Engine, useValue: null}]);
|
||||
var engine = injector.get(Engine);
|
||||
const injector = createInjector([{provide: Engine, useValue: null}]);
|
||||
const engine = injector.get(Engine);
|
||||
expect(engine).toBeNull();
|
||||
});
|
||||
|
||||
it('should provide to an alias', () => {
|
||||
var injector = createInjector([
|
||||
const injector = createInjector([
|
||||
Engine, {provide: SportsCar, useClass: SportsCar},
|
||||
{provide: Car, useExisting: SportsCar}
|
||||
]);
|
||||
|
||||
var car = injector.get(Car);
|
||||
var sportsCar = injector.get(SportsCar);
|
||||
const car = injector.get(Car);
|
||||
const sportsCar = injector.get(SportsCar);
|
||||
expect(car).toBeAnInstanceOf(SportsCar);
|
||||
expect(car).toBe(sportsCar);
|
||||
});
|
||||
|
||||
it('should support multiProviders', () => {
|
||||
var injector = createInjector([
|
||||
const injector = createInjector([
|
||||
Engine, {provide: Car, useClass: SportsCar, multi: true},
|
||||
{provide: Car, useClass: CarWithOptionalEngine, multi: true}
|
||||
]);
|
||||
|
||||
var cars = injector.get(Car);
|
||||
const cars = injector.get(Car);
|
||||
expect(cars.length).toEqual(2);
|
||||
expect(cars[0]).toBeAnInstanceOf(SportsCar);
|
||||
expect(cars[1]).toBeAnInstanceOf(CarWithOptionalEngine);
|
||||
});
|
||||
|
||||
it('should support multiProviders that are created using useExisting', () => {
|
||||
var injector = createInjector(
|
||||
const injector = createInjector(
|
||||
[Engine, SportsCar, {provide: Car, useExisting: SportsCar, multi: true}]);
|
||||
|
||||
var cars = injector.get(Car);
|
||||
const cars = injector.get(Car);
|
||||
expect(cars.length).toEqual(1);
|
||||
expect(cars[0]).toBe(injector.get(SportsCar));
|
||||
});
|
||||
|
||||
it('should throw when the aliased provider does not exist', () => {
|
||||
var injector = createInjector([{provide: 'car', useExisting: SportsCar}]);
|
||||
var e = `No provider for ${stringify(SportsCar)}!`;
|
||||
const injector = createInjector([{provide: 'car', useExisting: SportsCar}]);
|
||||
const e = `No provider for ${stringify(SportsCar)}!`;
|
||||
expect(() => injector.get('car')).toThrowError(e);
|
||||
});
|
||||
|
||||
it('should handle forwardRef in useExisting', () => {
|
||||
var injector = createInjector([
|
||||
const injector = createInjector([
|
||||
{provide: 'originalEngine', useClass: forwardRef(() => Engine)},
|
||||
{provide: 'aliasedEngine', useExisting: <any>forwardRef(() => 'originalEngine')}
|
||||
]);
|
||||
@ -726,37 +726,37 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
});
|
||||
|
||||
it('should support overriding factory dependencies', () => {
|
||||
var injector = createInjector(
|
||||
const injector = createInjector(
|
||||
[Engine, {provide: Car, useFactory: (e: Engine) => new SportsCar(e), deps: [Engine]}]);
|
||||
|
||||
var car = injector.get(Car);
|
||||
const car = injector.get(Car);
|
||||
expect(car).toBeAnInstanceOf(SportsCar);
|
||||
expect(car.engine).toBeAnInstanceOf(Engine);
|
||||
});
|
||||
|
||||
it('should support optional dependencies', () => {
|
||||
var injector = createInjector([CarWithOptionalEngine]);
|
||||
const injector = createInjector([CarWithOptionalEngine]);
|
||||
|
||||
var car = injector.get(CarWithOptionalEngine);
|
||||
const car = injector.get(CarWithOptionalEngine);
|
||||
expect(car.engine).toEqual(null);
|
||||
});
|
||||
|
||||
it('should flatten passed-in providers', () => {
|
||||
var injector = createInjector([[[Engine, Car]]]);
|
||||
const injector = createInjector([[[Engine, Car]]]);
|
||||
|
||||
var car = injector.get(Car);
|
||||
const car = injector.get(Car);
|
||||
expect(car).toBeAnInstanceOf(Car);
|
||||
});
|
||||
|
||||
it('should use the last provider when there are multiple providers for same token', () => {
|
||||
var injector = createInjector(
|
||||
const injector = createInjector(
|
||||
[{provide: Engine, useClass: Engine}, {provide: Engine, useClass: TurboEngine}]);
|
||||
|
||||
expect(injector.get(Engine)).toBeAnInstanceOf(TurboEngine);
|
||||
});
|
||||
|
||||
it('should use non-type tokens', () => {
|
||||
var injector = createInjector([{provide: 'token', useValue: 'value'}]);
|
||||
const injector = createInjector([{provide: 'token', useValue: 'value'}]);
|
||||
|
||||
expect(injector.get('token')).toEqual('value');
|
||||
});
|
||||
@ -774,14 +774,14 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
});
|
||||
|
||||
it('should provide itself', () => {
|
||||
var parent = createInjector([]);
|
||||
var child = createInjector([], parent);
|
||||
const parent = createInjector([]);
|
||||
const child = createInjector([], parent);
|
||||
|
||||
expect(child.get(Injector)).toBe(child);
|
||||
});
|
||||
|
||||
it('should throw when no provider defined', () => {
|
||||
var injector = createInjector([]);
|
||||
const injector = createInjector([]);
|
||||
expect(() => injector.get('NonExisting')).toThrowError('No provider for NonExisting!');
|
||||
});
|
||||
|
||||
@ -791,37 +791,37 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
});
|
||||
|
||||
it('should support null values', () => {
|
||||
var injector = createInjector([{provide: 'null', useValue: null}]);
|
||||
const injector = createInjector([{provide: 'null', useValue: null}]);
|
||||
expect(injector.get('null')).toBe(null);
|
||||
});
|
||||
|
||||
|
||||
describe('child', () => {
|
||||
it('should load instances from parent injector', () => {
|
||||
var parent = createInjector([Engine]);
|
||||
var child = createInjector([], parent);
|
||||
const parent = createInjector([Engine]);
|
||||
const child = createInjector([], parent);
|
||||
|
||||
var engineFromParent = parent.get(Engine);
|
||||
var engineFromChild = child.get(Engine);
|
||||
const engineFromParent = parent.get(Engine);
|
||||
const engineFromChild = child.get(Engine);
|
||||
|
||||
expect(engineFromChild).toBe(engineFromParent);
|
||||
});
|
||||
|
||||
it('should not use the child providers when resolving the dependencies of a parent provider',
|
||||
() => {
|
||||
var parent = createInjector([Car, Engine]);
|
||||
var child = createInjector([{provide: Engine, useClass: TurboEngine}], parent);
|
||||
const parent = createInjector([Car, Engine]);
|
||||
const child = createInjector([{provide: Engine, useClass: TurboEngine}], parent);
|
||||
|
||||
var carFromChild = child.get(Car);
|
||||
const carFromChild = child.get(Car);
|
||||
expect(carFromChild.engine).toBeAnInstanceOf(Engine);
|
||||
});
|
||||
|
||||
it('should create new instance in a child injector', () => {
|
||||
var parent = createInjector([Engine]);
|
||||
var child = createInjector([{provide: Engine, useClass: TurboEngine}], parent);
|
||||
const parent = createInjector([Engine]);
|
||||
const child = createInjector([{provide: Engine, useClass: TurboEngine}], parent);
|
||||
|
||||
var engineFromParent = parent.get(Engine);
|
||||
var engineFromChild = child.get(Engine);
|
||||
const engineFromParent = parent.get(Engine);
|
||||
const engineFromChild = child.get(Engine);
|
||||
|
||||
expect(engineFromParent).not.toBe(engineFromChild);
|
||||
expect(engineFromChild).toBeAnInstanceOf(TurboEngine);
|
||||
@ -832,7 +832,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
describe('depedency resolution', () => {
|
||||
describe('@Self()', () => {
|
||||
it('should return a dependency from self', () => {
|
||||
var inj = createInjector([
|
||||
const inj = createInjector([
|
||||
Engine,
|
||||
{provide: Car, useFactory: (e: Engine) => new Car(e), deps: [[Engine, new Self()]]}
|
||||
]);
|
||||
@ -852,8 +852,8 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
|
||||
describe('default', () => {
|
||||
it('should not skip self', () => {
|
||||
var parent = createInjector([Engine]);
|
||||
var child = createInjector(
|
||||
const parent = createInjector([Engine]);
|
||||
const child = createInjector(
|
||||
[
|
||||
{provide: Engine, useClass: TurboEngine},
|
||||
{provide: Car, useFactory: (e: Engine) => new Car(e), deps: [Engine]}
|
||||
|
@ -126,9 +126,9 @@ export function main() {
|
||||
});
|
||||
const main = TestBed.createComponent(MainComp);
|
||||
|
||||
var viewportDirectives = main.debugElement.children[0]
|
||||
.childNodes.filter(By.directive(ManualViewportDirective))
|
||||
.map(de => de.injector.get(ManualViewportDirective));
|
||||
const viewportDirectives = main.debugElement.children[0]
|
||||
.childNodes.filter(By.directive(ManualViewportDirective))
|
||||
.map(de => de.injector.get(ManualViewportDirective));
|
||||
|
||||
expect(main.nativeElement).toHaveText('(, B)');
|
||||
viewportDirectives.forEach(d => d.show());
|
||||
@ -170,7 +170,7 @@ export function main() {
|
||||
});
|
||||
const main = TestBed.createComponent(MainComp);
|
||||
|
||||
var viewportDirective =
|
||||
const viewportDirective =
|
||||
main.debugElement.queryAllNodes(By.directive(ManualViewportDirective))[0].injector.get(
|
||||
ManualViewportDirective);
|
||||
|
||||
@ -194,7 +194,7 @@ export function main() {
|
||||
});
|
||||
const main = TestBed.createComponent(MainComp);
|
||||
|
||||
var viewportDirective =
|
||||
const viewportDirective =
|
||||
main.debugElement.queryAllNodes(By.directive(ManualViewportDirective))[0].injector.get(
|
||||
ManualViewportDirective);
|
||||
|
||||
@ -254,7 +254,7 @@ export function main() {
|
||||
});
|
||||
const main = TestBed.createComponent(MainComp);
|
||||
|
||||
var projectDirective: ProjectDirective =
|
||||
const projectDirective: ProjectDirective =
|
||||
main.debugElement.queryAllNodes(By.directive(ProjectDirective))[0].injector.get(
|
||||
ProjectDirective);
|
||||
|
||||
@ -275,10 +275,10 @@ export function main() {
|
||||
});
|
||||
const main = TestBed.createComponent(MainComp);
|
||||
|
||||
var sourceDirective: ManualViewportDirective =
|
||||
const sourceDirective: ManualViewportDirective =
|
||||
main.debugElement.queryAllNodes(By.directive(ManualViewportDirective))[0].injector.get(
|
||||
ManualViewportDirective);
|
||||
var projectDirective: ProjectDirective =
|
||||
const projectDirective: ProjectDirective =
|
||||
main.debugElement.queryAllNodes(By.directive(ProjectDirective))[0].injector.get(
|
||||
ProjectDirective);
|
||||
expect(main.nativeElement).toHaveText('SIMPLE()START()END');
|
||||
@ -301,10 +301,10 @@ export function main() {
|
||||
});
|
||||
const main = TestBed.createComponent(MainComp);
|
||||
|
||||
var sourceDirective: ManualViewportDirective =
|
||||
const sourceDirective: ManualViewportDirective =
|
||||
main.debugElement.queryAllNodes(By.directive(ManualViewportDirective))[0].injector.get(
|
||||
ManualViewportDirective);
|
||||
var projectDirective: ProjectDirective =
|
||||
const projectDirective: ProjectDirective =
|
||||
main.debugElement.queryAllNodes(By.directive(ProjectDirective))[0].injector.get(
|
||||
ProjectDirective);
|
||||
expect(main.nativeElement).toHaveText('(, B)START()END');
|
||||
@ -327,7 +327,7 @@ export function main() {
|
||||
const main = TestBed.createComponent(MainComp);
|
||||
|
||||
main.detectChanges();
|
||||
var manualDirective: ManualViewportDirective =
|
||||
const manualDirective: ManualViewportDirective =
|
||||
main.debugElement.queryAllNodes(By.directive(ManualViewportDirective))[0].injector.get(
|
||||
ManualViewportDirective);
|
||||
expect(main.nativeElement).toHaveText('TREE(0:)');
|
||||
@ -350,14 +350,14 @@ export function main() {
|
||||
|
||||
expect(main.nativeElement).toHaveText('TREE(0:)');
|
||||
|
||||
var tree = main.debugElement.query(By.directive(Tree));
|
||||
var manualDirective: ManualViewportDirective = tree.queryAllNodes(By.directive(
|
||||
const tree = main.debugElement.query(By.directive(Tree));
|
||||
let manualDirective: ManualViewportDirective = tree.queryAllNodes(By.directive(
|
||||
ManualViewportDirective))[0].injector.get(ManualViewportDirective);
|
||||
manualDirective.show();
|
||||
main.detectChanges();
|
||||
expect(main.nativeElement).toHaveText('TREE(0:TREE2(1:))');
|
||||
|
||||
var tree2 = main.debugElement.query(By.directive(Tree2));
|
||||
const tree2 = main.debugElement.query(By.directive(Tree2));
|
||||
manualDirective = tree2.queryAllNodes(By.directive(ManualViewportDirective))[0].injector.get(
|
||||
ManualViewportDirective);
|
||||
manualDirective.show();
|
||||
@ -376,7 +376,7 @@ export function main() {
|
||||
});
|
||||
const main = TestBed.createComponent(MainComp);
|
||||
|
||||
var childNodes = getDOM().childNodes(main.nativeElement);
|
||||
const childNodes = getDOM().childNodes(main.nativeElement);
|
||||
expect(childNodes[0]).toHaveText('div {color: red}SIMPLE1(A)');
|
||||
expect(childNodes[1]).toHaveText('div {color: blue}SIMPLE2(B)');
|
||||
main.destroy();
|
||||
@ -395,9 +395,9 @@ export function main() {
|
||||
});
|
||||
const main = TestBed.createComponent(MainComp);
|
||||
|
||||
var mainEl = main.nativeElement;
|
||||
var div1 = getDOM().firstChild(mainEl);
|
||||
var div2 = getDOM().createElement('div');
|
||||
const mainEl = main.nativeElement;
|
||||
const div1 = getDOM().firstChild(mainEl);
|
||||
const div2 = getDOM().createElement('div');
|
||||
getDOM().setAttribute(div2, 'class', 'redStyle');
|
||||
getDOM().appendChild(mainEl, div2);
|
||||
expect(getDOM().getComputedStyle(div1).color).toEqual('rgb(255, 0, 0)');
|
||||
@ -415,9 +415,9 @@ export function main() {
|
||||
});
|
||||
const main = TestBed.createComponent(MainComp);
|
||||
|
||||
var mainEl = main.nativeElement;
|
||||
var div1 = getDOM().firstChild(mainEl);
|
||||
var div2 = getDOM().createElement('div');
|
||||
const mainEl = main.nativeElement;
|
||||
const div1 = getDOM().firstChild(mainEl);
|
||||
const div2 = getDOM().createElement('div');
|
||||
getDOM().appendChild(mainEl, div2);
|
||||
expect(getDOM().getComputedStyle(div1).color).toEqual('rgb(255, 0, 0)');
|
||||
expect(getDOM().getComputedStyle(div2).color).toEqual('rgb(0, 0, 0)');
|
||||
@ -433,7 +433,7 @@ export function main() {
|
||||
|
||||
expect(main.nativeElement).toHaveText('MAIN()');
|
||||
|
||||
var viewportElement =
|
||||
let viewportElement =
|
||||
main.debugElement.queryAllNodes(By.directive(ManualViewportDirective))[0];
|
||||
viewportElement.injector.get(ManualViewportDirective).show();
|
||||
expect(main.nativeElement).toHaveText('MAIN(FIRST())');
|
||||
@ -483,9 +483,9 @@ export function main() {
|
||||
});
|
||||
const main = TestBed.createComponent(MainComp);
|
||||
|
||||
var conditionalComp = main.debugElement.query(By.directive(ConditionalContentComponent));
|
||||
const conditionalComp = main.debugElement.query(By.directive(ConditionalContentComponent));
|
||||
|
||||
var viewViewportDir =
|
||||
const viewViewportDir =
|
||||
conditionalComp.queryAllNodes(By.directive(ManualViewportDirective))[0].injector.get(
|
||||
ManualViewportDirective);
|
||||
|
||||
@ -496,7 +496,7 @@ export function main() {
|
||||
|
||||
expect(main.nativeElement).toHaveText('(AC, D)');
|
||||
|
||||
var contentViewportDir =
|
||||
const contentViewportDir =
|
||||
conditionalComp.queryAllNodes(By.directive(ManualViewportDirective))[1].injector.get(
|
||||
ManualViewportDirective);
|
||||
|
||||
|
@ -15,8 +15,8 @@ import {iterateListLike} from '../../src/facade/collection';
|
||||
|
||||
export function main() {
|
||||
describe('QueryList', () => {
|
||||
var queryList: QueryList<string>;
|
||||
var log: string;
|
||||
let queryList: QueryList<string>;
|
||||
let log: string;
|
||||
beforeEach(() => {
|
||||
queryList = new QueryList<string>();
|
||||
log = '';
|
||||
@ -103,7 +103,7 @@ export function main() {
|
||||
|
||||
it('should support toString', () => {
|
||||
queryList.reset(['one', 'two']);
|
||||
var listString = queryList.toString();
|
||||
const listString = queryList.toString();
|
||||
expect(listString.indexOf('one') != -1).toBeTruthy();
|
||||
expect(listString.indexOf('two') != -1).toBeTruthy();
|
||||
});
|
||||
@ -123,7 +123,7 @@ export function main() {
|
||||
if (getDOM().supportsDOMEvents()) {
|
||||
describe('simple observable interface', () => {
|
||||
it('should fire callbacks on change', fakeAsync(() => {
|
||||
var fires = 0;
|
||||
let fires = 0;
|
||||
queryList.changes.subscribe({next: (_) => { fires += 1; }});
|
||||
|
||||
queryList.notifyOnChanges();
|
||||
@ -138,7 +138,7 @@ export function main() {
|
||||
}));
|
||||
|
||||
it('should provides query list as an argument', fakeAsync(() => {
|
||||
var recorded: any /** TODO #9100 */;
|
||||
let recorded: any /** TODO #9100 */;
|
||||
queryList.changes.subscribe({next: (v: any) => { recorded = v; }});
|
||||
|
||||
queryList.reset(['one']);
|
||||
|
@ -106,33 +106,33 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
}
|
||||
|
||||
it('should support providers with an OpaqueToken that contains a `.` in the name', () => {
|
||||
var token = new OpaqueToken('a.b');
|
||||
var tokenValue = 1;
|
||||
const token = new OpaqueToken('a.b');
|
||||
const tokenValue = 1;
|
||||
const injector = createInjector([{provide: token, useValue: tokenValue}]);
|
||||
expect(injector.get(token)).toEqual(tokenValue);
|
||||
});
|
||||
|
||||
it('should support providers with string token with a `.` in it', () => {
|
||||
var token = 'a.b';
|
||||
var tokenValue = 1;
|
||||
const token = 'a.b';
|
||||
const tokenValue = 1;
|
||||
const injector = createInjector([{provide: token, useValue: tokenValue}]);
|
||||
|
||||
expect(injector.get(token)).toEqual(tokenValue);
|
||||
});
|
||||
|
||||
it('should support providers with an anonymous function', () => {
|
||||
var token = () => true;
|
||||
var tokenValue = 1;
|
||||
const token = () => true;
|
||||
const tokenValue = 1;
|
||||
const injector = createInjector([{provide: token, useValue: tokenValue}]);
|
||||
|
||||
expect(injector.get(token)).toEqual(tokenValue);
|
||||
});
|
||||
|
||||
it('should support providers with an OpaqueToken that has a StringMap as value', () => {
|
||||
var token1 = new OpaqueToken('someToken');
|
||||
var token2 = new OpaqueToken('someToken');
|
||||
var tokenValue1 = {'a': 1};
|
||||
var tokenValue2 = {'a': 1};
|
||||
const token1 = new OpaqueToken('someToken');
|
||||
const token2 = new OpaqueToken('someToken');
|
||||
const tokenValue1 = {'a': 1};
|
||||
const tokenValue2 = {'a': 1};
|
||||
const injector = createInjector(
|
||||
[{provide: token1, useValue: tokenValue1}, {provide: token2, useValue: tokenValue2}]);
|
||||
|
||||
|
@ -97,9 +97,9 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
const fixture = TestBed.createComponent(SecuredComponent);
|
||||
const sanitizer: DomSanitizer = getTestBed().get(DomSanitizer);
|
||||
|
||||
let e = fixture.debugElement.children[0].nativeElement;
|
||||
let ci = fixture.componentInstance;
|
||||
let trusted = sanitizer.bypassSecurityTrustUrl('javascript:alert(1)');
|
||||
const e = fixture.debugElement.children[0].nativeElement;
|
||||
const ci = fixture.componentInstance;
|
||||
const trusted = sanitizer.bypassSecurityTrustUrl('javascript:alert(1)');
|
||||
ci.ctxProp = trusted;
|
||||
fixture.detectChanges();
|
||||
expect(getDOM().getProperty(e, 'href')).toEqual('javascript:alert(1)');
|
||||
@ -111,8 +111,8 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
const fixture = TestBed.createComponent(SecuredComponent);
|
||||
const sanitizer: DomSanitizer = getTestBed().get(DomSanitizer);
|
||||
|
||||
let trusted = sanitizer.bypassSecurityTrustScript('javascript:alert(1)');
|
||||
let ci = fixture.componentInstance;
|
||||
const trusted = sanitizer.bypassSecurityTrustScript('javascript:alert(1)');
|
||||
const ci = fixture.componentInstance;
|
||||
ci.ctxProp = trusted;
|
||||
expect(() => fixture.detectChanges()).toThrowError(/Required a safe URL, got a Script/);
|
||||
});
|
||||
@ -123,9 +123,9 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
const fixture = TestBed.createComponent(SecuredComponent);
|
||||
const sanitizer: DomSanitizer = getTestBed().get(DomSanitizer);
|
||||
|
||||
let e = fixture.debugElement.children[0].nativeElement;
|
||||
let trusted = sanitizer.bypassSecurityTrustUrl('bar/baz');
|
||||
let ci = fixture.componentInstance;
|
||||
const e = fixture.debugElement.children[0].nativeElement;
|
||||
const trusted = sanitizer.bypassSecurityTrustUrl('bar/baz');
|
||||
const ci = fixture.componentInstance;
|
||||
ci.ctxProp = trusted;
|
||||
fixture.detectChanges();
|
||||
expect(getDOM().getProperty(e, 'href')).toMatch(/SafeValue(%20| )must(%20| )use/);
|
||||
@ -134,8 +134,8 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
|
||||
describe('sanitizing', () => {
|
||||
function checkEscapeOfHrefProperty(fixture: ComponentFixture<any>, isAttribute: boolean) {
|
||||
let e = fixture.debugElement.children[0].nativeElement;
|
||||
let ci = fixture.componentInstance;
|
||||
const e = fixture.debugElement.children[0].nativeElement;
|
||||
const ci = fixture.componentInstance;
|
||||
ci.ctxProp = 'hello';
|
||||
fixture.detectChanges();
|
||||
// In the browser, reading href returns an absolute URL. On the server side,
|
||||
@ -201,8 +201,8 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
TestBed.overrideComponent(SecuredComponent, {set: {template}});
|
||||
const fixture = TestBed.createComponent(SecuredComponent);
|
||||
|
||||
let e = fixture.debugElement.children[0].nativeElement;
|
||||
let ci = fixture.componentInstance;
|
||||
const e = fixture.debugElement.children[0].nativeElement;
|
||||
const ci = fixture.componentInstance;
|
||||
// Make sure binding harmless values works.
|
||||
ci.ctxProp = 'red';
|
||||
fixture.detectChanges();
|
||||
@ -229,8 +229,8 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
TestBed.overrideComponent(SecuredComponent, {set: {template}});
|
||||
const fixture = TestBed.createComponent(SecuredComponent);
|
||||
|
||||
let e = fixture.debugElement.children[0].nativeElement;
|
||||
let ci = fixture.componentInstance;
|
||||
const e = fixture.debugElement.children[0].nativeElement;
|
||||
const ci = fixture.componentInstance;
|
||||
// Make sure binding harmless values works.
|
||||
ci.ctxProp = 'some <p>text</p>';
|
||||
fixture.detectChanges();
|
||||
|
@ -34,17 +34,17 @@ export function main() {
|
||||
afterEach(() => { (global as any).System = oldSystem; });
|
||||
|
||||
it('loads a default factory by appending the factory suffix', async(() => {
|
||||
let loader = new SystemJsNgModuleLoader(new Compiler());
|
||||
const loader = new SystemJsNgModuleLoader(new Compiler());
|
||||
loader.load('test').then(contents => { expect(contents).toBe('test module factory'); });
|
||||
}));
|
||||
it('loads a named factory by appending the factory suffix', async(() => {
|
||||
let loader = new SystemJsNgModuleLoader(new Compiler());
|
||||
const loader = new SystemJsNgModuleLoader(new Compiler());
|
||||
loader.load('test#Named').then(contents => {
|
||||
expect(contents).toBe('test NamedNgFactory');
|
||||
});
|
||||
}));
|
||||
it('loads a named factory with a configured prefix and suffix', async(() => {
|
||||
let loader = new SystemJsNgModuleLoader(new Compiler(), {
|
||||
const loader = new SystemJsNgModuleLoader(new Compiler(), {
|
||||
factoryPathPrefix: 'prefixed/',
|
||||
factoryPathSuffix: '/suffixed',
|
||||
});
|
||||
|
@ -228,7 +228,7 @@ export function main() {
|
||||
TestBed.configureTestingModule({declarations: [SimpleDirective, NeedsDirective]});
|
||||
const el = createComponent('<div simpleDirective needsDirective>');
|
||||
|
||||
var d = el.children[0].injector.get(NeedsDirective);
|
||||
const d = el.children[0].injector.get(NeedsDirective);
|
||||
|
||||
expect(d).toBeAnInstanceOf(NeedsDirective);
|
||||
expect(d.dependency).toBeAnInstanceOf(SimpleDirective);
|
||||
@ -286,7 +286,7 @@ export function main() {
|
||||
}
|
||||
];
|
||||
TestBed.overrideDirective(SimpleDirective, {add: {providers}});
|
||||
var el = createComponent('<div simpleDirective></div>');
|
||||
const el = createComponent('<div simpleDirective></div>');
|
||||
expect(el.children[0].injector.get('injectable2')).toEqual('injectable1-injectable2');
|
||||
});
|
||||
|
||||
|
@ -13,18 +13,18 @@ import {describe, expect, it} from '@angular/core/testing/testing_internal';
|
||||
export function main() {
|
||||
describe('es5 decorators', () => {
|
||||
it('should declare directive class', () => {
|
||||
var MyDirective = Directive({}).Class({constructor: function() { this.works = true; }});
|
||||
const MyDirective = Directive({}).Class({constructor: function() { this.works = true; }});
|
||||
expect(new MyDirective().works).toEqual(true);
|
||||
});
|
||||
|
||||
it('should declare Component class', () => {
|
||||
var MyComponent = Component({}).Class({constructor: function() { this.works = true; }});
|
||||
const MyComponent = Component({}).Class({constructor: function() { this.works = true; }});
|
||||
expect(new MyComponent().works).toEqual(true);
|
||||
});
|
||||
|
||||
it('should create type in ES5', () => {
|
||||
class MyComponent {};
|
||||
var as: any /** TODO #9100 */;
|
||||
let as: any /** TODO #9100 */;
|
||||
(<any>MyComponent).annotations = as = Component({});
|
||||
expect(reflector.annotations(MyComponent)).toEqual(as.annotations);
|
||||
});
|
||||
|
@ -67,7 +67,7 @@ class TestObj {
|
||||
|
||||
export function main() {
|
||||
describe('Reflector', () => {
|
||||
var reflector: Reflector;
|
||||
let reflector: Reflector;
|
||||
|
||||
beforeEach(() => { reflector = new Reflector(new ReflectionCapabilities()); });
|
||||
|
||||
|
@ -47,10 +47,10 @@ class MockNgZone extends NgZone {
|
||||
|
||||
export function main() {
|
||||
describe('Testability', () => {
|
||||
var testability: Testability;
|
||||
var execute: any;
|
||||
var execute2: any;
|
||||
var ngZone: MockNgZone;
|
||||
let testability: Testability;
|
||||
let execute: any;
|
||||
let execute2: any;
|
||||
let ngZone: MockNgZone;
|
||||
|
||||
beforeEach(() => {
|
||||
ngZone = new MockNgZone();
|
||||
|
@ -13,19 +13,19 @@ import {browserDetection} from '@angular/platform-browser/testing/browser_util';
|
||||
import {BaseError} from '../../src/facade/errors';
|
||||
import {isPresent, scheduleMicroTask} from '../../src/facade/lang';
|
||||
|
||||
var needsLongerTimers = browserDetection.isSlow || browserDetection.isEdge;
|
||||
var resultTimer = 1000;
|
||||
var testTimeout = browserDetection.isEdge ? 1200 : 500;
|
||||
const needsLongerTimers = browserDetection.isSlow || browserDetection.isEdge;
|
||||
const resultTimer = 1000;
|
||||
const testTimeout = browserDetection.isEdge ? 1200 : 500;
|
||||
// Schedules a macrotask (using a timer)
|
||||
function macroTask(fn: (...args: any[]) => void, timer = 1): void {
|
||||
// adds longer timers for passing tests in IE and Edge
|
||||
setTimeout(fn, needsLongerTimers ? timer : 1);
|
||||
}
|
||||
|
||||
var _log: Log;
|
||||
var _errors: any[];
|
||||
var _traces: any[];
|
||||
var _zone: NgZone;
|
||||
let _log: Log;
|
||||
let _errors: any[];
|
||||
let _traces: any[];
|
||||
let _zone: NgZone;
|
||||
|
||||
const resolvedPromise = Promise.resolve(null);
|
||||
|
||||
@ -51,7 +51,7 @@ function logOnStable() {
|
||||
}
|
||||
|
||||
function runNgZoneNoLog(fn: () => any) {
|
||||
var length = _log.logItems.length;
|
||||
const length = _log.logItems.length;
|
||||
try {
|
||||
return _zone.run(fn);
|
||||
} finally {
|
||||
@ -88,7 +88,7 @@ export function main() {
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
macroTask(() => {
|
||||
let resolve: (result: any) => void;
|
||||
let promise: Promise<any> = new Promise((res) => { resolve = res; });
|
||||
const promise: Promise<any> = new Promise((res) => { resolve = res; });
|
||||
|
||||
_zone.run(() => {
|
||||
setTimeout(() => {
|
||||
@ -111,7 +111,7 @@ export function main() {
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
macroTask(() => {
|
||||
let resolve: (result: any) => void;
|
||||
let promise: Promise<any> = new Promise((res) => { resolve = res; });
|
||||
const promise: Promise<any> = new Promise((res) => { resolve = res; });
|
||||
|
||||
_zone.run(() => {
|
||||
scheduleMicroTask(() => {
|
||||
@ -146,7 +146,7 @@ export function main() {
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
macroTask(() => {
|
||||
let resolve: (result: any) => void;
|
||||
let promise: Promise<any> = new Promise((res) => { resolve = res; });
|
||||
const promise: Promise<any> = new Promise((res) => { resolve = res; });
|
||||
|
||||
_zone.run(() => {
|
||||
setTimeout(() => {
|
||||
@ -235,7 +235,7 @@ function commonTests() {
|
||||
|
||||
runNgZoneNoLog(() => macroTask(_log.fn('run')));
|
||||
|
||||
var times = 0;
|
||||
let times = 0;
|
||||
_zone.onMicrotaskEmpty.subscribe({
|
||||
next: () => {
|
||||
times++;
|
||||
@ -271,7 +271,7 @@ function commonTests() {
|
||||
// Each subscriber fires a microtask outside the Angular zone. The test
|
||||
// then verifies that those microtasks do not cause additional digests.
|
||||
|
||||
var turnStart = false;
|
||||
let turnStart = false;
|
||||
_zone.onUnstable.subscribe({
|
||||
next: () => {
|
||||
if (turnStart) throw 'Should not call this more than once';
|
||||
@ -281,7 +281,7 @@ function commonTests() {
|
||||
}
|
||||
});
|
||||
|
||||
var turnDone = false;
|
||||
let turnDone = false;
|
||||
_zone.onMicrotaskEmpty.subscribe({
|
||||
next: () => {
|
||||
if (turnDone) throw 'Should not call this more than once';
|
||||
@ -291,7 +291,7 @@ function commonTests() {
|
||||
}
|
||||
});
|
||||
|
||||
var eventDone = false;
|
||||
let eventDone = false;
|
||||
_zone.onStable.subscribe({
|
||||
next: () => {
|
||||
if (eventDone) throw 'Should not call this more than once';
|
||||
@ -315,7 +315,7 @@ function commonTests() {
|
||||
|
||||
// the only practical use-case to run a callback inside the zone is
|
||||
// change detection after "onMicrotaskEmpty". That's the only case tested.
|
||||
var turnDone = false;
|
||||
let turnDone = false;
|
||||
_zone.onMicrotaskEmpty.subscribe({
|
||||
next: () => {
|
||||
_log.add('onMyMicrotaskEmpty');
|
||||
@ -426,10 +426,10 @@ function commonTests() {
|
||||
|
||||
it('should call onUnstable and onMicrotaskEmpty before and after each turn',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
var aResolve: (result: string) => void;
|
||||
var aPromise: Promise<string>;
|
||||
var bResolve: (result: string) => void;
|
||||
var bPromise: Promise<string>;
|
||||
let aResolve: (result: string) => void;
|
||||
let aPromise: Promise<string>;
|
||||
let bResolve: (result: string) => void;
|
||||
let bPromise: Promise<string>;
|
||||
|
||||
runNgZoneNoLog(() => {
|
||||
macroTask(() => {
|
||||
@ -469,8 +469,8 @@ function commonTests() {
|
||||
|
||||
it('should call onUnstable and onMicrotaskEmpty when an inner microtask is scheduled from outside angular',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
var resolve: (result: string) => void;
|
||||
var promise: Promise<string>;
|
||||
let resolve: (result: string) => void;
|
||||
let promise: Promise<string>;
|
||||
|
||||
macroTask(() => {
|
||||
NgZone.assertNotInAngularZone();
|
||||
@ -509,7 +509,7 @@ function commonTests() {
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
runNgZoneNoLog(() => macroTask(_log.fn('run')));
|
||||
|
||||
var ran = false;
|
||||
let ran = false;
|
||||
_zone.onMicrotaskEmpty.subscribe({
|
||||
next: () => {
|
||||
_log.add('onMicrotaskEmpty(begin)');
|
||||
@ -548,7 +548,7 @@ function commonTests() {
|
||||
});
|
||||
});
|
||||
|
||||
var ran = false;
|
||||
let ran = false;
|
||||
_zone.onMicrotaskEmpty.subscribe({
|
||||
next: () => {
|
||||
_log.add('onMicrotaskEmpty(begin)');
|
||||
@ -592,8 +592,8 @@ function commonTests() {
|
||||
});
|
||||
});
|
||||
|
||||
var donePromiseRan = false;
|
||||
var startPromiseRan = false;
|
||||
let donePromiseRan = false;
|
||||
let startPromiseRan = false;
|
||||
|
||||
_zone.onUnstable.subscribe({
|
||||
next: () => {
|
||||
@ -638,10 +638,10 @@ function commonTests() {
|
||||
|
||||
it('should call onUnstable and onMicrotaskEmpty before and after each turn, respectively',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
var aResolve: (result: string) => void;
|
||||
var aPromise: Promise<string>;
|
||||
var bResolve: (result: string) => void;
|
||||
var bPromise: Promise<string>;
|
||||
let aResolve: (result: string) => void;
|
||||
let aPromise: Promise<string>;
|
||||
let bResolve: (result: string) => void;
|
||||
let bPromise: Promise<string>;
|
||||
|
||||
runNgZoneNoLog(() => {
|
||||
macroTask(() => {
|
||||
@ -693,7 +693,7 @@ function commonTests() {
|
||||
|
||||
it('should call onUnstable and onMicrotaskEmpty for promises created outside of run body',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
var promise: Promise<any>;
|
||||
let promise: Promise<any>;
|
||||
|
||||
runNgZoneNoLog(() => {
|
||||
macroTask(() => {
|
||||
@ -719,7 +719,7 @@ function commonTests() {
|
||||
it('should call the on error callback when it is invoked via zone.runGuarded',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
macroTask(() => {
|
||||
var exception = new BaseError('sync');
|
||||
const exception = new BaseError('sync');
|
||||
|
||||
_zone.runGuarded(() => { throw exception; });
|
||||
|
||||
@ -732,7 +732,7 @@ function commonTests() {
|
||||
it('should not call the on error callback but rethrow when it is invoked via zone.run',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
macroTask(() => {
|
||||
var exception = new BaseError('sync');
|
||||
const exception = new BaseError('sync');
|
||||
expect(() => _zone.run(() => { throw exception; })).toThrowError('sync');
|
||||
|
||||
expect(_errors.length).toBe(0);
|
||||
@ -742,7 +742,7 @@ function commonTests() {
|
||||
|
||||
it('should call onError for errors from microtasks',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
var exception = new BaseError('async');
|
||||
const exception = new BaseError('async');
|
||||
|
||||
macroTask(() => { _zone.run(() => { scheduleMicroTask(() => { throw exception; }); }); });
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
declare var global: any;
|
||||
|
||||
var _global = <any>(typeof window === 'undefined' ? global : window);
|
||||
const _global = <any>(typeof window === 'undefined' ? global : window);
|
||||
|
||||
/**
|
||||
* Wraps a test function in an asynchronous test zone. The test will automatically
|
||||
@ -57,7 +57,7 @@ export function async(fn: Function): (done: any) => any {
|
||||
|
||||
function runInTestZone(fn: Function, finishCallback: Function, failCallback: Function) {
|
||||
const currentZone = Zone.current;
|
||||
var AsyncTestZoneSpec = (Zone as any)['AsyncTestZoneSpec'];
|
||||
const AsyncTestZoneSpec = (Zone as any)['AsyncTestZoneSpec'];
|
||||
if (AsyncTestZoneSpec === undefined) {
|
||||
throw new Error(
|
||||
'AsyncTestZoneSpec is needed for the async() test helper but could not be found. ' +
|
||||
@ -79,7 +79,7 @@ function runInTestZone(fn: Function, finishCallback: Function, failCallback: Fun
|
||||
const proxyZone = Zone.current.getZoneWith('ProxyZoneSpec');
|
||||
const previousDelegate = proxyZoneSpec.getDelegate();
|
||||
proxyZone.parent.run(() => {
|
||||
var testZoneSpec: ZoneSpec = new AsyncTestZoneSpec(
|
||||
const testZoneSpec: ZoneSpec = new AsyncTestZoneSpec(
|
||||
() => {
|
||||
// Need to restore the original zone.
|
||||
currentZone.run(() => {
|
||||
|
@ -120,8 +120,8 @@ export function tick(millis: number = 0): void {
|
||||
* @experimental
|
||||
*/
|
||||
export function discardPeriodicTasks(): void {
|
||||
let zoneSpec = _getFakeAsyncZoneSpec();
|
||||
let pendingTimers = zoneSpec.pendingPeriodicTimers;
|
||||
const zoneSpec = _getFakeAsyncZoneSpec();
|
||||
const pendingTimers = zoneSpec.pendingPeriodicTimers;
|
||||
zoneSpec.pendingPeriodicTimers.length = 0;
|
||||
}
|
||||
|
||||
|
@ -255,7 +255,7 @@ export class TestBed implements Injector {
|
||||
}
|
||||
if (!this._moduleWithComponentFactories) {
|
||||
try {
|
||||
let moduleType = this._createCompilerAndModule();
|
||||
const moduleType = this._createCompilerAndModule();
|
||||
this._moduleWithComponentFactories =
|
||||
this._compiler.compileModuleAndAllComponentsSync(moduleType);
|
||||
} catch (e) {
|
||||
|
@ -17,7 +17,7 @@ import {TestBed} from './test_bed';
|
||||
|
||||
declare var global: any;
|
||||
|
||||
var _global = <any>(typeof window === 'undefined' ? global : window);
|
||||
const _global = <any>(typeof window === 'undefined' ? global : window);
|
||||
|
||||
// Reset the test providers and the fake async zone before each test.
|
||||
if (_global.beforeEach) {
|
||||
|
@ -21,24 +21,24 @@ export * from './ng_zone_mock';
|
||||
|
||||
export var proxy: ClassDecorator = (t: any) => t;
|
||||
|
||||
var _global = <any>(typeof window === 'undefined' ? global : window);
|
||||
const _global = <any>(typeof window === 'undefined' ? global : window);
|
||||
|
||||
export var afterEach: Function = _global.afterEach;
|
||||
export var expect: (actual: any) => jasmine.Matchers = _global.expect;
|
||||
|
||||
var jsmBeforeEach = _global.beforeEach;
|
||||
var jsmDescribe = _global.describe;
|
||||
var jsmDDescribe = _global.fdescribe;
|
||||
var jsmXDescribe = _global.xdescribe;
|
||||
var jsmIt = _global.it;
|
||||
var jsmIIt = _global.fit;
|
||||
var jsmXIt = _global.xit;
|
||||
const jsmBeforeEach = _global.beforeEach;
|
||||
const jsmDescribe = _global.describe;
|
||||
const jsmDDescribe = _global.fdescribe;
|
||||
const jsmXDescribe = _global.xdescribe;
|
||||
const jsmIt = _global.it;
|
||||
const jsmIIt = _global.fit;
|
||||
const jsmXIt = _global.xit;
|
||||
|
||||
var runnerStack: BeforeEachRunner[] = [];
|
||||
const runnerStack: BeforeEachRunner[] = [];
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 3000;
|
||||
var globalTimeOut = jasmine.DEFAULT_TIMEOUT_INTERVAL;
|
||||
const globalTimeOut = jasmine.DEFAULT_TIMEOUT_INTERVAL;
|
||||
|
||||
var testBed = getTestBed();
|
||||
const testBed = getTestBed();
|
||||
|
||||
/**
|
||||
* Mechanism to run `beforeEach()` functions of Angular tests.
|
||||
@ -62,10 +62,10 @@ class BeforeEachRunner {
|
||||
jsmBeforeEach(() => { testBed.resetTestingModule(); });
|
||||
|
||||
function _describe(jsmFn: Function, ...args: any[]) {
|
||||
var parentRunner = runnerStack.length === 0 ? null : runnerStack[runnerStack.length - 1];
|
||||
var runner = new BeforeEachRunner(parentRunner);
|
||||
const parentRunner = runnerStack.length === 0 ? null : runnerStack[runnerStack.length - 1];
|
||||
const runner = new BeforeEachRunner(parentRunner);
|
||||
runnerStack.push(runner);
|
||||
var suite = jsmFn(...args);
|
||||
const suite = jsmFn(...args);
|
||||
runnerStack.pop();
|
||||
return suite;
|
||||
}
|
||||
@ -106,7 +106,7 @@ export function beforeEach(fn: Function): void {
|
||||
*/
|
||||
export function beforeEachProviders(fn: Function): void {
|
||||
jsmBeforeEach(() => {
|
||||
var providers = fn();
|
||||
const providers = fn();
|
||||
if (!providers) return;
|
||||
testBed.configureTestingModule({providers: providers});
|
||||
});
|
||||
@ -119,11 +119,11 @@ function _it(jsmFn: Function, name: string, testFn: Function, testTimeOut: numbe
|
||||
debugger;
|
||||
throw new Error('Empty Stack!');
|
||||
}
|
||||
var runner = runnerStack[runnerStack.length - 1];
|
||||
var timeOut = Math.max(globalTimeOut, testTimeOut);
|
||||
const runner = runnerStack[runnerStack.length - 1];
|
||||
const timeOut = Math.max(globalTimeOut, testTimeOut);
|
||||
|
||||
jsmFn(name, (done: any) => {
|
||||
var completerProvider = {
|
||||
const completerProvider = {
|
||||
provide: AsyncTestCompleter,
|
||||
useFactory: () => {
|
||||
// Mark the test as async when an AsyncTestCompleter is injected in an it()
|
||||
@ -134,7 +134,7 @@ function _it(jsmFn: Function, name: string, testFn: Function, testTimeOut: numbe
|
||||
runner.run();
|
||||
|
||||
if (testFn.length == 0) {
|
||||
let retVal = testFn();
|
||||
const retVal = testFn();
|
||||
if (isPromise(retVal)) {
|
||||
// Asynchronous test function that returns a Promise - wait for completion.
|
||||
(<Promise<any>>retVal).then(done, done.fail);
|
||||
@ -164,7 +164,7 @@ export function iit(name: any, fn: any, timeOut: any = null): void {
|
||||
export class SpyObject {
|
||||
constructor(type?: any) {
|
||||
if (type) {
|
||||
for (let prop in type.prototype) {
|
||||
for (const prop in type.prototype) {
|
||||
let m: any = null;
|
||||
try {
|
||||
m = type.prototype[prop];
|
||||
@ -197,7 +197,7 @@ export class SpyObject {
|
||||
object = new SpyObject();
|
||||
}
|
||||
|
||||
var m = StringMapWrapper.merge(config, overrides);
|
||||
const m = StringMapWrapper.merge(config, overrides);
|
||||
Object.keys(m).forEach(key => { object.spy(key).and.returnValue(m[key]); });
|
||||
return object;
|
||||
}
|
||||
|
Reference in New Issue
Block a user