Skip to content
Snippets Groups Projects
Commit f3a03247 authored by Kristof De Langhe's avatar Kristof De Langhe
Browse files

65240: Fixed current tests

parent eade3e7d
Branches
Tags
No related merge requests found
......@@ -7,10 +7,14 @@ import { DynamicFormService, DynamicInputModel } from '@ng-dynamic-forms/core';
import { FormControl, FormGroup } from '@angular/forms';
import { DynamicFormControlModel } from '@ng-dynamic-forms/core/src/model/dynamic-form-control.model';
import { Community } from '../../../core/shared/community.model';
import { ResourceType } from '../../../core/shared/resource-type';
import { ComColFormComponent } from './comcol-form.component';
import { DSpaceObject } from '../../../core/shared/dspace-object.model';
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', () => {
let comp: ComColFormComponent<DSpaceObject>;
......@@ -56,10 +60,12 @@ describe('ComColFormComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [TranslateModule.forRoot(), RouterTestingModule],
declarations: [ComColFormComponent],
declarations: [ComColFormComponent, VarDirective],
providers: [
{ 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]
}).compileComponents();
......@@ -70,6 +76,10 @@ describe('ComColFormComponent', () => {
comp = fixture.componentInstance;
comp.formModel = [];
comp.dso = new Community();
(comp as any).type = Community.type;
comp.uploaderComponent = Object.assign({
uploader: {}
});
fixture.detectChanges();
location = (comp as any).location;
});
......@@ -94,18 +104,21 @@ describe('ComColFormComponent', () => {
comp.onSubmit();
expect(comp.submitForm.emit).toHaveBeenCalledWith(
Object.assign(
{},
new Community(),
{
metadata: {
...newTitleMD,
...randomMD,
...abstractMD
{
dso: Object.assign(
{},
new Community(),
{
metadata: {
...newTitleMD,
...randomMD,
...abstractMD
},
type: Community.type
},
type: Community.type
},
)
),
uploader: {}
}
);
})
});
......
......@@ -16,6 +16,7 @@ import {
createFailedRemoteDataObject$,
createSuccessfulRemoteDataObject$
} from '../../testing/utils';
import { ComColDataService } from '../../../core/data/comcol-data.service';
describe('CreateComColPageComponent', () => {
let comp: CreateComColPageComponent<DSpaceObject>;
......@@ -74,7 +75,7 @@ describe('CreateComColPageComponent', () => {
TestBed.configureTestingModule({
imports: [TranslateModule.forRoot(), SharedModule, CommonModule, RouterTestingModule],
providers: [
{ provide: DataService, useValue: communityDataServiceStub },
{ provide: ComColDataService, useValue: communityDataServiceStub },
{ provide: CommunityDataService, useValue: communityDataServiceStub },
{ provide: RouteService, useValue: routeServiceStub },
{ provide: Router, useValue: routerStub },
......@@ -96,12 +97,21 @@ describe('CreateComColPageComponent', () => {
describe('onSubmit', () => {
let data;
beforeEach(() => {
data = Object.assign(new Community(), {
metadata: [{
key: 'dc.title',
value: 'test'
}]
});
data = {
dso: Object.assign(new Community(), {
metadata: [{
key: 'dc.title',
value: 'test'
}]
}),
uploader: {
options: {
url: ''
},
queue: [],
uploadAll: {}
}
};
});
it('should navigate when successful', () => {
spyOn(router, 'navigate');
......
......@@ -15,6 +15,7 @@ import {
createFailedRemoteDataObject$,
createSuccessfulRemoteDataObject$
} from '../../testing/utils';
import { ComColDataService } from '../../../core/data/comcol-data.service';
describe('EditComColPageComponent', () => {
let comp: EditComColPageComponent<DSpaceObject>;
......@@ -65,7 +66,7 @@ describe('EditComColPageComponent', () => {
TestBed.configureTestingModule({
imports: [TranslateModule.forRoot(), SharedModule, CommonModule, RouterTestingModule],
providers: [
{ provide: DataService, useValue: communityDataServiceStub },
{ provide: ComColDataService, useValue: communityDataServiceStub },
{ provide: Router, useValue: routerStub },
{ provide: ActivatedRoute, useValue: routeStub },
],
......@@ -84,12 +85,21 @@ describe('EditComColPageComponent', () => {
describe('onSubmit', () => {
let data;
beforeEach(() => {
data = Object.assign(new Community(), {
metadata: [{
key: 'dc.title',
value: 'test'
}]
});
data = {
dso: Object.assign(new Community(), {
metadata: [{
key: 'dc.title',
value: 'test'
}]
}),
uploader: {
options: {
url: ''
},
queue: [],
uploadAll: {}
}
}
});
it('should navigate when successful', () => {
spyOn(router, 'navigate');
......
......@@ -3,4 +3,7 @@ export class AuthServiceMock {
public checksAuthenticationToken() {
return
}
public buildAuthHeader() {
return 'auth-header';
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment