forked from hazza/dspace-angular
[DURACOM-307] fix tests
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
@if (elem.href) {
|
||||
<a href="{{elem.href}}" target="_blank" rel="noopener noreferrer">{{elem.text}}</a>
|
||||
} @else {
|
||||
{{ elem }}
|
||||
{{ elem.text }}
|
||||
}
|
||||
}
|
||||
</div>
|
||||
|
@@ -84,7 +84,7 @@ export class ContextHelpWrapperComponent implements OnInit, OnDestroy {
|
||||
@Input() set content(translateKey: string) {
|
||||
this.content$.next(translateKey);
|
||||
}
|
||||
private content$: BehaviorSubject<string | undefined> = new BehaviorSubject(undefined);
|
||||
private content$: BehaviorSubject<string> = new BehaviorSubject(null);
|
||||
|
||||
parsedContent$: Observable<ParsedContent>;
|
||||
|
||||
@@ -100,7 +100,7 @@ export class ContextHelpWrapperComponent implements OnInit, OnDestroy {
|
||||
this.content$.pipe(distinctUntilChanged(), mergeMap(translateKey => this.translateService.get(translateKey))),
|
||||
this.dontParseLinks$.pipe(distinctUntilChanged()),
|
||||
]).pipe(
|
||||
map(([text, dontParseLinks]) =>
|
||||
map(([text, dontParseLinks]: [string, boolean]) =>
|
||||
dontParseLinks ? [{ text }] : this.parseLinks(text)),
|
||||
);
|
||||
this.shouldShowIcon$ = this.contextHelpService.shouldShowIcons$();
|
||||
|
@@ -1,4 +1,3 @@
|
||||
import { NgIf } from '@angular/common';
|
||||
import {
|
||||
Component,
|
||||
DebugElement,
|
||||
@@ -164,7 +163,6 @@ describe('DSOSelectorModalWrapperComponent', () => {
|
||||
templateUrl: './dso-selector-modal-wrapper.component.html',
|
||||
imports: [
|
||||
DSOSelectorComponent,
|
||||
NgIf,
|
||||
TranslateModule,
|
||||
],
|
||||
standalone: true,
|
||||
|
@@ -59,11 +59,12 @@ describe('ChipsComponent test suite', () => {
|
||||
// synchronous beforeEach
|
||||
beforeEach(() => {
|
||||
html = `
|
||||
<ds-chips
|
||||
*ngIf="chips.hasItems()"
|
||||
[chips]="chips"
|
||||
[editable]="editable"
|
||||
(selected)="onChipSelected($event)"></ds-chips>`;
|
||||
@if(chips.hasItems()) {
|
||||
<ds-chips
|
||||
[chips]="chips"
|
||||
[editable]="editable"
|
||||
(selected)="onChipSelected($event)"></ds-chips>
|
||||
}`;
|
||||
|
||||
testFixture = createTestComponent(html, TestComponent) as ComponentFixture<TestComponent>;
|
||||
testComp = testFixture.componentInstance;
|
||||
|
@@ -195,11 +195,13 @@ describe('FormComponent test suite', () => {
|
||||
// synchronous beforeEach
|
||||
beforeEach(() => {
|
||||
html = `
|
||||
<ds-form *ngIf="formModel" #formRef="formComponent"
|
||||
@if('formModel') {
|
||||
<ds-form #formRef="formComponent"
|
||||
[formId]="formId"
|
||||
[formModel]="formModel"
|
||||
[displaySubmit]="displaySubmit"
|
||||
[displayCancel]="displayCancel"></ds-form>`;
|
||||
[displayCancel]="displayCancel"></ds-form>
|
||||
}`;
|
||||
|
||||
testFixture = createTestComponent(html, TestComponent) as ComponentFixture<TestComponent>;
|
||||
testComp = testFixture.componentInstance;
|
||||
|
@@ -1,7 +1,4 @@
|
||||
import {
|
||||
NgClass,
|
||||
NgIf,
|
||||
} from '@angular/common';
|
||||
import { NgClass } from '@angular/common';
|
||||
import {
|
||||
ComponentFixture,
|
||||
TestBed,
|
||||
@@ -24,7 +21,6 @@ describe('OrcidBadgeAndTooltipComponent', () => {
|
||||
OrcidBadgeAndTooltipComponent,
|
||||
NgbTooltipModule,
|
||||
NgClass,
|
||||
NgIf,
|
||||
],
|
||||
providers: [
|
||||
{ provide: TranslateService, useValue: { instant: (key: string) => key } },
|
||||
|
@@ -6,7 +6,9 @@ import {
|
||||
} from '@angular/core';
|
||||
import {
|
||||
ComponentFixture,
|
||||
fakeAsync,
|
||||
TestBed,
|
||||
tick,
|
||||
waitForAsync,
|
||||
} from '@angular/core/testing';
|
||||
import {
|
||||
@@ -210,6 +212,11 @@ describe('SubmissionSectionDuplicatesComponent test suite', () => {
|
||||
formOperationsService = TestBed.inject(SectionFormOperationsService);
|
||||
collectionDataService = TestBed.inject(CollectionDataService);
|
||||
compAsAny.pathCombiner = new JsonPatchOperationPathCombiner('sections', sectionObject.id);
|
||||
spyOn(comp, 'getDuplicateData').and.returnValue(observableOf({ potentialDuplicates: duplicates }));
|
||||
collectionDataService.findById.and.returnValue(createSuccessfulRemoteDataObject$(mockCollection));
|
||||
sectionsServiceStub.getSectionErrors.and.returnValue(observableOf([]));
|
||||
sectionsServiceStub.isSectionReadOnly.and.returnValue(observableOf(false));
|
||||
compAsAny.submissionService.getSubmissionScope.and.returnValue(SubmissionScopeType.WorkspaceItem);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
@@ -219,18 +226,13 @@ describe('SubmissionSectionDuplicatesComponent test suite', () => {
|
||||
});
|
||||
|
||||
// Test initialisation of the submission section
|
||||
it('Should init section properly', () => {
|
||||
collectionDataService.findById.and.returnValue(createSuccessfulRemoteDataObject$(mockCollection));
|
||||
sectionsServiceStub.getSectionErrors.and.returnValue(observableOf([]));
|
||||
sectionsServiceStub.isSectionReadOnly.and.returnValue(observableOf(false));
|
||||
compAsAny.submissionService.getSubmissionScope.and.returnValue(SubmissionScopeType.WorkspaceItem);
|
||||
it('Should init section properly', fakeAsync(() => {
|
||||
spyOn(comp, 'getSectionStatus').and.returnValue(observableOf(true));
|
||||
spyOn(comp, 'getDuplicateData').and.returnValue(observableOf({ potentialDuplicates: duplicates }));
|
||||
expect(comp.isLoading).toBeTruthy();
|
||||
comp.onSectionInit();
|
||||
fixture.detectChanges();
|
||||
tick(100);
|
||||
expect(comp.isLoading).toBeFalsy();
|
||||
});
|
||||
}));
|
||||
|
||||
// The following tests look for proper logic in the getSectionStatus() implementation
|
||||
// These are very simple as we don't really have a 'false' state unless we're still loading
|
||||
@@ -241,7 +243,7 @@ describe('SubmissionSectionDuplicatesComponent test suite', () => {
|
||||
}));
|
||||
});
|
||||
it('Should return FALSE', () => {
|
||||
compAsAny.isLoadin = true;
|
||||
compAsAny.isLoading = true;
|
||||
expect(compAsAny.getSectionStatus()).toBeObservable(cold('(a|)', {
|
||||
a: false,
|
||||
}));
|
||||
|
@@ -1,4 +1,3 @@
|
||||
import { NgFor } from '@angular/common';
|
||||
import { Component } from '@angular/core';
|
||||
import {
|
||||
FormsModule,
|
||||
@@ -15,7 +14,7 @@ import { StartsWithDateComponent as BaseComponent } from '../../../../../../app/
|
||||
// templateUrl: './starts-with-date.component.html',
|
||||
templateUrl: '../../../../../../app/shared/starts-with/date/starts-with-date.component.html',
|
||||
standalone: true,
|
||||
imports: [FormsModule, ReactiveFormsModule, NgFor, TranslateModule],
|
||||
imports: [FormsModule, ReactiveFormsModule, TranslateModule],
|
||||
})
|
||||
export class StartsWithDateComponent extends BaseComponent {
|
||||
}
|
||||
|
Reference in New Issue
Block a user