diff --git a/packages/router/test/regression_integration.spec.ts b/packages/router/test/regression_integration.spec.ts
index 9dd5b8ba323b65..9f8d9218bde714 100644
--- a/packages/router/test/regression_integration.spec.ts
+++ b/packages/router/test/regression_integration.spec.ts
@@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
-import {CommonModule} from '@angular/common';
+import {CommonModule, Location} from '@angular/common';
import {ChangeDetectionStrategy, Component, ContentChild, NgModule, TemplateRef, Type, ViewChild, ViewContainerRef} from '@angular/core';
import {ComponentFixture, fakeAsync, TestBed, tick} from '@angular/core/testing';
import {Router} from '@angular/router';
@@ -187,6 +187,48 @@ describe('Integration', () => {
expect(fixture.nativeElement.innerHTML).toContain('isActive: true');
}));
});
+
+ describe('useHash', () => {
+ xit('should restore hash to match current route - #28561', fakeAsync(() => {
+ @Component({selector: 'root-cmp', template: ``})
+ class RootCmp {
+ }
+
+ @Component({template: 'simple'})
+ class SimpleCmp {
+ }
+
+ TestBed.configureTestingModule({
+ imports: [RouterTestingModule.withRoutes([
+ {path: '', component: SimpleCmp},
+ {path: 'one', component: SimpleCmp, canActivate: ['returnRootUrlTree']}
+ ])],
+ declarations: [SimpleCmp, RootCmp],
+ providers: [
+ {
+ provide: 'returnRootUrlTree',
+ useFactory: (router: Router) => () => {
+ return router.parseUrl('/');
+ },
+ deps: [Router]
+ },
+ ],
+ });
+
+ const router = TestBed.inject(Router);
+ const location = TestBed.inject(Location);
+
+ router.navigateByUrl('/');
+ // Will setup location change listeners
+ const fixture = createRoot(router, RootCmp);
+
+ (location).simulateHashChange('/one');
+ advance(fixture);
+
+ expect(location.path()).toEqual('/');
+ expect((location).urlChanges).toEqual(['replace: /', 'hash: /one', 'replace: /']);
+ }));
+ });
});
function advance(fixture: ComponentFixture): void {