mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-11 03:53:02 +00:00
Misc edit community and collection bugs - repair test
This commit is contained in:
@@ -13,13 +13,13 @@ import { DSpaceObject } from '../../../../core/shared/dspace-object.model';
|
|||||||
import { NotificationsService } from '../../../notifications/notifications.service';
|
import { NotificationsService } from '../../../notifications/notifications.service';
|
||||||
import { SharedModule } from '../../../shared.module';
|
import { SharedModule } from '../../../shared.module';
|
||||||
import { NotificationsServiceStub } from '../../../testing/notifications-service.stub';
|
import { NotificationsServiceStub } from '../../../testing/notifications-service.stub';
|
||||||
import { createFailedRemoteDataObject$, createSuccessfulRemoteDataObject$ } from '../../../remote-data.utils';
|
import { createSuccessfulRemoteDataObject$ } from '../../../remote-data.utils';
|
||||||
import { ComcolMetadataComponent } from './comcol-metadata.component';
|
import { ComcolMetadataComponent } from './comcol-metadata.component';
|
||||||
|
|
||||||
describe('ComColMetadataComponent', () => {
|
describe('ComColMetadataComponent', () => {
|
||||||
let comp: ComcolMetadataComponent<DSpaceObject>;
|
let comp: ComcolMetadataComponent<DSpaceObject>;
|
||||||
let fixture: ComponentFixture<ComcolMetadataComponent<DSpaceObject>>;
|
let fixture: ComponentFixture<ComcolMetadataComponent<DSpaceObject>>;
|
||||||
let dsoDataService: CommunityDataService;
|
let dsoDataService;
|
||||||
let router: Router;
|
let router: Router;
|
||||||
|
|
||||||
let community;
|
let community;
|
||||||
@@ -27,7 +27,6 @@ describe('ComColMetadataComponent', () => {
|
|||||||
let communityDataServiceStub;
|
let communityDataServiceStub;
|
||||||
let routerStub;
|
let routerStub;
|
||||||
let routeStub;
|
let routeStub;
|
||||||
let isSuccessful = true;
|
|
||||||
|
|
||||||
const logoEndpoint = 'rest/api/logo/endpoint';
|
const logoEndpoint = 'rest/api/logo/endpoint';
|
||||||
|
|
||||||
@@ -50,11 +49,7 @@ describe('ComColMetadataComponent', () => {
|
|||||||
|
|
||||||
communityDataServiceStub = {
|
communityDataServiceStub = {
|
||||||
update: (com, uuid?) => createSuccessfulRemoteDataObject$(newCommunity),
|
update: (com, uuid?) => createSuccessfulRemoteDataObject$(newCommunity),
|
||||||
patch: () => {
|
patch: () => null,
|
||||||
return observableOf({
|
|
||||||
isSuccessful,
|
|
||||||
})
|
|
||||||
},
|
|
||||||
getLogoEndpoint: () => observableOf(logoEndpoint)
|
getLogoEndpoint: () => observableOf(logoEndpoint)
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -123,22 +118,38 @@ describe('ComColMetadataComponent', () => {
|
|||||||
/* tslint:enable:no-empty */
|
/* tslint:enable:no-empty */
|
||||||
},
|
},
|
||||||
deleteLogo: false,
|
deleteLogo: false,
|
||||||
}
|
};
|
||||||
|
spyOn(router, 'navigate');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should navigate when successful', () => {
|
describe('when successful', () => {
|
||||||
spyOn(router, 'navigate');
|
|
||||||
comp.onSubmit(data);
|
beforeEach(() => {
|
||||||
fixture.detectChanges();
|
spyOn(dsoDataService, 'patch').and.returnValue(observableOf({
|
||||||
expect(router.navigate).toHaveBeenCalled();
|
isSuccessful: true,
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should navigate', () => {
|
||||||
|
comp.onSubmit(data);
|
||||||
|
fixture.detectChanges();
|
||||||
|
expect(router.navigate).toHaveBeenCalled();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not navigate on failure', () => {
|
describe('on failure', () => {
|
||||||
isSuccessful = false;
|
|
||||||
spyOn(router, 'navigate');
|
beforeEach(() => {
|
||||||
comp.onSubmit(data);
|
spyOn(dsoDataService, 'patch').and.returnValue(observableOf({
|
||||||
fixture.detectChanges();
|
isSuccessful: false,
|
||||||
expect(router.navigate).not.toHaveBeenCalled();
|
}));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not navigate', () => {
|
||||||
|
comp.onSubmit(data);
|
||||||
|
fixture.detectChanges();
|
||||||
|
expect(router.navigate).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user