Guest User

Untitled

a guest
Jul 30th, 2018
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. Chrome 67.0.3396 (Mac OS X 10.13.5) LoginComponent should call auth.login when passed a valid form with correct credentials onSubmit FAILED
  2. Expected spy login to have been called.
  3. at UserContext.<anonymous> src/app/components/login/login.component.spec.ts:87:26)
  4. at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke node_modules/zone.js/dist/zone.js:388:1)
  5. at ProxyZoneSpec.push../node_modules/zone.js/dist/zone-testing.js.ProxyZoneSpec.onInvoke node_modules/zone.js/dist/zone-testing.js:288:1)
  6. at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke node_modules/zone.js/dist/zone.js:387:1)
  7.  
  8. onSubmit(form: NgForm) {
  9. if (form.valid) {
  10. this.authService.login(this.user.username, this.user.password)
  11. .subscribe(
  12. data => {
  13. console.log(data);
  14. /* TODO: Navigate to holding page etc */
  15. // Hide any error message that was previously shown
  16. this.hideErrorMsg = true;
  17. },
  18. err => {
  19. console.log(err);
  20. // Change error message to be shown
  21. this.errorMessage = 'Either username or password were incorrect';
  22. // Show the error message
  23. this.hideErrorMsg = false;
  24. }
  25. );
  26. }
  27.  
  28. const validFormGoodCreds = <NgForm>{
  29. value: {
  30. password: "somePassword",
  31. username: "someUsername"
  32. }
  33. };
  34.  
  35. beforeEach(async(() => {
  36. TestBed.configureTestingModule({
  37. declarations: [LoginComponent],
  38. imports: [FormsModule, HttpClientModule]
  39. }).compileComponents();
  40. authLogoutSpy = spyOn(component['authService'], 'logout');
  41.  
  42. it('should call auth.login when passed a valid form with correct credentials onSubmit', () => {
  43. component.onSubmit(validFormGoodCreds);
  44. expect(authLoginSpy).toHaveBeenCalled();
  45.  
  46. // TODO: Check for navigation to holding page
  47. });
Add Comment
Please, Sign In to add comment