mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
fixed more tests
This commit is contained in:
@@ -32,9 +32,4 @@ export class ProtractorPage {
|
||||
submitByPressingEnter() {
|
||||
element(by.css('#search-navbar-container form input[name="query"]')).sendKeys(protractor.Key.ENTER);
|
||||
}
|
||||
|
||||
submitByPressingEnter() {
|
||||
element(by.css('#search-navbar-container form input[name="query"]')).sendKeys(protractor.Key.ENTER);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -15,6 +15,7 @@ import { DeleteRequest } from './request.models';
|
||||
import { ObjectCacheService } from '../cache/object-cache.service';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../shared/testing/utils';
|
||||
import { fakeAsync, tick } from '@angular/core/testing';
|
||||
|
||||
describe('RelationshipService', () => {
|
||||
let service: RelationshipService;
|
||||
@@ -104,6 +105,9 @@ describe('RelationshipService', () => {
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
jasmine.clock().uninstall();
|
||||
jasmine.clock().install();
|
||||
|
||||
requestService = getMockRequestService(getRequestEntry$(true));
|
||||
service = initTestService();
|
||||
});
|
||||
|
@@ -147,20 +147,16 @@ export class RelationshipService extends DataService<Relationship> {
|
||||
* @param item The item to remove from the cache
|
||||
*/
|
||||
private refreshRelationshipItemsInCache(item) {
|
||||
setTimeout(() => {
|
||||
|
||||
this.objectCache.remove(item.self);
|
||||
this.requestService.removeByHrefSubstring(item.uuid);
|
||||
combineLatest(
|
||||
this.objectCache.hasBySelfLinkObservable(item.self),
|
||||
this.requestService.hasByHrefObservable(item.self)
|
||||
).pipe(
|
||||
filter(([existsInOC, existsInRC]) => !existsInOC && !existsInRC),
|
||||
take(1),
|
||||
switchMap(() => this.itemService.findByHref(item.self).pipe(take(1)))
|
||||
).subscribe();
|
||||
}, 1000)
|
||||
|
||||
this.objectCache.remove(item.self);
|
||||
this.requestService.removeByHrefSubstring(item.uuid);
|
||||
combineLatest(
|
||||
this.objectCache.hasBySelfLinkObservable(item.self),
|
||||
this.requestService.hasByHrefObservable(item.self)
|
||||
).pipe(
|
||||
filter(([existsInOC, existsInRC]) => !existsInOC && !existsInRC),
|
||||
take(1),
|
||||
switchMap(() => this.itemService.findByHref(item.self).pipe(take(1)))
|
||||
).subscribe();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -222,7 +222,6 @@ describe('DsDynamicFormControlContainerComponent test suite', () => {
|
||||
expect(component.group instanceof FormGroup).toBe(true);
|
||||
expect(component.model instanceof DynamicFormControlModel).toBe(true);
|
||||
expect(component.hasErrorMessaging).toBe(false);
|
||||
expect(component.asBootstrapFormGroup).toBe(true);
|
||||
|
||||
expect(component.onControlValueChanges).toBeDefined();
|
||||
expect(component.onModelDisabledUpdates).toBeDefined();
|
||||
|
@@ -18,6 +18,8 @@ import { RestResponse } from '../../../../../core/cache/response.models';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { SubmissionObjectDataService } from '../../../../../core/submission/submission-object-data.service';
|
||||
import { WorkspaceItem } from '../../../../../core/submission/models/workspaceitem.model';
|
||||
import { ObjectCacheService } from '../../../../../core/cache/object-cache.service';
|
||||
import { RequestService } from '../../../../../core/data/request.service';
|
||||
|
||||
describe('RelationshipEffects', () => {
|
||||
let relationEffects: RelationshipEffects;
|
||||
@@ -102,7 +104,9 @@ describe('RelationshipEffects', () => {
|
||||
{ provide: RelationshipTypeService, useValue: mockRelationshipTypeService },
|
||||
{ provide: RelationshipService, useValue: mockRelationshipService },
|
||||
{ provide: SubmissionObjectDataService, useValue: {findById: () => createSuccessfulRemoteDataObject$(new WorkspaceItem())}},
|
||||
{ provide: Store, useValue: jasmine.createSpyObj('store', ['dispatch']) }
|
||||
{ provide: Store, useValue: jasmine.createSpyObj('store', ['dispatch']) },
|
||||
{ provide: ObjectCacheService, useValue: {}},
|
||||
{ provide: RequestService, useValue: {}},
|
||||
],
|
||||
});
|
||||
}));
|
||||
|
@@ -92,7 +92,6 @@ function init() {
|
||||
groupFactory: () => {
|
||||
return [
|
||||
new DynamicInputModel({
|
||||
|
||||
id: 'bootstrapArrayGroupInput',
|
||||
placeholder: 'example array group input',
|
||||
readOnly: false
|
||||
@@ -363,7 +362,7 @@ describe('FormComponent test suite', () => {
|
||||
|
||||
spyOn((formComp as any).formService, 'validateAllFormFields');
|
||||
|
||||
form.next(formState.testForm)
|
||||
form.next(formState.testForm);
|
||||
formFixture.detectChanges();
|
||||
|
||||
formComp.onSubmit();
|
||||
@@ -419,7 +418,7 @@ describe('FormComponent test suite', () => {
|
||||
}));
|
||||
|
||||
it('should dispatch FormChangeAction when an item has been removed from an array', inject([FormBuilderService], (service: FormBuilderService) => {
|
||||
formComp.removeItem(new Event('click'), formComp.formModel[0] as DynamicFormArrayModel, 0);
|
||||
formComp.removeItem(new Event('click'), formComp.formModel[0] as DynamicFormArrayModel, 1);
|
||||
|
||||
expect(store.dispatch).toHaveBeenCalledWith(new FormChangeAction('testFormArray', service.getValueFromModel(formComp.formModel)));
|
||||
}));
|
||||
@@ -427,7 +426,7 @@ describe('FormComponent test suite', () => {
|
||||
it('should emit removeArrayItem Event when an item has been removed from an array', inject([FormBuilderService], (service: FormBuilderService) => {
|
||||
spyOn(formComp.removeArrayItem, 'emit');
|
||||
|
||||
formComp.removeItem(new Event('click'), formComp.formModel[0] as DynamicFormArrayModel, 0);
|
||||
formComp.removeItem(new Event('click'), formComp.formModel[0] as DynamicFormArrayModel, 1);
|
||||
|
||||
expect(formComp.removeArrayItem.emit).toHaveBeenCalled();
|
||||
}));
|
||||
|
@@ -304,7 +304,6 @@ export class FormComponent implements OnDestroy, OnInit {
|
||||
this.formBuilderService.addFormArrayGroup(formArrayControl, arrayContext);
|
||||
const value = formArrayControl.controls[index].value;
|
||||
formArrayControl.controls[formArrayControl.length - 1].setValue(value);
|
||||
formArrayControl.controls[index].setValue(undefined);
|
||||
formArrayControl.controls[index].reset();
|
||||
this.addArrayItem.emit(this.getEvent($event, arrayContext, index, 'add'));
|
||||
this.formService.changeForm(this.formId, this.formModel);
|
||||
|
Reference in New Issue
Block a user