mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
[DURACOM-191] unit test fix
This commit is contained in:
@@ -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: '<div></div>',
|
||||
standalone: true
|
||||
standalone: true,
|
||||
})
|
||||
export class ThumbnailStubComponent {
|
||||
|
||||
|
@@ -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 {
|
||||
|
||||
|
@@ -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);
|
||||
});
|
||||
});
|
||||
|
@@ -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 {
|
||||
|
||||
|
@@ -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);
|
||||
|
@@ -281,7 +281,8 @@ describe('EpersonGroupListComponent test suite', () => {
|
||||
@Component({
|
||||
selector: 'ds-test-cmp',
|
||||
template: ``,
|
||||
standalone: true
|
||||
standalone: true,
|
||||
imports: [EpersonGroupListComponent]
|
||||
})
|
||||
class TestComponent {
|
||||
|
||||
|
@@ -5,7 +5,8 @@ import { By } from '@angular/platform-browser';
|
||||
|
||||
@Component({
|
||||
template: `<div dsHoverClass="ds-hover"></div>`,
|
||||
standalone: true
|
||||
standalone: true,
|
||||
imports: [HoverClassDirective]
|
||||
})
|
||||
class TestComponent {
|
||||
}
|
||||
|
@@ -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();
|
||||
}));
|
||||
|
@@ -8,7 +8,8 @@ import { MetadataFieldWrapperComponent } from './metadata-field-wrapper.componen
|
||||
selector: 'ds-component-without-content',
|
||||
template: '<ds-metadata-field-wrapper [hideIfNoTextContent]="hideIfNoTextContent" [label]="\'test label\'">\n' +
|
||||
'</ds-metadata-field-wrapper>',
|
||||
standalone: true
|
||||
standalone: true,
|
||||
imports: [MetadataFieldWrapperComponent]
|
||||
})
|
||||
class NoContentComponent {
|
||||
public hideIfNoTextContent = true;
|
||||
@@ -20,7 +21,8 @@ class NoContentComponent {
|
||||
' <span></span>\n' +
|
||||
' <span></span>\n' +
|
||||
'</ds-metadata-field-wrapper>',
|
||||
standalone: true
|
||||
standalone: true,
|
||||
imports: [MetadataFieldWrapperComponent]
|
||||
})
|
||||
class SpanContentComponent {
|
||||
@Input() hideIfNoTextContent = true;
|
||||
@@ -31,7 +33,8 @@ class SpanContentComponent {
|
||||
template: '<ds-metadata-field-wrapper [hideIfNoTextContent]="hideIfNoTextContent" [label]="\'test label\'">\n' +
|
||||
' <span>The quick brown fox jumps over the lazy dog</span>\n' +
|
||||
'</ds-metadata-field-wrapper>',
|
||||
standalone: true
|
||||
standalone: true,
|
||||
imports: [MetadataFieldWrapperComponent]
|
||||
})
|
||||
class TextContentComponent {
|
||||
@Input() hideIfNoTextContent = true;
|
||||
|
@@ -11,6 +11,7 @@ export function getMockFormBuilderService(): FormBuilderService {
|
||||
getFormControlById: new UntypedFormControl(),
|
||||
hasMappedGroupValue: false,
|
||||
findById: {},
|
||||
fromJSON: {},
|
||||
getPath: ['test', 'path'],
|
||||
getId: 'path',
|
||||
clearAllModelsValue : {},
|
||||
|
@@ -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,
|
||||
|
@@ -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;
|
||||
|
@@ -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();
|
||||
}));
|
||||
|
@@ -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;
|
||||
|
@@ -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(), {
|
||||
|
@@ -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,16 +213,10 @@ describe('SubmissionSectionAccessesComponent', () => {
|
||||
{ provide: SubmissionObjectDataService, useValue: {} },
|
||||
{ provide: SubmissionService, useValue: {} },
|
||||
{ provide: APP_CONFIG, useValue: environment },
|
||||
{ provide: DynamicFormValidationService, useValue: mockDynamicFormValidationService },
|
||||
FormBuilderService,
|
||||
provideMockStore({})
|
||||
|
||||
]
|
||||
})
|
||||
.overrideComponent(SubmissionSectionAccessesComponent, {
|
||||
remove: {
|
||||
imports: [
|
||||
|
||||
]
|
||||
}
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
|
@@ -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 {
|
||||
|
||||
|
@@ -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(() => {
|
||||
|
Reference in New Issue
Block a user