fix(ivy): ensure TestBed restores fields to the most original value (#32823)

PR Close #32823
This commit is contained in:
Andrew Scott
2019-09-23 16:15:11 -07:00
committed by Andrew Kushnir
parent a54adcaff0
commit c8be987b40
2 changed files with 34 additions and 4 deletions

View File

@ -513,9 +513,9 @@ export class R3TestBedCompiler {
}
restoreOriginalState(): void {
for (const op of this.defCleanupOps) {
op.def[op.field] = op.original;
}
// Process cleanup ops in reverse order so the field's original value is restored correctly (in
// case there were multiple overrides for the same field).
forEachRight(this.defCleanupOps, (op: CleanupOperation) => { op.def[op.field] = op.original; });
// Restore initial component/directive/pipe defs
this.initialNgDefs.forEach(
(value: [string, PropertyDescriptor | undefined], type: Type<any>) => {