Skip to content

Commit b1eb4a8

Browse files
[DURACOM-307] fix tests
1 parent dc70ec0 commit b1eb4a8

8 files changed

Lines changed: 26 additions & 28 deletions

File tree

src/app/shared/context-help-wrapper/context-help-wrapper.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
@if (elem.href) {
55
<a href="{{elem.href}}" target="_blank" rel="noopener noreferrer">{{elem.text}}</a>
66
} @else {
7-
{{ elem }}
7+
{{ elem.text }}
88
}
99
}
1010
</div>

src/app/shared/context-help-wrapper/context-help-wrapper.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export class ContextHelpWrapperComponent implements OnInit, OnDestroy {
8484
@Input() set content(translateKey: string) {
8585
this.content$.next(translateKey);
8686
}
87-
private content$: BehaviorSubject<string | undefined> = new BehaviorSubject(undefined);
87+
private content$: BehaviorSubject<string> = new BehaviorSubject(null);
8888

8989
parsedContent$: Observable<ParsedContent>;
9090

@@ -100,7 +100,7 @@ export class ContextHelpWrapperComponent implements OnInit, OnDestroy {
100100
this.content$.pipe(distinctUntilChanged(), mergeMap(translateKey => this.translateService.get(translateKey))),
101101
this.dontParseLinks$.pipe(distinctUntilChanged()),
102102
]).pipe(
103-
map(([text, dontParseLinks]) =>
103+
map(([text, dontParseLinks]: [string, boolean]) =>
104104
dontParseLinks ? [{ text }] : this.parseLinks(text)),
105105
);
106106
this.shouldShowIcon$ = this.contextHelpService.shouldShowIcons$();

src/app/shared/dso-selector/modal-wrappers/dso-selector-modal-wrapper.component.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { NgIf } from '@angular/common';
21
import {
32
Component,
43
DebugElement,
@@ -164,7 +163,6 @@ describe('DSOSelectorModalWrapperComponent', () => {
164163
templateUrl: './dso-selector-modal-wrapper.component.html',
165164
imports: [
166165
DSOSelectorComponent,
167-
NgIf,
168166
TranslateModule,
169167
],
170168
standalone: true,

src/app/shared/form/chips/chips.component.spec.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,12 @@ describe('ChipsComponent test suite', () => {
5959
// synchronous beforeEach
6060
beforeEach(() => {
6161
html = `
62-
<ds-chips
63-
*ngIf="chips.hasItems()"
64-
[chips]="chips"
65-
[editable]="editable"
66-
(selected)="onChipSelected($event)"></ds-chips>`;
62+
@if(chips.hasItems()) {
63+
<ds-chips
64+
[chips]="chips"
65+
[editable]="editable"
66+
(selected)="onChipSelected($event)"></ds-chips>
67+
}`;
6768

6869
testFixture = createTestComponent(html, TestComponent) as ComponentFixture<TestComponent>;
6970
testComp = testFixture.componentInstance;

src/app/shared/form/form.component.spec.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,13 @@ describe('FormComponent test suite', () => {
195195
// synchronous beforeEach
196196
beforeEach(() => {
197197
html = `
198-
<ds-form *ngIf="formModel" #formRef="formComponent"
198+
@if('formModel') {
199+
<ds-form #formRef="formComponent"
199200
[formId]="formId"
200201
[formModel]="formModel"
201202
[displaySubmit]="displaySubmit"
202-
[displayCancel]="displayCancel"></ds-form>`;
203+
[displayCancel]="displayCancel"></ds-form>
204+
}`;
203205

204206
testFixture = createTestComponent(html, TestComponent) as ComponentFixture<TestComponent>;
205207
testComp = testFixture.componentInstance;

src/app/shared/orcid-badge-and-tooltip/orcid-badge-and-tooltip.component.spec.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
import {
2-
NgClass,
3-
NgIf,
4-
} from '@angular/common';
1+
import { NgClass } from '@angular/common';
52
import {
63
ComponentFixture,
74
TestBed,
@@ -24,7 +21,6 @@ describe('OrcidBadgeAndTooltipComponent', () => {
2421
OrcidBadgeAndTooltipComponent,
2522
NgbTooltipModule,
2623
NgClass,
27-
NgIf,
2824
],
2925
providers: [
3026
{ provide: TranslateService, useValue: { instant: (key: string) => key } },

src/app/submission/sections/duplicates/section-duplicates.component.spec.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import {
66
} from '@angular/core';
77
import {
88
ComponentFixture,
9+
fakeAsync,
910
TestBed,
11+
tick,
1012
waitForAsync,
1113
} from '@angular/core/testing';
1214
import {
@@ -210,6 +212,11 @@ describe('SubmissionSectionDuplicatesComponent test suite', () => {
210212
formOperationsService = TestBed.inject(SectionFormOperationsService);
211213
collectionDataService = TestBed.inject(CollectionDataService);
212214
compAsAny.pathCombiner = new JsonPatchOperationPathCombiner('sections', sectionObject.id);
215+
spyOn(comp, 'getDuplicateData').and.returnValue(observableOf({ potentialDuplicates: duplicates }));
216+
collectionDataService.findById.and.returnValue(createSuccessfulRemoteDataObject$(mockCollection));
217+
sectionsServiceStub.getSectionErrors.and.returnValue(observableOf([]));
218+
sectionsServiceStub.isSectionReadOnly.and.returnValue(observableOf(false));
219+
compAsAny.submissionService.getSubmissionScope.and.returnValue(SubmissionScopeType.WorkspaceItem);
213220
});
214221

215222
afterEach(() => {
@@ -219,18 +226,13 @@ describe('SubmissionSectionDuplicatesComponent test suite', () => {
219226
});
220227

221228
// Test initialisation of the submission section
222-
it('Should init section properly', () => {
223-
collectionDataService.findById.and.returnValue(createSuccessfulRemoteDataObject$(mockCollection));
224-
sectionsServiceStub.getSectionErrors.and.returnValue(observableOf([]));
225-
sectionsServiceStub.isSectionReadOnly.and.returnValue(observableOf(false));
226-
compAsAny.submissionService.getSubmissionScope.and.returnValue(SubmissionScopeType.WorkspaceItem);
229+
it('Should init section properly', fakeAsync(() => {
227230
spyOn(comp, 'getSectionStatus').and.returnValue(observableOf(true));
228-
spyOn(comp, 'getDuplicateData').and.returnValue(observableOf({ potentialDuplicates: duplicates }));
229231
expect(comp.isLoading).toBeTruthy();
230232
comp.onSectionInit();
231-
fixture.detectChanges();
233+
tick(100);
232234
expect(comp.isLoading).toBeFalsy();
233-
});
235+
}));
234236

235237
// The following tests look for proper logic in the getSectionStatus() implementation
236238
// 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', () => {
241243
}));
242244
});
243245
it('Should return FALSE', () => {
244-
compAsAny.isLoadin = true;
246+
compAsAny.isLoading = true;
245247
expect(compAsAny.getSectionStatus()).toBeObservable(cold('(a|)', {
246248
a: false,
247249
}));

src/themes/custom/app/shared/starts-with/date/starts-with-date.component.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { NgFor } from '@angular/common';
21
import { Component } from '@angular/core';
32
import {
43
FormsModule,
@@ -15,7 +14,7 @@ import { StartsWithDateComponent as BaseComponent } from '../../../../../../app/
1514
// templateUrl: './starts-with-date.component.html',
1615
templateUrl: '../../../../../../app/shared/starts-with/date/starts-with-date.component.html',
1716
standalone: true,
18-
imports: [FormsModule, ReactiveFormsModule, NgFor, TranslateModule],
17+
imports: [FormsModule, ReactiveFormsModule, TranslateModule],
1918
})
2019
export class StartsWithDateComponent extends BaseComponent {
2120
}

0 commit comments

Comments
 (0)