mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
65240: Fixed current tests
This commit is contained in:
@@ -7,10 +7,14 @@ import { DynamicFormService, DynamicInputModel } from '@ng-dynamic-forms/core';
|
|||||||
import { FormControl, FormGroup } from '@angular/forms';
|
import { FormControl, FormGroup } from '@angular/forms';
|
||||||
import { DynamicFormControlModel } from '@ng-dynamic-forms/core/src/model/dynamic-form-control.model';
|
import { DynamicFormControlModel } from '@ng-dynamic-forms/core/src/model/dynamic-form-control.model';
|
||||||
import { Community } from '../../../core/shared/community.model';
|
import { Community } from '../../../core/shared/community.model';
|
||||||
import { ResourceType } from '../../../core/shared/resource-type';
|
|
||||||
import { ComColFormComponent } from './comcol-form.component';
|
import { ComColFormComponent } from './comcol-form.component';
|
||||||
import { DSpaceObject } from '../../../core/shared/dspace-object.model';
|
import { DSpaceObject } from '../../../core/shared/dspace-object.model';
|
||||||
import { hasValue } from '../../empty.util';
|
import { hasValue } from '../../empty.util';
|
||||||
|
import { VarDirective } from '../../utils/var.directive';
|
||||||
|
import { NotificationsService } from '../../notifications/notifications.service';
|
||||||
|
import { NotificationsServiceStub } from '../../testing/notifications-service-stub';
|
||||||
|
import { AuthService } from '../../../core/auth/auth.service';
|
||||||
|
import { AuthServiceMock } from '../../mocks/mock-auth.service';
|
||||||
|
|
||||||
describe('ComColFormComponent', () => {
|
describe('ComColFormComponent', () => {
|
||||||
let comp: ComColFormComponent<DSpaceObject>;
|
let comp: ComColFormComponent<DSpaceObject>;
|
||||||
@@ -56,10 +60,12 @@ describe('ComColFormComponent', () => {
|
|||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [TranslateModule.forRoot(), RouterTestingModule],
|
imports: [TranslateModule.forRoot(), RouterTestingModule],
|
||||||
declarations: [ComColFormComponent],
|
declarations: [ComColFormComponent, VarDirective],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: Location, useValue: locationStub },
|
{ provide: Location, useValue: locationStub },
|
||||||
{ provide: DynamicFormService, useValue: formServiceStub }
|
{ provide: DynamicFormService, useValue: formServiceStub },
|
||||||
|
{ provide: NotificationsService, useValue: new NotificationsServiceStub() },
|
||||||
|
{ provide: AuthService, useValue: new AuthServiceMock() }
|
||||||
],
|
],
|
||||||
schemas: [NO_ERRORS_SCHEMA]
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
}).compileComponents();
|
}).compileComponents();
|
||||||
@@ -70,6 +76,10 @@ describe('ComColFormComponent', () => {
|
|||||||
comp = fixture.componentInstance;
|
comp = fixture.componentInstance;
|
||||||
comp.formModel = [];
|
comp.formModel = [];
|
||||||
comp.dso = new Community();
|
comp.dso = new Community();
|
||||||
|
(comp as any).type = Community.type;
|
||||||
|
comp.uploaderComponent = Object.assign({
|
||||||
|
uploader: {}
|
||||||
|
});
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
location = (comp as any).location;
|
location = (comp as any).location;
|
||||||
});
|
});
|
||||||
@@ -94,7 +104,8 @@ describe('ComColFormComponent', () => {
|
|||||||
comp.onSubmit();
|
comp.onSubmit();
|
||||||
|
|
||||||
expect(comp.submitForm.emit).toHaveBeenCalledWith(
|
expect(comp.submitForm.emit).toHaveBeenCalledWith(
|
||||||
Object.assign(
|
{
|
||||||
|
dso: Object.assign(
|
||||||
{},
|
{},
|
||||||
new Community(),
|
new Community(),
|
||||||
{
|
{
|
||||||
@@ -105,7 +116,9 @@ describe('ComColFormComponent', () => {
|
|||||||
},
|
},
|
||||||
type: Community.type
|
type: Community.type
|
||||||
},
|
},
|
||||||
)
|
),
|
||||||
|
uploader: {}
|
||||||
|
}
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
@@ -16,6 +16,7 @@ import {
|
|||||||
createFailedRemoteDataObject$,
|
createFailedRemoteDataObject$,
|
||||||
createSuccessfulRemoteDataObject$
|
createSuccessfulRemoteDataObject$
|
||||||
} from '../../testing/utils';
|
} from '../../testing/utils';
|
||||||
|
import { ComColDataService } from '../../../core/data/comcol-data.service';
|
||||||
|
|
||||||
describe('CreateComColPageComponent', () => {
|
describe('CreateComColPageComponent', () => {
|
||||||
let comp: CreateComColPageComponent<DSpaceObject>;
|
let comp: CreateComColPageComponent<DSpaceObject>;
|
||||||
@@ -74,7 +75,7 @@ describe('CreateComColPageComponent', () => {
|
|||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [TranslateModule.forRoot(), SharedModule, CommonModule, RouterTestingModule],
|
imports: [TranslateModule.forRoot(), SharedModule, CommonModule, RouterTestingModule],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: DataService, useValue: communityDataServiceStub },
|
{ provide: ComColDataService, useValue: communityDataServiceStub },
|
||||||
{ provide: CommunityDataService, useValue: communityDataServiceStub },
|
{ provide: CommunityDataService, useValue: communityDataServiceStub },
|
||||||
{ provide: RouteService, useValue: routeServiceStub },
|
{ provide: RouteService, useValue: routeServiceStub },
|
||||||
{ provide: Router, useValue: routerStub },
|
{ provide: Router, useValue: routerStub },
|
||||||
@@ -96,12 +97,21 @@ describe('CreateComColPageComponent', () => {
|
|||||||
describe('onSubmit', () => {
|
describe('onSubmit', () => {
|
||||||
let data;
|
let data;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
data = Object.assign(new Community(), {
|
data = {
|
||||||
|
dso: Object.assign(new Community(), {
|
||||||
metadata: [{
|
metadata: [{
|
||||||
key: 'dc.title',
|
key: 'dc.title',
|
||||||
value: 'test'
|
value: 'test'
|
||||||
}]
|
}]
|
||||||
});
|
}),
|
||||||
|
uploader: {
|
||||||
|
options: {
|
||||||
|
url: ''
|
||||||
|
},
|
||||||
|
queue: [],
|
||||||
|
uploadAll: {}
|
||||||
|
}
|
||||||
|
};
|
||||||
});
|
});
|
||||||
it('should navigate when successful', () => {
|
it('should navigate when successful', () => {
|
||||||
spyOn(router, 'navigate');
|
spyOn(router, 'navigate');
|
||||||
|
@@ -15,6 +15,7 @@ import {
|
|||||||
createFailedRemoteDataObject$,
|
createFailedRemoteDataObject$,
|
||||||
createSuccessfulRemoteDataObject$
|
createSuccessfulRemoteDataObject$
|
||||||
} from '../../testing/utils';
|
} from '../../testing/utils';
|
||||||
|
import { ComColDataService } from '../../../core/data/comcol-data.service';
|
||||||
|
|
||||||
describe('EditComColPageComponent', () => {
|
describe('EditComColPageComponent', () => {
|
||||||
let comp: EditComColPageComponent<DSpaceObject>;
|
let comp: EditComColPageComponent<DSpaceObject>;
|
||||||
@@ -65,7 +66,7 @@ describe('EditComColPageComponent', () => {
|
|||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [TranslateModule.forRoot(), SharedModule, CommonModule, RouterTestingModule],
|
imports: [TranslateModule.forRoot(), SharedModule, CommonModule, RouterTestingModule],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: DataService, useValue: communityDataServiceStub },
|
{ provide: ComColDataService, useValue: communityDataServiceStub },
|
||||||
{ provide: Router, useValue: routerStub },
|
{ provide: Router, useValue: routerStub },
|
||||||
{ provide: ActivatedRoute, useValue: routeStub },
|
{ provide: ActivatedRoute, useValue: routeStub },
|
||||||
],
|
],
|
||||||
@@ -84,12 +85,21 @@ describe('EditComColPageComponent', () => {
|
|||||||
describe('onSubmit', () => {
|
describe('onSubmit', () => {
|
||||||
let data;
|
let data;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
data = Object.assign(new Community(), {
|
data = {
|
||||||
|
dso: Object.assign(new Community(), {
|
||||||
metadata: [{
|
metadata: [{
|
||||||
key: 'dc.title',
|
key: 'dc.title',
|
||||||
value: 'test'
|
value: 'test'
|
||||||
}]
|
}]
|
||||||
});
|
}),
|
||||||
|
uploader: {
|
||||||
|
options: {
|
||||||
|
url: ''
|
||||||
|
},
|
||||||
|
queue: [],
|
||||||
|
uploadAll: {}
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
it('should navigate when successful', () => {
|
it('should navigate when successful', () => {
|
||||||
spyOn(router, 'navigate');
|
spyOn(router, 'navigate');
|
||||||
|
@@ -3,4 +3,7 @@ export class AuthServiceMock {
|
|||||||
public checksAuthenticationToken() {
|
public checksAuthenticationToken() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
public buildAuthHeader() {
|
||||||
|
return 'auth-header';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user