Skip to content

Commit 2f811a5

Browse files
Fix client tests
1 parent 3fa86a3 commit 2f811a5

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

src/main/webapp/app/lecture/lecture-unit/lecture-unit-management/attachment-unit-form/attachment-unit-form.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import dayjs from 'dayjs/esm';
33
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
44
import { faQuestionCircle, faTimes } from '@fortawesome/free-solid-svg-icons';
55
import { ACCEPTED_FILE_EXTENSIONS_FILE_BROWSER, ALLOWED_FILE_EXTENSIONS_HUMAN_READABLE } from 'app/shared/constants/file-extensions.constants';
6-
import { Competency, CompetencyLectureUnitLink } from 'app/entities/competency.model';
6+
import { CompetencyLectureUnitLink } from 'app/entities/competency.model';
77
import { MAX_FILE_SIZE } from 'app/shared/constants/input.constants';
88
import { toSignal } from '@angular/core/rxjs-interop';
99

@@ -62,7 +62,7 @@ export class AttachmentUnitFormComponent implements OnChanges {
6262
releaseDate: [undefined as dayjs.Dayjs | undefined],
6363
version: [{ value: 1, disabled: true }],
6464
updateNotificationText: [undefined as string | undefined, [Validators.maxLength(1000)]],
65-
competencies: [undefined as Competency[] | undefined],
65+
competencyLinks: [undefined as CompetencyLectureUnitLink[] | undefined],
6666
});
6767
private readonly statusChanges = toSignal(this.form.statusChanges ?? 'INVALID');
6868

src/test/javascript/spec/component/lecture-unit/attachment-unit/attachment-unit-form.component.spec.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import { ComponentFixture, TestBed } from '@angular/core/testing';
22
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
33
import { FaIconComponent } from '@fortawesome/angular-fontawesome';
4-
import { TranslateService } from '@ngx-translate/core';
54
import { AttachmentUnitFormComponent, AttachmentUnitFormData } from 'app/lecture/lecture-unit/lecture-unit-management/attachment-unit-form/attachment-unit-form.component';
65
import { FormDateTimePickerComponent } from 'app/shared/date-time-picker/date-time-picker.component';
76
import { ArtemisTranslatePipe } from 'app/shared/pipes/artemis-translate.pipe';
87
import dayjs from 'dayjs/esm';
9-
import { MockComponent, MockDirective, MockPipe, MockProviders } from 'ng-mocks';
8+
import { MockComponent, MockDirective, MockPipe } from 'ng-mocks';
109
import { NgbTooltip } from '@ng-bootstrap/ng-bootstrap';
1110
import { CompetencySelectionComponent } from 'app/shared/competency-selection/competency-selection.component';
1211
import { MAX_FILE_SIZE } from 'app/shared/constants/input.constants';
@@ -25,7 +24,6 @@ describe('AttachmentUnitFormComponent', () => {
2524
MockComponent(FaIconComponent),
2625
MockComponent(CompetencySelectionComponent),
2726
],
28-
providers: [MockProviders(TranslateService)],
2927
schemas: [],
3028
})
3129
.compileComponents()
@@ -71,7 +69,7 @@ describe('AttachmentUnitFormComponent', () => {
7169
expect(attachmentUnitFormComponent.descriptionControl?.value).toEqual(formData.formProperties.description);
7270
expect(attachmentUnitFormComponent.versionControl?.value).toEqual(formData.formProperties.version);
7371
expect(attachmentUnitFormComponent.updateNotificationTextControl?.value).toEqual(formData.formProperties.updateNotificationText);
74-
expect(attachmentUnitFormComponent.fileName).toEqual(formData.fileProperties.fileName);
72+
expect(attachmentUnitFormComponent.fileName()).toEqual(formData.fileProperties.fileName);
7573
expect(attachmentUnitFormComponent.file).toEqual(formData.fileProperties.file);
7674
});
7775
it('should submit valid form', () => {
@@ -90,7 +88,7 @@ describe('AttachmentUnitFormComponent', () => {
9088
const fakeFile = new File([''], 'Test-File.pdf', { type: 'application/pdf' });
9189
attachmentUnitFormComponent.file = fakeFile;
9290
const exampleFileName = 'lorem Ipsum';
93-
attachmentUnitFormComponent.fileName = exampleFileName;
91+
attachmentUnitFormComponent.fileName.set(exampleFileName);
9492

9593
attachmentUnitFormComponentFixture.detectChanges();
9694
expect(attachmentUnitFormComponent.form.valid).toBeTrue();
@@ -132,7 +130,7 @@ describe('AttachmentUnitFormComponent', () => {
132130
attachmentUnitFormComponent.updateNotificationTextControl!.setValue(exampleUpdateNotificationText);
133131
const fakeFile = new File([''], 'Test-File.pdf', { type: 'application/pdf' });
134132
attachmentUnitFormComponent.file = fakeFile;
135-
attachmentUnitFormComponent.fileName = 'lorem Ipsum';
133+
attachmentUnitFormComponent.fileName.set('lorem Ipsum');
136134

137135
expect(attachmentUnitFormComponent.form.invalid).toBeTrue();
138136
const submitFormSpy = jest.spyOn(attachmentUnitFormComponent, 'submitForm');
@@ -166,7 +164,7 @@ describe('AttachmentUnitFormComponent', () => {
166164
attachmentUnitFormComponentFixture.detectChanges();
167165

168166
const submitButton = attachmentUnitFormComponentFixture.debugElement.nativeElement.querySelector('#submitButton');
169-
expect(attachmentUnitFormComponent.isFileTooBig).toBeTrue();
167+
expect(attachmentUnitFormComponent.isFileTooBig()).toBeTrue();
170168
expect(submitButton.disabled).toBeTrue();
171169
});
172170
});

0 commit comments

Comments
 (0)