fixed more tests

This commit is contained in:
lotte
2020-02-04 12:36:17 +01:00
parent d1b7f07c68
commit 34c5d93a98
7 changed files with 22 additions and 26 deletions

View File

@@ -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);
}
}

View File

@@ -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();
});

View File

@@ -147,8 +147,6 @@ 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(
@@ -159,8 +157,6 @@ export class RelationshipService extends DataService<Relationship> {
take(1),
switchMap(() => this.itemService.findByHref(item.self).pipe(take(1)))
).subscribe();
}, 1000)
}
/**

View File

@@ -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();

View File

@@ -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: {}},
],
});
}));

View File

@@ -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();
}));

View File

@@ -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);