fix(router): routerLink support of null/undefined (#13380)

Closes #6971
This commit is contained in:
Dzmitry Shylovich
2016-12-28 00:45:16 +03:00
committed by Hans
parent 9c697030e6
commit 174334dec3
3 changed files with 36 additions and 14 deletions

View File

@ -1022,6 +1022,26 @@ describe('Integration', () => {
expect(native.getAttribute('href')).toEqual('/home');
}));
it('should not throw when commands is null', fakeAsync(() => {
@Component({
selector: 'someCmp',
template:
`<router-outlet></router-outlet><a [routerLink]="null">Link</a><button [routerLink]="null">Button</button>`
})
class CmpWithLink {
}
TestBed.configureTestingModule({declarations: [CmpWithLink]});
const router: Router = TestBed.get(Router);
let fixture: ComponentFixture<CmpWithLink> = createRoot(router, CmpWithLink);
router.resetConfig([{path: 'home', component: SimpleCmp}]);
const anchor = fixture.nativeElement.querySelector('a');
const button = fixture.nativeElement.querySelector('button');
expect(() => anchor.click()).not.toThrow();
expect(() => button.click()).not.toThrow();
}));
it('should update hrefs when query params or fragment change', fakeAsync(() => {
@Component({