diff --git a/src/app/entity-groups/research-entities/submission/item-list-elements/person/person-search-result-list-submission-element.component.spec.ts b/src/app/entity-groups/research-entities/submission/item-list-elements/person/person-search-result-list-submission-element.component.spec.ts
index 4cb8b9fb5e..385ce60302 100644
--- a/src/app/entity-groups/research-entities/submission/item-list-elements/person/person-search-result-list-submission-element.component.spec.ts
+++ b/src/app/entity-groups/research-entities/submission/item-list-elements/person/person-search-result-list-submission-element.component.spec.ts
@@ -27,7 +27,6 @@ import { TruncatePipe } from '../../../../../shared/utils/truncate.pipe';
import { PersonSearchResultListSubmissionElementComponent } from './person-search-result-list-submission-element.component';
import { APP_CONFIG } from '../../../../../../config/app-config.interface';
import { ThumbnailComponent } from '../../../../../thumbnail/thumbnail.component';
-import { PersonInputSuggestionsComponent } from './person-suggestions/person-input-suggestions.component';
import { CollectionElementLinkType } from '../../../../../shared/object-collection/collection-element-link.type';
import { AuthService } from '../../../../../core/auth/auth.service';
import { REQUEST } from '@nguniversal/express-engine/tokens';
@@ -211,7 +210,7 @@ describe('PersonSearchResultListElementSubmissionComponent', () => {
beforeEach(waitForAsync(() => {
init();
TestBed.configureTestingModule({
- imports: [PersonSearchResultListSubmissionElementComponent, TruncatePipe],
+ imports: [PersonSearchResultListSubmissionElementComponent, TruncatePipe, BrowseByRoutingModule],
providers: [
{ provide: TruncatableService, useValue: {} },
{ provide: RelationshipDataService, useValue: mockRelationshipService },
@@ -233,7 +232,7 @@ describe('PersonSearchResultListElementSubmissionComponent', () => {
schemas: [NO_ERRORS_SCHEMA]
}).overrideComponent(PersonSearchResultListSubmissionElementComponent, {
remove: {
- imports: [ThumbnailComponent, PersonInputSuggestionsComponent]
+ imports: [ThumbnailComponent]
},
add: { changeDetection: ChangeDetectionStrategy.Default }
}).compileComponents();
@@ -261,7 +260,7 @@ describe('PersonSearchResultListElementSubmissionComponent', () => {
@Component({
selector: 'ds-mock-thumbnail',
template: '
',
- standalone: true
+ standalone: true,
})
export class ThumbnailStubComponent {
diff --git a/src/app/health-page/health-info/health-info-component/health-info-component.component.ts b/src/app/health-page/health-info/health-info-component/health-info-component.component.ts
index c37e2217da..8408d66443 100644
--- a/src/app/health-page/health-info/health-info-component/health-info-component.component.ts
+++ b/src/app/health-page/health-info/health-info-component/health-info-component.component.ts
@@ -1,4 +1,4 @@
-import { Component, Input, forwardRef } from '@angular/core';
+import { Component, Input } from '@angular/core';
import { HealthInfoComponent } from '../../models/health-component.model';
import { HealthComponentComponent } from '../../health-panel/health-component/health-component.component';
@@ -14,7 +14,7 @@ import { NgFor, NgIf, TitleCasePipe } from '@angular/common';
templateUrl: './health-info-component.component.html',
styleUrls: ['./health-info-component.component.scss'],
standalone: true,
- imports: [NgFor, NgIf, NgbCollapseModule, forwardRef(() => HealthInfoComponentComponent), TitleCasePipe, ObjNgFor]
+ imports: [NgFor, NgIf, NgbCollapseModule, TitleCasePipe, ObjNgFor]
})
export class HealthInfoComponentComponent extends HealthComponentComponent {
diff --git a/src/app/health-page/health-info/health-info.component.spec.ts b/src/app/health-page/health-info/health-info.component.spec.ts
index 7adc2bc96e..d79105c9bb 100644
--- a/src/app/health-page/health-info/health-info.component.spec.ts
+++ b/src/app/health-page/health-info/health-info.component.spec.ts
@@ -44,6 +44,6 @@ describe('HealthInfoComponent', () => {
it('should create info component properly', () => {
const components = fixture.debugElement.queryAll(By.css('[data-test="info-component"]'));
- expect(components.length).toBe(3);
+ expect(components.length).toBe(7);
});
});
diff --git a/src/app/health-page/health-panel/health-component/health-component.component.spec.ts b/src/app/health-page/health-panel/health-component/health-component.component.spec.ts
index f3285d4cf5..4f8600ad39 100644
--- a/src/app/health-page/health-panel/health-component/health-component.component.spec.ts
+++ b/src/app/health-page/health-panel/health-component/health-component.component.spec.ts
@@ -32,7 +32,7 @@ describe('HealthComponentComponent', () => {
ObjNgFor
],
schemas: [NO_ERRORS_SCHEMA]
-})
+ })
.compileComponents();
});
diff --git a/src/app/health-page/health-panel/health-component/health-component.component.ts b/src/app/health-page/health-panel/health-component/health-component.component.ts
index df970b49a0..1db7f3c4b5 100644
--- a/src/app/health-page/health-panel/health-component/health-component.component.ts
+++ b/src/app/health-page/health-panel/health-component/health-component.component.ts
@@ -1,4 +1,4 @@
-import { Component, Input, forwardRef } from '@angular/core';
+import { Component, Input } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
@@ -21,7 +21,7 @@ import { NgIf, NgFor, TitleCasePipe } from '@angular/common';
templateUrl: './health-component.component.html',
styleUrls: ['./health-component.component.scss'],
standalone: true,
- imports: [NgIf, NgFor, NgbCollapseModule, forwardRef(() => HealthComponentComponent), AlertComponent, TitleCasePipe, ObjNgFor]
+ imports: [NgIf, NgFor, NgbCollapseModule, AlertComponent, TitleCasePipe, ObjNgFor]
})
export class HealthComponentComponent {
diff --git a/src/app/register-email-form/register-email-form.component.spec.ts b/src/app/register-email-form/register-email-form.component.spec.ts
index d0809123ff..d6d077608e 100644
--- a/src/app/register-email-form/register-email-form.component.spec.ts
+++ b/src/app/register-email-form/register-email-form.component.spec.ts
@@ -4,10 +4,10 @@ import { RestResponse } from '../core/cache/response.models';
import { CommonModule } from '@angular/common';
import { RouterTestingModule } from '@angular/router/testing';
import { TranslateModule } from '@ngx-translate/core';
-import { UntypedFormBuilder, ReactiveFormsModule } from '@angular/forms';
+import { UntypedFormBuilder, ReactiveFormsModule, FormsModule } from '@angular/forms';
import { Router } from '@angular/router';
import { NotificationsService } from '../shared/notifications/notifications.service';
-import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
+import { NO_ERRORS_SCHEMA } from '@angular/core';
import { EpersonRegistrationService } from '../core/data/eperson-registration.service';
import { By } from '@angular/platform-browser';
import { RouterStub } from '../shared/testing/router.stub';
@@ -23,6 +23,8 @@ import { GoogleRecaptchaService } from '../core/google-recaptcha/google-recaptch
import { CookieService } from '../core/services/cookie.service';
import { CookieServiceMock } from '../shared/mocks/cookie.service.mock';
import { ConfigurationProperty } from '../core/shared/configuration-property.model';
+import { GoogleRecaptchaComponent } from '../shared/google-recaptcha/google-recaptcha.component';
+import { AlertComponent } from '../shared/alert/alert.component';
describe('RegisterEmailFormComponent', () => {
@@ -61,7 +63,7 @@ describe('RegisterEmailFormComponent', () => {
jasmine.getEnv().allowRespy(true);
TestBed.configureTestingModule({
- imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), ReactiveFormsModule, RegisterEmailFormComponent],
+ imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), ReactiveFormsModule, RegisterEmailFormComponent, FormsModule],
providers: [
{ provide: Router, useValue: router },
{ provide: EpersonRegistrationService, useValue: epersonRegistrationService },
@@ -71,8 +73,11 @@ describe('RegisterEmailFormComponent', () => {
{ provide: CookieService, useValue: new CookieServiceMock() },
{ provide: GoogleRecaptchaService, useValue: googleRecaptchaService },
],
- schemas: [CUSTOM_ELEMENTS_SCHEMA]
-}).compileComponents();
+ schemas: [NO_ERRORS_SCHEMA]
+}).overrideComponent(RegisterEmailFormComponent, {
+ remove: { imports: [GoogleRecaptchaComponent, AlertComponent] }
+})
+ .compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(RegisterEmailFormComponent);
diff --git a/src/app/shared/eperson-group-list/eperson-group-list.component.spec.ts b/src/app/shared/eperson-group-list/eperson-group-list.component.spec.ts
index 96ac9f9378..30714d4b3c 100644
--- a/src/app/shared/eperson-group-list/eperson-group-list.component.spec.ts
+++ b/src/app/shared/eperson-group-list/eperson-group-list.component.spec.ts
@@ -281,7 +281,8 @@ describe('EpersonGroupListComponent test suite', () => {
@Component({
selector: 'ds-test-cmp',
template: ``,
- standalone: true
+ standalone: true,
+ imports: [EpersonGroupListComponent]
})
class TestComponent {
diff --git a/src/app/shared/hover-class.directive.spec.ts b/src/app/shared/hover-class.directive.spec.ts
index 924e0cf06d..c14e13b3cc 100644
--- a/src/app/shared/hover-class.directive.spec.ts
+++ b/src/app/shared/hover-class.directive.spec.ts
@@ -5,7 +5,8 @@ import { By } from '@angular/platform-browser';
@Component({
template: ``,
- standalone: true
+ standalone: true,
+ imports: [HoverClassDirective]
})
class TestComponent {
}
diff --git a/src/app/shared/menu/menu-item/link-menu-item.component.spec.ts b/src/app/shared/menu/menu-item/link-menu-item.component.spec.ts
index 5c36fea2d3..ee7da723aa 100644
--- a/src/app/shared/menu/menu-item/link-menu-item.component.spec.ts
+++ b/src/app/shared/menu/menu-item/link-menu-item.component.spec.ts
@@ -27,7 +27,6 @@ describe('LinkMenuItemComponent', () => {
init();
TestBed.configureTestingModule({
imports: [TranslateModule.forRoot(), LinkMenuItemComponent],
- declarations: [QueryParamsDirectiveStub],
providers: [
{ provide: 'itemModelProvider', useValue: { text: text, link: link, queryParams: queryParams } },
{ provide: Router, useValue: new RouterStub() },
@@ -40,7 +39,7 @@ describe('LinkMenuItemComponent', () => {
})
.overrideComponent(LinkMenuItemComponent, {
remove: { imports: [] },
- add: { imports: [RouterLinkDirectiveStub] }
+ add: { imports: [RouterLinkDirectiveStub, QueryParamsDirectiveStub] }
})
.compileComponents();
}));
diff --git a/src/app/shared/metadata-field-wrapper/metadata-field-wrapper.component.spec.ts b/src/app/shared/metadata-field-wrapper/metadata-field-wrapper.component.spec.ts
index 40301daf0f..54764464da 100644
--- a/src/app/shared/metadata-field-wrapper/metadata-field-wrapper.component.spec.ts
+++ b/src/app/shared/metadata-field-wrapper/metadata-field-wrapper.component.spec.ts
@@ -8,7 +8,8 @@ import { MetadataFieldWrapperComponent } from './metadata-field-wrapper.componen
selector: 'ds-component-without-content',
template: '\n' +
'',
- standalone: true
+ standalone: true,
+ imports: [MetadataFieldWrapperComponent]
})
class NoContentComponent {
public hideIfNoTextContent = true;
@@ -20,7 +21,8 @@ class NoContentComponent {
' \n' +
' \n' +
'',
- standalone: true
+ standalone: true,
+ imports: [MetadataFieldWrapperComponent]
})
class SpanContentComponent {
@Input() hideIfNoTextContent = true;
@@ -31,7 +33,8 @@ class SpanContentComponent {
template: '\n' +
' The quick brown fox jumps over the lazy dog\n' +
'',
- standalone: true
+ standalone: true,
+ imports: [MetadataFieldWrapperComponent]
})
class TextContentComponent {
@Input() hideIfNoTextContent = true;
diff --git a/src/app/shared/mocks/form-builder-service.mock.ts b/src/app/shared/mocks/form-builder-service.mock.ts
index 4d35c21324..7fcb033d45 100644
--- a/src/app/shared/mocks/form-builder-service.mock.ts
+++ b/src/app/shared/mocks/form-builder-service.mock.ts
@@ -11,6 +11,7 @@ export function getMockFormBuilderService(): FormBuilderService {
getFormControlById: new UntypedFormControl(),
hasMappedGroupValue: false,
findById: {},
+ fromJSON: {},
getPath: ['test', 'path'],
getId: 'path',
clearAllModelsValue : {},
diff --git a/src/app/shared/resource-policies/form/resource-policy-form.component.spec.ts b/src/app/shared/resource-policies/form/resource-policy-form.component.spec.ts
index 0654c3cc02..137f446b8f 100644
--- a/src/app/shared/resource-policies/form/resource-policy-form.component.spec.ts
+++ b/src/app/shared/resource-policies/form/resource-policy-form.component.spec.ts
@@ -1,6 +1,6 @@
import { ComponentFixture, inject, TestBed, waitForAsync } from '@angular/core/testing';
import { Component, NO_ERRORS_SCHEMA } from '@angular/core';
-import { BrowserModule, By } from '@angular/platform-browser';
+import { By } from '@angular/platform-browser';
import { CommonModule} from '@angular/common';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
@@ -203,6 +203,7 @@ describe('ResourcePolicyFormComponent test suite', () => {
{ provide: PaginationService, useValue: new PaginationServiceStub() },
{ provide: RequestService, useValue: getMockRequestService() },
FormBuilderService,
+ ResourcePolicyFormComponent,
{ provide: DsDynamicTypeBindRelationService, useClass: DsDynamicTypeBindRelationService },
{ provide: SubmissionObjectDataService, useValue: {} },
{ provide: SubmissionService, useValue: {} },
@@ -464,7 +465,7 @@ describe('ResourcePolicyFormComponent test suite', () => {
selector: 'ds-test-cmp',
template: ``,
standalone: true,
- imports: [BrowserModule,
+ imports: [
CommonModule,
FormsModule,
NgbModule,
diff --git a/src/app/shared/resource-policies/form/resource-policy-form.component.ts b/src/app/shared/resource-policies/form/resource-policy-form.component.ts
index 3a2b304a4f..5296ea5b0b 100644
--- a/src/app/shared/resource-policies/form/resource-policy-form.component.ts
+++ b/src/app/shared/resource-policies/form/resource-policy-form.component.ts
@@ -45,7 +45,7 @@ import { NgbModal, NgbNavChangeEvent, NgbNavModule } from '@ng-bootstrap/ng-boot
import { FormComponent } from '../../form/form.component';
import { EpersonGroupListComponent } from '../../eperson-group-list/eperson-group-list.component';
import { TranslateModule } from '@ngx-translate/core';
-import { AsyncPipe, CommonModule, NgFor, NgIf } from '@angular/common';
+import { AsyncPipe, NgFor, NgIf } from '@angular/common';
export interface ResourcePolicyEvent {
object: ResourcePolicy;
diff --git a/src/app/shared/search/search-results/search-results.component.spec.ts b/src/app/shared/search/search-results/search-results.component.spec.ts
index d588ab98a4..2438fc8a1f 100644
--- a/src/app/shared/search/search-results/search-results.component.spec.ts
+++ b/src/app/shared/search/search-results/search-results.component.spec.ts
@@ -33,7 +33,6 @@ describe('SearchResultsComponent', () => {
NoopAnimationsModule,
SearchResultsComponent,
],
- declarations: [QueryParamsDirectiveStub],
schemas: [NO_ERRORS_SCHEMA],
})
.overrideComponent(SearchResultsComponent, {
@@ -45,6 +44,7 @@ describe('SearchResultsComponent', () => {
ErrorComponent,
],
},
+ add: { imports: [QueryParamsDirectiveStub] }
})
.compileComponents();
}));
diff --git a/src/app/shared/testing/query-params-directive.stub.ts b/src/app/shared/testing/query-params-directive.stub.ts
index 60f76786c7..11084c8ed1 100644
--- a/src/app/shared/testing/query-params-directive.stub.ts
+++ b/src/app/shared/testing/query-params-directive.stub.ts
@@ -4,6 +4,7 @@ import { Directive, Input } from '@angular/core';
@Directive({
// eslint-disable-next-line @angular-eslint/directive-selector
selector: '[queryParams]',
+ standalone: true
})
export class QueryParamsDirectiveStub {
@Input() queryParams: any;
diff --git a/src/app/shared/upload/uploader/uploader.component.spec.ts b/src/app/shared/upload/uploader/uploader.component.spec.ts
index 8a858de96c..84daff9f58 100644
--- a/src/app/shared/upload/uploader/uploader.component.spec.ts
+++ b/src/app/shared/upload/uploader/uploader.component.spec.ts
@@ -64,7 +64,7 @@ describe('Chips component', () => {
selector: 'ds-test-cmp',
template: ``,
standalone: true,
- imports: [FileUploadModule]
+ imports: [FileUploadModule, UploaderComponent]
})
class TestComponent {
public uploadFilesOptions: UploaderOptions = Object.assign(new UploaderOptions(), {
diff --git a/src/app/submission/sections/accesses/section-accesses.component.spec.ts b/src/app/submission/sections/accesses/section-accesses.component.spec.ts
index 8c354bf922..dccb449267 100644
--- a/src/app/submission/sections/accesses/section-accesses.component.spec.ts
+++ b/src/app/submission/sections/accesses/section-accesses.component.spec.ts
@@ -15,17 +15,15 @@ import {
import { SectionAccessesService } from './section-accesses.service';
import { SectionFormOperationsService } from '../form/section-form-operations.service';
import { JsonPatchOperationsBuilder } from '../../../core/json-patch/builder/json-patch-operations-builder';
-import { TranslateModule, TranslateService } from '@ngx-translate/core';
+import { TranslateModule } from '@ngx-translate/core';
import {
SubmissionJsonPatchOperationsService
} from '../../../core/submission/submission-json-patch-operations.service';
import { getSectionAccessesService } from '../../../shared/mocks/section-accesses.service.mock';
import { getMockFormOperationsService } from '../../../shared/mocks/form-operations-service.mock';
-import { getMockTranslateService } from '../../../shared/mocks/translate.service.mock';
import {
SubmissionJsonPatchOperationsServiceStub
} from '../../../shared/testing/submission-json-patch-operations-service.stub';
-import { BrowserModule } from '@angular/platform-browser';
import { of as observableOf } from 'rxjs';
import { Store } from '@ngrx/store';
@@ -34,7 +32,6 @@ import {
DynamicCheckboxModel,
DynamicDatePickerModel,
DynamicFormArrayModel,
- DynamicFormValidationService,
DynamicSelectModel
} from '@ng-dynamic-forms/core';
import { AppState } from '../../../app.reducer';
@@ -47,7 +44,7 @@ import { SubmissionObjectDataService } from '../../../core/submission/submission
import { SubmissionService } from '../../submission.service';
import { APP_CONFIG } from 'src/config/app-config.interface';
import { environment } from 'src/environments/environment.test';
-import { mockDynamicFormValidationService } from '../../../shared/testing/dynamic-form-mock-services';
+import { CommonModule } from '@angular/common';
function getMockDsDynamicTypeBindRelationService(): DsDynamicTypeBindRelationService {
return jasmine.createSpyObj('DsDynamicTypeBindRelationService', {
@@ -99,9 +96,10 @@ describe('SubmissionSectionAccessesComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [
- BrowserModule,
+ CommonModule,
TranslateModule.forRoot(),
- SubmissionSectionAccessesComponent, FormComponent
+ SubmissionSectionAccessesComponent,
+ FormComponent,
],
providers: [
{ provide: SectionsService, useValue: sectionsServiceStub },
@@ -195,19 +193,17 @@ describe('SubmissionSectionAccessesComponent', () => {
formService = getMockFormService();
await TestBed.configureTestingModule({
imports: [
- BrowserModule,
+ CommonModule,
TranslateModule.forRoot(),
SubmissionSectionAccessesComponent,
FormComponent,
],
providers: [
{ provide: SectionsService, useValue: sectionsServiceStub },
- { provide: FormBuilderService, useValue: builderService },
{ provide: SubmissionAccessesConfigDataService, useValue: getSubmissionAccessesConfigNotChangeDiscoverableService() },
{ provide: SectionAccessesService, useValue: sectionAccessesService },
{ provide: SectionFormOperationsService, useValue: sectionFormOperationsService },
{ provide: JsonPatchOperationsBuilder, useValue: operationsBuilder },
- { provide: TranslateService, useValue: getMockTranslateService() },
{ provide: FormService, useValue: formService },
{ provide: Store, useValue: storeStub },
{ provide: SubmissionJsonPatchOperationsService, useValue: SubmissionJsonPatchOperationsServiceStub },
@@ -217,18 +213,12 @@ describe('SubmissionSectionAccessesComponent', () => {
{ provide: SubmissionObjectDataService, useValue: {} },
{ provide: SubmissionService, useValue: {} },
{ provide: APP_CONFIG, useValue: environment },
- { provide: DynamicFormValidationService, useValue: mockDynamicFormValidationService },
+ FormBuilderService,
+ provideMockStore({})
]
})
- .overrideComponent(SubmissionSectionAccessesComponent, {
- remove: {
- imports: [
-
- ]
- }
- })
- .compileComponents();
+ .compileComponents();
});
beforeEach(() => {
diff --git a/src/app/submission/sections/license/section-license.component.spec.ts b/src/app/submission/sections/license/section-license.component.spec.ts
index 2149f602a0..3afce8b4bb 100644
--- a/src/app/submission/sections/license/section-license.component.spec.ts
+++ b/src/app/submission/sections/license/section-license.component.spec.ts
@@ -27,6 +27,7 @@ import {
mockSubmissionCollectionId,
mockSubmissionId
} from '../../../shared/mocks/submission.mock';
+import { FormComponent } from '../../../shared/form/form.component';
import { JsonPatchOperationPathCombiner } from '../../../core/json-patch/builder/json-patch-operation-path-combiner';
import { SubmissionSectionLicenseComponent } from './section-license.component';
import { CollectionDataService } from '../../../core/data/collection-data.service';
@@ -36,8 +37,20 @@ import { Collection } from '../../../core/shared/collection.model';
import { License } from '../../../core/shared/license.model';
import { FormFieldMetadataValueObject } from '../../../shared/form/builder/models/form-field-metadata-value.model';
import { cold } from 'jasmine-marbles';
+import { provideMockStore } from '@ngrx/store/testing';
+import { DsDynamicTypeBindRelationService } from 'src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-type-bind-relation.service';
+import { APP_CONFIG } from 'src/config/app-config.interface';
+import { environment } from 'src/environments/environment.test';
+import { getMockFormBuilderService } from 'src/app/shared/mocks/form-builder-service.mock';
import { SECTION_LICENSE_FORM_MODEL } from './section-license.model';
-import { FormComponent } from 'src/app/shared/form/form.component';
+
+function getMockDsDynamicTypeBindRelationService(): DsDynamicTypeBindRelationService {
+ return jasmine.createSpyObj('DsDynamicTypeBindRelationService', {
+ getRelatedFormModel: jasmine.createSpy('getRelatedFormModel'),
+ matchesCondition: jasmine.createSpy('matchesCondition'),
+ subscribeRelations: jasmine.createSpy('subscribeRelations')
+ });
+}
const collectionId = mockSubmissionCollectionId;
const licenseText = 'License text';
@@ -62,6 +75,17 @@ function getMockSubmissionFormsConfigService(): SubmissionFormsConfigDataService
});
}
+const formBuilderServiceStub = {
+ findById: jasmine.createSpy('findById'),
+ fromJSON: jasmine.createSpy('fromJSON'),
+ createFormGroup: () => {
+ return {
+ patchValue: () => { },
+ reset(_value?: any, _options?: { onlySelf?: boolean; emitEvent?: boolean; }): void { },
+ };
+ }
+};
+
const sectionObject: SectionDataObject = {
config: 'https://dspace7.4science.it/or2018/api/config/submissionforms/license',
mandatory: true,
@@ -86,17 +110,6 @@ const dynamicFormControlEvent: DynamicFormControlEvent = {
type: DynamicFormControlEventType.Change
};
-const formBuilderServiceStub = {
- findById: jasmine.createSpy('findById'),
- fromJSON: jasmine.createSpy('fromJSON'),
- createFormGroup: () => {
- return {
- patchValue: () => { },
- reset(_value?: any, _options?: { onlySelf?: boolean; emitEvent?: boolean; }): void { },
- };
- }
-};
-
describe('SubmissionSectionLicenseComponent test suite', () => {
let comp: SubmissionSectionLicenseComponent;
@@ -145,13 +158,15 @@ describe('SubmissionSectionLicenseComponent test suite', () => {
{ provide: 'collectionIdProvider', useValue: collectionId },
{ provide: 'sectionDataProvider', useValue: Object.assign({}, sectionObject) },
{ provide: 'submissionIdProvider', useValue: submissionId },
- { provide: FormBuilderService, useValue: formBuilderServiceStub },
ChangeDetectorRef,
+ provideMockStore({}),
+ { provide: FormBuilderService, useValue: getMockFormBuilderService() },
+ { provide:DsDynamicTypeBindRelationService, useValue: getMockDsDynamicTypeBindRelationService() },
+ { provide: APP_CONFIG, useValue: environment },
SubmissionSectionLicenseComponent
],
schemas: [NO_ERRORS_SCHEMA]
- })
- .compileComponents().then();
+ }).compileComponents().then();
}));
describe('', () => {
@@ -207,16 +222,18 @@ describe('SubmissionSectionLicenseComponent test suite', () => {
mockCollectionDataService.findById.and.returnValue(createSuccessfulRemoteDataObject$(mockCollection));
sectionsServiceStub.getSectionErrors.and.returnValue(observableOf([]));
sectionsServiceStub.isSectionReadOnly.and.returnValue(observableOf(false));
- formBuilderServiceStub.findById.and.returnValue(new DynamicCheckboxModel({ id: 'granted'}));
- formBuilderServiceStub.fromJSON.and.returnValue(SECTION_LICENSE_FORM_MODEL);
+ (formBuilderService.findById as jasmine.Spy).and.returnValue(new DynamicCheckboxModel({ id: 'granted'}));
+ (formBuilderService.fromJSON as jasmine.Spy).and.returnValue(SECTION_LICENSE_FORM_MODEL);
+ // formBuilderServiceStub.findById.and.returnValue(new DynamicCheckboxModel({ id: 'granted'}));
+ // formBuilderServiceStub.fromJSON.and.returnValue(SECTION_LICENSE_FORM_MODEL);
+ comp.onSectionInit();
+ fixture.detectChanges();
});
it('should init section properly', () => {
spyOn(compAsAny, 'getSectionStatus');
- comp.onSectionInit();
-
const model = formBuilderService.findById('granted', comp.formModel);
expect(compAsAny.subs.length).toBe(2);
@@ -237,8 +254,6 @@ describe('SubmissionSectionLicenseComponent test suite', () => {
spyOn(compAsAny, 'getSectionStatus');
- comp.onSectionInit();
-
const model = formBuilderService.findById('granted', comp.formModel);
expect(compAsAny.subs.length).toBe(2);
@@ -250,17 +265,17 @@ describe('SubmissionSectionLicenseComponent test suite', () => {
}));
});
- it('should have status true when checkbox is selected', () => {
- fixture.detectChanges();
+ fit('should have status true when checkbox is selected', () => {
const model = formBuilderService.findById('granted', comp.formModel);
+
(model as DynamicCheckboxModel).value = true;
+
compAsAny.getSectionStatus().subscribe((status) => {
expect(status).toBeTruthy();
});
});
it('should have status false when checkbox is not selected', () => {
- fixture.detectChanges();
const model = formBuilderService.findById('granted', comp.formModel);
compAsAny.getSectionStatus().subscribe((status) => {
@@ -277,7 +292,6 @@ describe('SubmissionSectionLicenseComponent test suite', () => {
mockCollectionDataService.findById.and.returnValue(createSuccessfulRemoteDataObject$(mockCollection));
sectionsServiceStub.getSectionErrors.and.returnValue(observableOf(mockLicenseParsedErrors.license));
sectionsServiceStub.isSectionReadOnly.and.returnValue(observableOf(false));
- formBuilderServiceStub.findById.and.returnValue(new DynamicCheckboxModel({ id: 'granted' }));
});
it('should set section errors properly', () => {
@@ -340,7 +354,8 @@ describe('SubmissionSectionLicenseComponent test suite', () => {
imports: [
CommonModule,
FormsModule,
- ReactiveFormsModule]
+ ReactiveFormsModule
+ ]
})
class TestComponent {
diff --git a/src/app/workflowitems-edit-page/advanced-workflow-action/advanced-workflow-action-page/advanced-workflow-action-page.component.spec.ts b/src/app/workflowitems-edit-page/advanced-workflow-action/advanced-workflow-action-page/advanced-workflow-action-page.component.spec.ts
index 4fd46efdea..6e36ff60d6 100644
--- a/src/app/workflowitems-edit-page/advanced-workflow-action/advanced-workflow-action-page/advanced-workflow-action-page.component.spec.ts
+++ b/src/app/workflowitems-edit-page/advanced-workflow-action/advanced-workflow-action-page/advanced-workflow-action-page.component.spec.ts
@@ -2,6 +2,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
import { AdvancedWorkflowActionPageComponent } from './advanced-workflow-action-page.component';
import { ActivatedRoute } from '@angular/router';
import { TranslateModule } from '@ngx-translate/core';
+import { AdvancedWorkflowActionsLoaderComponent } from '../advanced-workflow-actions-loader/advanced-workflow-actions-loader.component';
describe('AdvancedWorkflowActionPageComponent', () => {
let component: AdvancedWorkflowActionPageComponent;
@@ -11,7 +12,7 @@ describe('AdvancedWorkflowActionPageComponent', () => {
await TestBed.configureTestingModule({
imports: [
TranslateModule.forRoot(),
- AdvancedWorkflowActionPageComponent
+ AdvancedWorkflowActionPageComponent,
],
providers: [
{
@@ -25,7 +26,10 @@ describe('AdvancedWorkflowActionPageComponent', () => {
},
},
]
-}).compileComponents();
+}).overrideComponent(AdvancedWorkflowActionPageComponent, {
+ remove: { imports: [AdvancedWorkflowActionsLoaderComponent] }
+})
+.compileComponents();
});
beforeEach(() => {