@@ -8,7 +8,7 @@ import { IgxLabelDirective } from '../directives/label/label.directive';
88import { IgxInputDirective } from '../directives/input/input.directive' ;
99import { UIInteractions , wait } from '../test-utils/ui-interactions.spec' ;
1010import { IgxInputGroupModule } from '../input-group' ;
11-
11+ import { IgxTextSelectionModule } from '../directives/text-selection/text-selection.directive' ;
1212import { configureTestSuite } from '../test-utils/configure-suite' ;
1313import { DateRangeType } from 'igniteui-angular' ;
1414import { IgxButtonModule } from '../directives/button/button.directive' ;
@@ -32,7 +32,8 @@ describe('IgxDatePicker', () => {
3232 IgxDropDownDatePickerRetemplatedComponent ,
3333 IgxDatePickerOpeningComponent
3434 ] ,
35- imports : [ IgxDatePickerModule , FormsModule , NoopAnimationsModule , IgxInputGroupModule , IgxCalendarModule , IgxButtonModule ]
35+ imports : [ IgxDatePickerModule , FormsModule , NoopAnimationsModule , IgxInputGroupModule , IgxCalendarModule ,
36+ IgxButtonModule , IgxTextSelectionModule ]
3637 } )
3738 . compileComponents ( ) ;
3839 } ) ) ;
@@ -1089,6 +1090,29 @@ describe('IgxDatePicker', () => {
10891090 expect ( instance . getEditElement ( ) ) . toBe ( editElement ) ;
10901091 } ) ;
10911092 } ) ;
1093+
1094+ describe ( 'Drop-down mode select all text on focus' , ( ) => {
1095+ let fixture : ComponentFixture < IgxDatePickerOpeningComponent > ;
1096+ let datePicker : IgxDatePickerComponent ;
1097+
1098+ beforeEach ( ( ) => {
1099+ fixture = TestBed . createComponent ( IgxDatePickerOpeningComponent ) ;
1100+ datePicker = fixture . componentInstance . datePicker ;
1101+ fixture . detectChanges ( ) ;
1102+ } ) ;
1103+
1104+ it ( 'Should select all input text on input focus' , async ( ) => {
1105+ const input = fixture . debugElement . query ( By . directive ( IgxInputDirective ) ) . nativeElement ;
1106+ input . focus ( ) ;
1107+ fixture . detectChanges ( ) ;
1108+ await wait ( 100 ) ;
1109+
1110+ expect ( input ) . toEqual ( document . activeElement ) ;
1111+ expect ( input . selectionEnd ) . toEqual ( input . value . length ) ;
1112+ expect ( input . selectionStart ) . toEqual ( 0 ) ;
1113+ expect ( input . value . substring ( input . selectionStart , input . selectionEnd ) ) . toEqual ( input . value ) ;
1114+ } ) ;
1115+ } ) ;
10921116} ) ;
10931117
10941118@Component ( {
@@ -1228,9 +1252,10 @@ export class IgxDatePickerCustomizedComponent {
12281252@Component ( {
12291253 template :
12301254 `
1231- <igx-date-picker mode="dropdown"></igx-date-picker>
1255+ <igx-date-picker mode="dropdown" [value]="date" ></igx-date-picker>
12321256 `
12331257} )
12341258export class IgxDatePickerOpeningComponent {
12351259 @ViewChild ( IgxDatePickerComponent , { static : true } ) public datePicker : IgxDatePickerComponent ;
1260+ public date = new Date ( 2017 , 7 , 7 ) ;
12361261}
0 commit comments