-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
64fa96c
commit 2f4297f
Showing
28 changed files
with
2,842 additions
and
1,239 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import { ComponentFixture, TestBed, inject } from '@angular/core/testing' | ||
import { of, throwError } from 'rxjs' | ||
|
||
import { PasswordResetInitService } from '../service/password-reset-init.service' | ||
import { PasswordService } from '../service/password.service' | ||
import { PasswordResetInitComponent } from './password-reset-init.component' | ||
import { EMAIL_NOT_FOUND_TYPE } from 'src/app/app.constants' | ||
import { HttpClientTestingModule } from '@angular/common/http/testing' | ||
|
@@ -26,32 +26,29 @@ describe('Component Tests', () => { | |
expect(comp.errorEmailNotExists).toBeUndefined() | ||
}) | ||
|
||
it('notifies of success upon successful requestReset', inject( | ||
[PasswordResetInitService], | ||
(service: PasswordResetInitService) => { | ||
spyOn(service, 'initPasswordReset').and.returnValue(of(new PasswordResetInitResult(true, false, false))) | ||
comp.resetRequestForm.patchValue({ | ||
email: '[email protected]', | ||
}) | ||
it('notifies of success upon successful requestReset', inject([PasswordService], (service: PasswordService) => { | ||
spyOn(service, 'initPasswordReset').and.returnValue(of(new PasswordResetInitResult(true, false, false))) | ||
comp.resetRequestForm.patchValue({ | ||
email: '[email protected]', | ||
}) | ||
|
||
comp.requestReset() | ||
const emailControl = comp.resetRequestForm.get('email')! | ||
emailControl.setValue('[email protected]') | ||
fixture.detectChanges() | ||
expect(comp.success).toEqual('OK') | ||
expect(comp.error).toBeUndefined() | ||
expect(comp.errorEmailNotExists).toBeUndefined() | ||
fixture.whenStable().then(() => { | ||
expect(true).toBeFalsy() | ||
const button = fixture.debugElement.query(By.css('#reset')) | ||
expect(button.nativeElement.disabled).toBeFalsy() | ||
}) | ||
} | ||
)) | ||
comp.requestReset() | ||
const emailControl = comp.resetRequestForm.get('email')! | ||
emailControl.setValue('[email protected]') | ||
fixture.detectChanges() | ||
expect(comp.success).toEqual('OK') | ||
expect(comp.error).toBeUndefined() | ||
expect(comp.errorEmailNotExists).toBeUndefined() | ||
fixture.whenStable().then(() => { | ||
expect(true).toBeFalsy() | ||
const button = fixture.debugElement.query(By.css('#reset')) | ||
expect(button.nativeElement.disabled).toBeFalsy() | ||
}) | ||
})) | ||
|
||
it('notifies of unknown email upon email address not registered/400', inject( | ||
[PasswordResetInitService], | ||
(service: PasswordResetInitService) => { | ||
[PasswordService], | ||
(service: PasswordService) => { | ||
spyOn(service, 'initPasswordReset').and.returnValue(of(new PasswordResetInitResult(false, true, false))) | ||
comp.resetRequestForm.patchValue({ | ||
email: '[email protected]', | ||
|
@@ -65,21 +62,18 @@ describe('Component Tests', () => { | |
} | ||
)) | ||
|
||
it('notifies of error upon error response', inject( | ||
[PasswordResetInitService], | ||
(service: PasswordResetInitService) => { | ||
spyOn(service, 'initPasswordReset').and.returnValue(of(new PasswordResetInitResult(false, false, true))) | ||
comp.resetRequestForm.patchValue({ | ||
email: '[email protected]', | ||
}) | ||
comp.requestReset() | ||
it('notifies of error upon error response', inject([PasswordService], (service: PasswordService) => { | ||
spyOn(service, 'initPasswordReset').and.returnValue(of(new PasswordResetInitResult(false, false, true))) | ||
comp.resetRequestForm.patchValue({ | ||
email: '[email protected]', | ||
}) | ||
comp.requestReset() | ||
|
||
expect(service.initPasswordReset).toHaveBeenCalledWith('[email protected]') | ||
expect(comp.success).toBeUndefined() | ||
expect(comp.errorEmailNotExists).toBeUndefined() | ||
expect(comp.error).toEqual('ERROR') | ||
} | ||
)) | ||
expect(service.initPasswordReset).toHaveBeenCalledWith('[email protected]') | ||
expect(comp.success).toBeUndefined() | ||
expect(comp.errorEmailNotExists).toBeUndefined() | ||
expect(comp.error).toEqual('ERROR') | ||
})) | ||
|
||
it('should disable the submit button for invalid email address', () => { | ||
const emailControl = comp.resetRequestForm.get('email')! | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.