1
1
import { ComponentFixture , TestBed } from '@angular/core/testing' ;
2
2
import { FormsModule , ReactiveFormsModule } from '@angular/forms' ;
3
3
import { FaIconComponent } from '@fortawesome/angular-fontawesome' ;
4
- import { TranslateService } from '@ngx-translate/core' ;
5
4
import { AttachmentUnitFormComponent , AttachmentUnitFormData } from 'app/lecture/lecture-unit/lecture-unit-management/attachment-unit-form/attachment-unit-form.component' ;
6
5
import { FormDateTimePickerComponent } from 'app/shared/date-time-picker/date-time-picker.component' ;
7
6
import { ArtemisTranslatePipe } from 'app/shared/pipes/artemis-translate.pipe' ;
8
7
import dayjs from 'dayjs/esm' ;
9
- import { MockComponent , MockDirective , MockPipe , MockProviders } from 'ng-mocks' ;
8
+ import { MockComponent , MockDirective , MockPipe } from 'ng-mocks' ;
10
9
import { NgbTooltip } from '@ng-bootstrap/ng-bootstrap' ;
11
10
import { CompetencySelectionComponent } from 'app/shared/competency-selection/competency-selection.component' ;
12
11
import { MAX_FILE_SIZE } from 'app/shared/constants/input.constants' ;
@@ -25,7 +24,6 @@ describe('AttachmentUnitFormComponent', () => {
25
24
MockComponent ( FaIconComponent ) ,
26
25
MockComponent ( CompetencySelectionComponent ) ,
27
26
] ,
28
- providers : [ MockProviders ( TranslateService ) ] ,
29
27
schemas : [ ] ,
30
28
} )
31
29
. compileComponents ( )
@@ -71,7 +69,7 @@ describe('AttachmentUnitFormComponent', () => {
71
69
expect ( attachmentUnitFormComponent . descriptionControl ?. value ) . toEqual ( formData . formProperties . description ) ;
72
70
expect ( attachmentUnitFormComponent . versionControl ?. value ) . toEqual ( formData . formProperties . version ) ;
73
71
expect ( attachmentUnitFormComponent . updateNotificationTextControl ?. value ) . toEqual ( formData . formProperties . updateNotificationText ) ;
74
- expect ( attachmentUnitFormComponent . fileName ) . toEqual ( formData . fileProperties . fileName ) ;
72
+ expect ( attachmentUnitFormComponent . fileName ( ) ) . toEqual ( formData . fileProperties . fileName ) ;
75
73
expect ( attachmentUnitFormComponent . file ) . toEqual ( formData . fileProperties . file ) ;
76
74
} ) ;
77
75
it ( 'should submit valid form' , ( ) => {
@@ -90,7 +88,7 @@ describe('AttachmentUnitFormComponent', () => {
90
88
const fakeFile = new File ( [ '' ] , 'Test-File.pdf' , { type : 'application/pdf' } ) ;
91
89
attachmentUnitFormComponent . file = fakeFile ;
92
90
const exampleFileName = 'lorem Ipsum' ;
93
- attachmentUnitFormComponent . fileName = exampleFileName ;
91
+ attachmentUnitFormComponent . fileName . set ( exampleFileName ) ;
94
92
95
93
attachmentUnitFormComponentFixture . detectChanges ( ) ;
96
94
expect ( attachmentUnitFormComponent . form . valid ) . toBeTrue ( ) ;
@@ -132,7 +130,7 @@ describe('AttachmentUnitFormComponent', () => {
132
130
attachmentUnitFormComponent . updateNotificationTextControl ! . setValue ( exampleUpdateNotificationText ) ;
133
131
const fakeFile = new File ( [ '' ] , 'Test-File.pdf' , { type : 'application/pdf' } ) ;
134
132
attachmentUnitFormComponent . file = fakeFile ;
135
- attachmentUnitFormComponent . fileName = 'lorem Ipsum' ;
133
+ attachmentUnitFormComponent . fileName . set ( 'lorem Ipsum' ) ;
136
134
137
135
expect ( attachmentUnitFormComponent . form . invalid ) . toBeTrue ( ) ;
138
136
const submitFormSpy = jest . spyOn ( attachmentUnitFormComponent , 'submitForm' ) ;
@@ -166,7 +164,7 @@ describe('AttachmentUnitFormComponent', () => {
166
164
attachmentUnitFormComponentFixture . detectChanges ( ) ;
167
165
168
166
const submitButton = attachmentUnitFormComponentFixture . debugElement . nativeElement . querySelector ( '#submitButton' ) ;
169
- expect ( attachmentUnitFormComponent . isFileTooBig ) . toBeTrue ( ) ;
167
+ expect ( attachmentUnitFormComponent . isFileTooBig ( ) ) . toBeTrue ( ) ;
170
168
expect ( submitButton . disabled ) . toBeTrue ( ) ;
171
169
} ) ;
172
170
} ) ;
0 commit comments