fix(router): mount correct component if router outlet was not instantiated and if using a route reuse strategy (#25313) (#25314)
This unsets 'attachRef' on outlet context if no route is to be reused in route activation. Closes #25313 PR Close #25314
This commit is contained in:
@ -10,6 +10,7 @@ ng_module(
|
||||
module_name = "@angular/platform-browser/testing",
|
||||
deps = [
|
||||
"//packages/core",
|
||||
"//packages/core/testing",
|
||||
"//packages/platform-browser",
|
||||
"@rxjs",
|
||||
],
|
||||
|
@ -11,6 +11,7 @@ const sourcemaps = require('rollup-plugin-sourcemaps');
|
||||
|
||||
const globals = {
|
||||
'@angular/core': 'ng.core',
|
||||
'@angular/core/testing': 'ng.core.testing',
|
||||
'@angular/common': 'ng.common',
|
||||
'@angular/platform-browser': 'ng.platformBrowser'
|
||||
};
|
||||
|
@ -7,8 +7,9 @@
|
||||
*/
|
||||
|
||||
|
||||
import {ɵglobal as global} from '@angular/core';
|
||||
import {ɵgetDOM as getDOM} from '@angular/platform-browser';
|
||||
import {Type, ɵglobal as global} from '@angular/core';
|
||||
import {ComponentFixture} from '@angular/core/testing';
|
||||
import {By, ɵgetDOM as getDOM} from '@angular/platform-browser';
|
||||
|
||||
|
||||
|
||||
@ -79,6 +80,11 @@ export interface NgMatchers<T = any> extends jasmine.Matchers<T> {
|
||||
*/
|
||||
toContainError(expected: any): boolean;
|
||||
|
||||
/**
|
||||
* Expect a component of the given type to show.
|
||||
*/
|
||||
toContainComponent(expectedComponentType: Type<any>, expectationFailOutput?: any): boolean;
|
||||
|
||||
/**
|
||||
* Invert the matchers.
|
||||
*/
|
||||
@ -235,6 +241,29 @@ _global.beforeEach(function() {
|
||||
};
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
toContainComponent: function() {
|
||||
return {
|
||||
compare: function(actualFixture: any, expectedComponentType: Type<any>) {
|
||||
const failOutput = arguments[2];
|
||||
const msgFn = (msg: string): string => [msg, failOutput].filter(Boolean).join(', ');
|
||||
|
||||
// verify correct actual type
|
||||
if (!(actualFixture instanceof ComponentFixture)) {
|
||||
return {
|
||||
pass: false,
|
||||
message: msgFn(
|
||||
`Expected actual to be of type \'ComponentFixture\' [actual=${actualFixture.constructor.name}]`)
|
||||
};
|
||||
}
|
||||
|
||||
const found = !!actualFixture.debugElement.query(By.directive(expectedComponentType));
|
||||
return found ?
|
||||
{pass: true} :
|
||||
{pass: false, message: msgFn(`Expected ${expectedComponentType.name} to show`)};
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user