-
Notifications
You must be signed in to change notification settings - Fork 437
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3738 from alexandrevryghem/w2p-117573_remove-obse…
…rvable-function-calls-from-template_contribute-8_x [Port dspace-8_x] Removed observable function calls from template (part 1)
- Loading branch information
Showing
32 changed files
with
911 additions
and
916 deletions.
There are no files selected for viewing
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,5 +1,5 @@ | ||
import { CommonModule } from '@angular/common'; | ||
import { NO_ERRORS_SCHEMA } from '@angular/core'; | ||
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; | ||
import { | ||
ComponentFixture, | ||
TestBed, | ||
|
@@ -19,12 +19,10 @@ import { | |
import { | ||
ActivatedRoute, | ||
Router, | ||
RouterModule, | ||
} from '@angular/router'; | ||
import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; | ||
import { | ||
TranslateLoader, | ||
TranslateModule, | ||
} from '@ngx-translate/core'; | ||
import { TranslateModule } from '@ngx-translate/core'; | ||
import { | ||
Observable, | ||
of as observableOf, | ||
|
@@ -49,7 +47,6 @@ import { FormBuilderService } from '../../../shared/form/builder/form-builder.se | |
import { FormComponent } from '../../../shared/form/form.component'; | ||
import { ThemedLoadingComponent } from '../../../shared/loading/themed-loading.component'; | ||
import { getMockFormBuilderService } from '../../../shared/mocks/form-builder-service.mock'; | ||
import { TranslateLoaderMock } from '../../../shared/mocks/translate-loader.mock'; | ||
import { NotificationsService } from '../../../shared/notifications/notifications.service'; | ||
import { PaginationComponent } from '../../../shared/pagination/pagination.component'; | ||
import { createSuccessfulRemoteDataObject$ } from '../../../shared/remote-data.utils'; | ||
|
@@ -92,9 +89,6 @@ describe('EPersonFormComponent', () => { | |
ePersonDataServiceStub = { | ||
activeEPerson: null, | ||
allEpeople: mockEPeople, | ||
getEPeople(): Observable<RemoteData<PaginatedList<EPerson>>> { | ||
return createSuccessfulRemoteDataObject$(buildPaginatedList(null, this.allEpeople)); | ||
}, | ||
getActiveEPerson(): Observable<EPerson> { | ||
return observableOf(this.activeEPerson); | ||
}, | ||
|
@@ -228,12 +222,8 @@ describe('EPersonFormComponent', () => { | |
router = new RouterStub(); | ||
TestBed.configureTestingModule({ | ||
imports: [CommonModule, NgbModule, FormsModule, ReactiveFormsModule, BrowserModule, | ||
TranslateModule.forRoot({ | ||
loader: { | ||
provide: TranslateLoader, | ||
useClass: TranslateLoaderMock, | ||
}, | ||
}), | ||
RouterModule.forRoot([]), | ||
TranslateModule.forRoot(), | ||
EPersonFormComponent, | ||
HasNoValuePipe, | ||
], | ||
|
@@ -251,7 +241,7 @@ describe('EPersonFormComponent', () => { | |
{ provide: Router, useValue: router }, | ||
EPeopleRegistryComponent, | ||
], | ||
schemas: [NO_ERRORS_SCHEMA], | ||
schemas: [CUSTOM_ELEMENTS_SCHEMA], | ||
}) | ||
.overrideComponent(EPersonFormComponent, { | ||
remove: { imports: [ ThemedLoadingComponent, PaginationComponent,FormComponent] }, | ||
|
@@ -274,37 +264,13 @@ describe('EPersonFormComponent', () => { | |
}); | ||
|
||
describe('check form validation', () => { | ||
let firstName; | ||
let lastName; | ||
let email; | ||
let canLogIn; | ||
let requireCertificate; | ||
let canLogIn: boolean; | ||
let requireCertificate: boolean; | ||
|
||
let expected; | ||
beforeEach(() => { | ||
firstName = 'testName'; | ||
lastName = 'testLastName'; | ||
email = '[email protected]'; | ||
canLogIn = false; | ||
requireCertificate = false; | ||
|
||
expected = Object.assign(new EPerson(), { | ||
metadata: { | ||
'eperson.firstname': [ | ||
{ | ||
value: firstName, | ||
}, | ||
], | ||
'eperson.lastname': [ | ||
{ | ||
value: lastName, | ||
}, | ||
], | ||
}, | ||
email: email, | ||
canLogIn: canLogIn, | ||
requireCertificate: requireCertificate, | ||
}); | ||
spyOn(component.submitForm, 'emit'); | ||
component.canLogIn.value = canLogIn; | ||
component.requireCertificate.value = requireCertificate; | ||
|
@@ -378,15 +344,13 @@ describe('EPersonFormComponent', () => { | |
expect(component.formGroup.controls.email.errors.emailTaken).toBeTruthy(); | ||
}); | ||
}); | ||
|
||
|
||
|
||
}); | ||
|
||
describe('when submitting the form', () => { | ||
let firstName; | ||
let lastName; | ||
let email; | ||
let canLogIn; | ||
let canLogIn: boolean; | ||
let requireCertificate; | ||
|
||
let expected; | ||
|
@@ -415,6 +379,7 @@ describe('EPersonFormComponent', () => { | |
requireCertificate: requireCertificate, | ||
}); | ||
spyOn(component.submitForm, 'emit'); | ||
component.ngOnInit(); | ||
component.firstName.value = firstName; | ||
component.lastName.value = lastName; | ||
component.email.value = email; | ||
|
@@ -454,9 +419,17 @@ describe('EPersonFormComponent', () => { | |
email: email, | ||
canLogIn: canLogIn, | ||
requireCertificate: requireCertificate, | ||
_links: undefined, | ||
_links: { | ||
groups: { | ||
href: '', | ||
}, | ||
self: { | ||
href: '', | ||
}, | ||
}, | ||
}); | ||
spyOn(ePersonDataServiceStub, 'getActiveEPerson').and.returnValue(observableOf(expectedWithId)); | ||
component.ngOnInit(); | ||
component.onSubmit(); | ||
fixture.detectChanges(); | ||
}); | ||
|
@@ -504,22 +477,19 @@ describe('EPersonFormComponent', () => { | |
}); | ||
|
||
describe('delete', () => { | ||
|
||
let ePersonId; | ||
let eperson: EPerson; | ||
let modalService; | ||
|
||
beforeEach(() => { | ||
spyOn(authService, 'impersonate').and.callThrough(); | ||
ePersonId = 'testEPersonId'; | ||
eperson = EPersonMock; | ||
component.epersonInitial = eperson; | ||
component.canDelete$ = observableOf(true); | ||
spyOn(component.epersonService, 'getActiveEPerson').and.returnValue(observableOf(eperson)); | ||
modalService = (component as any).modalService; | ||
spyOn(modalService, 'open').and.returnValue(Object.assign({ componentInstance: Object.assign({ response: observableOf(true) }) })); | ||
component.ngOnInit(); | ||
fixture.detectChanges(); | ||
|
||
}); | ||
|
||
it('the delete button should be visible if the ePerson can be deleted', () => { | ||
|
Oops, something went wrong.