fix(router): make setUpLocationChangeListener idempotent
This commit is contained in:
@ -6,6 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Location} from '@angular/common';
|
||||
import {TestBed} from '@angular/core/testing';
|
||||
|
||||
import {ResolveData} from '../src/config';
|
||||
@ -32,6 +33,28 @@ describe('Router', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('setUpLocationChangeListener', () => {
|
||||
beforeEach(() => { TestBed.configureTestingModule({imports: [RouterTestingModule]}); });
|
||||
|
||||
it('should be indempotent', () => {
|
||||
const r: Router = TestBed.get(Router);
|
||||
const location: Location = TestBed.get(Location);
|
||||
|
||||
r.setUpLocationChangeListener();
|
||||
const a = (<any>r).locationSubscription;
|
||||
r.setUpLocationChangeListener();
|
||||
const b = (<any>r).locationSubscription;
|
||||
|
||||
expect(a).toBe(b);
|
||||
|
||||
r.dispose();
|
||||
r.setUpLocationChangeListener();
|
||||
const c = (<any>r).locationSubscription;
|
||||
|
||||
expect(c).not.toBe(b);
|
||||
});
|
||||
});
|
||||
|
||||
describe('PreActivation', () => {
|
||||
const serializer = new DefaultUrlSerializer();
|
||||
const inj = {get: (token: any) => () => `${token}_value`};
|
||||
|
Reference in New Issue
Block a user