forked from DSpace/dspace-angular
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merged in CST-12490 (pull request DSpace#983)
[CST-12490] unit test fixes Approved-by: Andrea Bollini
- Loading branch information
Showing
21 changed files
with
327 additions
and
157 deletions.
There are no files selected for viewing
86 changes: 71 additions & 15 deletions
86
...pp/admin/admin-ldn-services/ldn-service-form-edit/ldn-service-form-edit.component.spec.ts
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,23 +1,79 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { LdnServiceFormEditComponent } from './ldn-service-form-edit.component'; | ||
import { ChangeDetectorRef, EventEmitter } from '@angular/core'; | ||
import { ReactiveFormsModule, FormBuilder } from '@angular/forms'; | ||
import { ActivatedRoute, Router } from '@angular/router'; | ||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; | ||
import { TranslateModule, TranslateService } from '@ngx-translate/core'; | ||
import { PaginationService } from 'ngx-pagination'; | ||
import { NotificationsService } from '../../../shared/notifications/notifications.service'; | ||
import { LdnItemfiltersService } from '../ldn-services-data/ldn-itemfilters-data.service'; | ||
import { LdnServicesService } from '../ldn-services-data/ldn-services-data.service'; | ||
import { RouterStub } from '../../../shared/testing/router.stub'; | ||
import { MockActivatedRoute } from '../../../shared/mocks/active-router.mock'; | ||
import { NotificationsServiceStub } from '../../../shared/testing/notifications-service.stub'; | ||
import { of } from 'rxjs'; | ||
import { RouteService } from '../../../core/services/route.service'; | ||
import { provideMockStore } from '@ngrx/store/testing'; | ||
|
||
describe('LdnServiceFormEditComponent', () => { | ||
let component: LdnServiceFormEditComponent; | ||
let fixture: ComponentFixture<LdnServiceFormEditComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [LdnServiceFormEditComponent] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(LdnServiceFormEditComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
let component: LdnServiceFormEditComponent; | ||
let fixture: ComponentFixture<LdnServiceFormEditComponent>; | ||
|
||
let ldnServicesService: any; | ||
let ldnItemfiltersService: any; | ||
let cdRefStub: any; | ||
let modalService: any; | ||
|
||
const translateServiceStub = { | ||
get: () => of('translated-text'), | ||
onLangChange: new EventEmitter(), | ||
onTranslationChange: new EventEmitter(), | ||
onDefaultLangChange: new EventEmitter() | ||
}; | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
beforeEach(async () => { | ||
ldnServicesService = { | ||
update: () => ({}), | ||
}; | ||
ldnItemfiltersService = { | ||
findAll: () => of(['item1', 'item2']), | ||
}; | ||
cdRefStub = Object.assign({ | ||
detectChanges: () => fixture.detectChanges() | ||
}); | ||
modalService = { | ||
open: () => {/*comment*/ | ||
} | ||
}; | ||
|
||
await TestBed.configureTestingModule({ | ||
imports: [ReactiveFormsModule, TranslateModule.forRoot()], | ||
declarations: [LdnServiceFormEditComponent], | ||
providers: [ | ||
{ provide: LdnServicesService, useValue: ldnServicesService }, | ||
{ provide: LdnItemfiltersService, useValue: ldnItemfiltersService }, | ||
{ provide: Router, useValue: new RouterStub() }, | ||
{ provide: ActivatedRoute, useValue: new MockActivatedRoute() }, | ||
{ provide: ChangeDetectorRef, useValue: cdRefStub }, | ||
{ provide: NgbModal, useValue: modalService }, | ||
{ provide: NotificationsService, useValue: NotificationsServiceStub }, | ||
{ provide: TranslateService, useValue: translateServiceStub }, | ||
{ provide: PaginationService, useValue: {} }, | ||
FormBuilder, | ||
RouteService, | ||
provideMockStore({ }), | ||
] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(LdnServiceFormEditComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
83 changes: 69 additions & 14 deletions
83
src/app/admin/admin-ldn-services/ldn-service-form/ldn-service-form.component.spec.ts
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,25 +1,80 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { LdnServiceFormComponent } from './ldn-service-form.component'; | ||
import { FormBuilder, ReactiveFormsModule } from '@angular/forms'; | ||
import { RouterTestingModule } from '@angular/router/testing'; | ||
import { NgbModal, NgbModalModule } from '@ng-bootstrap/ng-bootstrap'; | ||
import { TranslateModule, TranslateService } from '@ngx-translate/core'; | ||
import { LdnItemfiltersService } from '../ldn-services-data/ldn-itemfilters-data.service'; | ||
import { LdnServicesService } from '../ldn-services-data/ldn-services-data.service'; | ||
import { NotificationsService } from 'src/app/shared/notifications/notifications.service'; | ||
import { Router } from '@angular/router'; | ||
import { RouterStub } from 'src/app/shared/testing/router.stub'; | ||
import { createPaginatedList } from 'src/app/shared/testing/utils.test'; | ||
import { Itemfilter } from '../ldn-services-model/ldn-service-itemfilters'; | ||
import { createSuccessfulRemoteDataObject$ } from 'src/app/shared/remote-data.utils'; | ||
import { of } from 'rxjs'; | ||
import { EventEmitter } from '@angular/core'; | ||
|
||
describe('LdnServiceFormComponent', () => { | ||
let component: LdnServiceFormComponent; | ||
let fixture: ComponentFixture<LdnServiceFormComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [LdnServiceFormComponent] | ||
}) | ||
.compileComponents(); | ||
let component: LdnServiceFormComponent; | ||
let fixture: ComponentFixture<LdnServiceFormComponent>; | ||
|
||
let ldnServicesService: any; | ||
let ldnItemfiltersService: any; | ||
let notificationsService: any; | ||
|
||
const itemFiltersRdPL$ = createSuccessfulRemoteDataObject$(createPaginatedList([new Itemfilter()])); | ||
const translateServiceStub = { | ||
get: () => of('translated-text'), | ||
onLangChange: new EventEmitter(), | ||
onTranslationChange: new EventEmitter(), | ||
onDefaultLangChange: new EventEmitter() | ||
}; | ||
|
||
beforeEach(async () => { | ||
ldnItemfiltersService = jasmine.createSpyObj('ldnItemfiltersService', { | ||
findAll: jasmine.createSpy('findAll'), | ||
}); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(LdnServiceFormComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
ldnServicesService = jasmine.createSpyObj('ldnServicesService', { | ||
create: jasmine.createSpy('create'), | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
notificationsService = jasmine.createSpyObj('notificationsService', { | ||
success: jasmine.createSpy('success'), | ||
error: jasmine.createSpy('error'), | ||
}); | ||
|
||
await TestBed.configureTestingModule({ | ||
imports: [ | ||
ReactiveFormsModule, | ||
RouterTestingModule, | ||
NgbModalModule, | ||
TranslateModule.forRoot() | ||
], | ||
providers: [ | ||
{ provide: LdnItemfiltersService, useValue: ldnItemfiltersService }, | ||
{ provide: LdnServicesService, useValue: ldnServicesService }, | ||
{ provide: NotificationsService, useValue: notificationsService }, | ||
{ provide: TranslateService, useValue: translateServiceStub }, | ||
{ provide: Router, useValue: new RouterStub() }, | ||
{ provide: NgbModal, useValue: { open: () => {/*comment*/ } } }, | ||
FormBuilder | ||
], | ||
declarations: [LdnServiceFormComponent] | ||
}) | ||
.compileComponents(); | ||
}); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(LdnServiceFormComponent); | ||
component = fixture.componentInstance; | ||
ldnItemfiltersService.findAll.and.returnValue(itemFiltersRdPL$); | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
22 changes: 2 additions & 20 deletions
22
src/app/admin/admin-ldn-services/ldn-service-new/ldn-service-new.component.ts
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,27 +1,9 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { Observable } from 'rxjs'; | ||
import { LdnService } from "../ldn-services-model/ldn-services.model"; | ||
import { ActivatedRoute } from "@angular/router"; | ||
import { ProcessDataService } from "../../../core/data/processes/process-data.service"; | ||
import { LinkService } from "../../../core/cache/builders/link.service"; | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'ds-ldn-service-new', | ||
templateUrl: './ldn-service-new.component.html', | ||
styleUrls: ['./ldn-service-new.component.scss'] | ||
}) | ||
export class LdnServiceNewComponent implements OnInit { | ||
/** | ||
* Emits preselected process if there is one | ||
*/ | ||
ldnService$?: Observable<LdnService>; | ||
|
||
constructor(private route: ActivatedRoute, private processService: ProcessDataService, private linkService: LinkService) { | ||
} | ||
|
||
/** | ||
* If there's an id parameter, use this the process with this identifier as presets for the form | ||
*/ | ||
ngOnInit() { | ||
} | ||
export class LdnServiceNewComponent { | ||
} |
65 changes: 47 additions & 18 deletions
65
.../admin/admin-ldn-services/ldn-services-directory/ldn-services-directory.component.spec.ts
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,25 +1,54 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { LdnServicesOverviewComponent } from './ldn-services-directory.component'; | ||
import { ChangeDetectorRef, EventEmitter } from '@angular/core'; | ||
import { NotificationsService } from '../../../shared/notifications/notifications.service'; | ||
import { NotificationsServiceStub } from '../../../shared/testing/notifications-service.stub'; | ||
import { TranslateModule, TranslateService } from '@ngx-translate/core'; | ||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; | ||
import { LdnServicesService } from '../ldn-services-data/ldn-services-data.service'; | ||
import { PaginationService } from '../../../core/pagination/pagination.service'; | ||
import { PaginationServiceStub } from '../../../shared/testing/pagination-service.stub'; | ||
import { of } from 'rxjs'; | ||
|
||
import { ServicesDirectoryComponent } from './services-directory.component'; | ||
describe('LdnServicesOverviewComponent', () => { | ||
let component: LdnServicesOverviewComponent; | ||
let fixture: ComponentFixture<LdnServicesOverviewComponent>; | ||
|
||
describe('ServicesDirectoryComponent', () => { | ||
let component: ServicesDirectoryComponent; | ||
let fixture: ComponentFixture<ServicesDirectoryComponent>; | ||
const translateServiceStub = { | ||
get: () => of('translated-text'), | ||
onLangChange: new EventEmitter(), | ||
onTranslationChange: new EventEmitter(), | ||
onDefaultLangChange: new EventEmitter() | ||
}; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ServicesDirectoryComponent] | ||
}) | ||
.compileComponents(); | ||
}); | ||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [TranslateModule.forRoot()], | ||
declarations: [LdnServicesOverviewComponent], | ||
providers: [ | ||
{ provide: LdnServicesService, useValue: {} }, | ||
{ provide: PaginationService, useValue: new PaginationServiceStub() }, | ||
{ | ||
provide: NgbModal, useValue: { | ||
open: () => {/*comment*/ | ||
} | ||
} | ||
}, | ||
{ provide: ChangeDetectorRef, useValue: {} }, | ||
{ provide: NotificationsService, useValue: NotificationsServiceStub }, | ||
{ provide: TranslateService, useValue: translateServiceStub }, | ||
] | ||
}) | ||
.compileComponents(); | ||
}); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(ServicesDirectoryComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
beforeEach(() => { | ||
fixture = TestBed.createComponent(LdnServicesOverviewComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
17 changes: 0 additions & 17 deletions
17
src/app/admin/admin-ldn-services/ldn-services-services/ldn-directory.service.spec.ts
This file was deleted.
Oops, something went wrong.
29 changes: 0 additions & 29 deletions
29
src/app/admin/admin-ldn-services/ldn-services-services/ldn-directory.service.ts
This file was deleted.
Oops, something went wrong.
17 changes: 0 additions & 17 deletions
17
...pp/admin/admin-ldn-services/ldn-services-services/ldn-service-bulk-delete.service.spec.ts
This file was deleted.
Oops, something went wrong.
11 changes: 10 additions & 1 deletion
11
src/app/core/coar-notify/notify-info/notify-info.component.spec.ts
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
Oops, something went wrong.