I have MainComponent that uses ChildComponentA as a @ViewChild. MainComponent is calling a method on ChildComponentA.
I want to write an unit test case mocking ChildComponentA. How can I do this using TestBed (in Angular 2 RC5)?
Before I used to use overrideDirective(MainComponentName, ChildComponentA, MockChildComponentA); Is there an equivalent to this using TestBed?
I tried using
TestBed.overrideComponent(ChildComponentA,{
set: {
template: '<div></div>'
}
});
Run Code Online (Sandbox Code Playgroud)
which just sets the template, but I want to mock the methods in …
我有page1和page2。我在page2路由上添加了canActivate gaurd,想知道我是否来自page1?我怎么做?
canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
//If from Page 1 { clearCache() }
return true;
}
Run Code Online (Sandbox Code Playgroud)
提前致谢。