@@ -15,7 +15,7 @@ import {Directionality} from '@angular/cdk/bidi';
15
15
import { OverlayContainer } from '@angular/cdk/overlay' ;
16
16
import { ErrorStateMatcher , MatNativeDateModule } from '@angular/material/core' ;
17
17
import { MatDatepickerModule } from './datepicker-module' ;
18
- import { MatFormFieldModule } from '@angular/material/form-field' ;
18
+ import { MatFormField , MatFormFieldModule , MatLabel } from '@angular/material/form-field' ;
19
19
import { MatInputModule } from '@angular/material/input' ;
20
20
import { dispatchFakeEvent , dispatchKeyboardEvent } from '@angular/cdk/testing/private' ;
21
21
import { FocusMonitor } from '@angular/cdk/a11y' ;
@@ -26,11 +26,7 @@ import {MatStartDate, MatEndDate} from './date-range-input-parts';
26
26
import { Subscription } from 'rxjs' ;
27
27
28
28
describe ( 'MatDateRangeInput' , ( ) => {
29
- function createComponent < T > (
30
- component : Type < T > ,
31
- declarations : Type < any > [ ] = [ ] ,
32
- providers : Provider [ ] = [ ] ,
33
- ) : ComponentFixture < T > {
29
+ function createComponent < T > ( component : Type < T > , providers : Provider [ ] = [ ] ) : ComponentFixture < T > {
34
30
TestBed . configureTestingModule ( {
35
31
imports : [
36
32
FormsModule ,
@@ -40,9 +36,9 @@ describe('MatDateRangeInput', () => {
40
36
NoopAnimationsModule ,
41
37
ReactiveFormsModule ,
42
38
MatNativeDateModule ,
39
+ component ,
43
40
] ,
44
41
providers,
45
- declarations : [ component , ...declarations ] ,
46
42
} ) ;
47
43
48
44
return TestBed . createComponent ( component ) ;
@@ -818,16 +814,12 @@ describe('MatDateRangeInput', () => {
818
814
class RTL extends Directionality {
819
815
override readonly value = 'rtl' ;
820
816
}
821
- const fixture = createComponent (
822
- StandardRangePicker ,
823
- [ ] ,
824
- [
825
- {
826
- provide : Directionality ,
827
- useFactory : ( ) => new RTL ( null ) ,
828
- } ,
829
- ] ,
830
- ) ;
817
+ const fixture = createComponent ( StandardRangePicker , [
818
+ {
819
+ provide : Directionality ,
820
+ useFactory : ( ) => new RTL ( null ) ,
821
+ } ,
822
+ ] ) ;
831
823
fixture . detectChanges ( ) ;
832
824
const { start, end} = fixture . componentInstance ;
833
825
@@ -1156,6 +1148,16 @@ describe('MatDateRangeInput', () => {
1156
1148
#rangePicker></mat-date-range-picker>
1157
1149
</mat-form-field>
1158
1150
` ,
1151
+ standalone : true ,
1152
+ imports : [
1153
+ MatDateRangeInput ,
1154
+ MatStartDate ,
1155
+ MatEndDate ,
1156
+ MatFormField ,
1157
+ MatLabel ,
1158
+ MatDateRangePicker ,
1159
+ ReactiveFormsModule ,
1160
+ ] ,
1159
1161
} )
1160
1162
class StandardRangePicker {
1161
1163
@ViewChild ( 'start' ) start : ElementRef < HTMLInputElement > ;
@@ -1189,6 +1191,8 @@ class StandardRangePicker {
1189
1191
<mat-date-range-picker #rangePicker></mat-date-range-picker>
1190
1192
</mat-form-field>
1191
1193
` ,
1194
+ standalone : true ,
1195
+ imports : [ MatDateRangeInput , MatStartDate , MatEndDate , MatFormField , MatDateRangePicker ] ,
1192
1196
} )
1193
1197
class RangePickerNoStart { }
1194
1198
@@ -1202,6 +1206,8 @@ class RangePickerNoStart {}
1202
1206
<mat-date-range-picker #rangePicker></mat-date-range-picker>
1203
1207
</mat-form-field>
1204
1208
` ,
1209
+ standalone : true ,
1210
+ imports : [ MatDateRangeInput , MatStartDate , MatEndDate , MatFormField , MatDateRangePicker ] ,
1205
1211
} )
1206
1212
class RangePickerNoEnd { }
1207
1213
@@ -1216,6 +1222,15 @@ class RangePickerNoEnd {}
1216
1222
<mat-date-range-picker #rangePicker></mat-date-range-picker>
1217
1223
</mat-form-field>
1218
1224
` ,
1225
+ standalone : true ,
1226
+ imports : [
1227
+ MatDateRangeInput ,
1228
+ MatStartDate ,
1229
+ MatEndDate ,
1230
+ MatFormField ,
1231
+ MatDateRangePicker ,
1232
+ FormsModule ,
1233
+ ] ,
1219
1234
} )
1220
1235
class RangePickerNgModel {
1221
1236
@ViewChild ( MatStartDate , { read : NgModel } ) startModel : NgModel ;
@@ -1254,6 +1269,8 @@ class RangePickerNgModel {
1254
1269
<mat-date-range-picker #rangePicker></mat-date-range-picker>
1255
1270
</mat-form-field>
1256
1271
` ,
1272
+ standalone : true ,
1273
+ imports : [ MatDateRangeInput , MatStartDate , MatEndDate , MatFormField , MatDateRangePicker ] ,
1257
1274
} )
1258
1275
class RangePickerNoLabel {
1259
1276
@ViewChild ( 'start' ) start : ElementRef < HTMLInputElement > ;
@@ -1269,6 +1286,7 @@ class RangePickerNoLabel {
1269
1286
multi : true ,
1270
1287
} ,
1271
1288
] ,
1289
+ standalone : true ,
1272
1290
} )
1273
1291
class CustomValidator implements Validator {
1274
1292
validate = jasmine . createSpy ( 'validate spy' ) . and . returnValue ( null ) ;
@@ -1285,6 +1303,16 @@ class CustomValidator implements Validator {
1285
1303
<mat-date-range-picker #rangePicker></mat-date-range-picker>
1286
1304
</mat-form-field>
1287
1305
` ,
1306
+ standalone : true ,
1307
+ imports : [
1308
+ MatDateRangeInput ,
1309
+ MatStartDate ,
1310
+ MatEndDate ,
1311
+ MatFormField ,
1312
+ MatDateRangePicker ,
1313
+ CustomValidator ,
1314
+ FormsModule ,
1315
+ ] ,
1288
1316
} )
1289
1317
class RangePickerWithCustomValidator {
1290
1318
@ViewChild ( CustomValidator ) validator : CustomValidator ;
@@ -1305,6 +1333,8 @@ class RangePickerWithCustomValidator {
1305
1333
<mat-date-range-picker #rangePicker></mat-date-range-picker>
1306
1334
</mat-form-field>
1307
1335
` ,
1336
+ standalone : true ,
1337
+ imports : [ MatDateRangeInput , MatStartDate , MatEndDate , MatFormField , MatDateRangePicker ] ,
1308
1338
} )
1309
1339
class RangePickerErrorStateMatcher {
1310
1340
@ViewChild ( MatStartDate ) startInput : MatStartDate < Date > ;
0 commit comments