【发布时间】:2017-09-15 09:10:37
【问题描述】:
我是 Angular 新手,我想对下面的示例做测试用例。请解释一下如何使用 karma 或 jasmine 为这个登录功能编写测试用例?
ngOnInit() {
// reset login status
this.authenticationService.logout();
// get return url from route parameters or default to '/'
this.returnUrl = this.route.snapshot.queryParams['returnUrl'] || '/';
}
login() {
this.loading = true;
this.authenticationService.login(this.model.username,
this.model.password)
.subscribe(
data => {this.router.navigate([this.returnUrl]);
},
error => {
this.alertService.error(error);
this.loading = false;
});
}
【问题讨论】:
标签: angularjs jasmine karma-jasmine