1
1
import { IgxDateRangeComponent } from './igx-date-range.component' ;
2
2
import { ComponentFixture , async , TestBed } from '@angular/core/testing' ;
3
- import { Component , OnInit , Optional } from '@angular/core' ;
3
+ import { Component , OnInit , ViewChild , wtfStartTimeRange , NgModule } from '@angular/core' ;
4
4
import { IgxInputGroupModule } from '../input-group/index' ;
5
- import {
6
- IgxDateRangeModule , IgxDateRangeStartDirective , IgxDateRangeEndDirective ,
7
- IgxDateRangeDirective , IgxDateRangeBaseDirective
8
- } from './index' ;
9
5
import { InteractionMode } from '../core/enums' ;
10
-
11
- describe ( 'IgxDateRangeComponent' , ( ) => {
12
- let component : IgxDateRangeComponent ;
13
- let fixture : ComponentFixture < IgxDateRangeComponent > ;
6
+ import { NoopAnimationsModule } from '@angular/platform-browser/animations' ;
7
+ import { FormsModule , ReactiveFormsModule } from '@angular/forms' ;
8
+ import { IgxIconModule } from '../icon' ;
9
+ import { IgxCalendarModule } from '../calendar/index' ;
10
+ import { IgxButtonModule } from '../directives/button/button.directive' ;
11
+ import { IgxDateRangeModule } from './igx-date-range.module' ;
12
+ import { noop } from 'rxjs' ;
13
+
14
+ // tslint:disable: no-use-before-declare
15
+ describe ( 'IgxDateRange' , ( ) => {
16
+ let singleInputRange : DateRangeTwoInputsTestComponent ;
17
+ let twoInputsRange : DateRangeTwoInputsTestComponent ;
18
+ let fixture : ComponentFixture < DateRangeTestComponent > ;
14
19
15
20
beforeEach ( async ( ( ) => {
16
21
TestBed . configureTestingModule ( {
17
- declarations : [
18
- IgxDateRangeComponent ,
19
- IgxDateRangeBaseDirective ,
20
- IgxDateRangeStartDirective ,
21
- IgxDateRangeEndDirective ,
22
- IgxDateRangeDirective
23
- ] ,
24
- imports : [
25
- IgxInputGroupModule ,
26
- IgxDateRangeModule
27
- ]
28
- } )
29
- . compileComponents ( ) ;
22
+ imports : [ DateRangeTestingModule ]
23
+ } ) . compileComponents ( ) ;
30
24
} ) ) ;
31
25
32
- beforeEach ( ( ) => {
33
- fixture = TestBed . createComponent ( IgxDateRangeComponent ) ;
34
- component = fixture . componentInstance ;
35
- fixture . detectChanges ( ) ;
36
- } ) ;
37
-
38
- describe ( 'IgxDateRange - Focus' , ( ) => {
26
+ describe ( 'Focus' , ( ) => {
39
27
it ( 'Should move focus to the calendar on open' , ( ) => {
40
28
// TODO
41
29
} ) ;
42
30
43
- it ( 'Should not change focus when the calendar is closed' , ( ) => {
44
- // TODO
45
- } ) ;
46
-
47
31
it ( 'Should move the focus to start input when "Today" is clicked and there isn\'t a value in start input' , ( ) => {
48
32
// TODO
49
33
} ) ;
@@ -57,7 +41,7 @@ describe('IgxDateRangeComponent', () => {
57
41
} ) ;
58
42
} ) ;
59
43
60
- describe ( 'IgxDateRange - API' , ( ) => {
44
+ describe ( 'API' , ( ) => {
61
45
it ( 'Should select today properly' , ( ) => {
62
46
// TODO
63
47
} ) ;
@@ -82,7 +66,7 @@ describe('IgxDateRangeComponent', () => {
82
66
} ) ;
83
67
} ) ;
84
68
85
- describe ( 'IgxDateRange - Keyboard Navigation' , ( ) => {
69
+ describe ( 'Keyboard Navigation' , ( ) => {
86
70
it ( 'Should open the calendar on mouse click' , ( ) => {
87
71
// TODO
88
72
} ) ;
@@ -100,7 +84,7 @@ describe('IgxDateRangeComponent', () => {
100
84
} ) ;
101
85
} ) ;
102
86
103
- describe ( 'IgxDateRange - Two Inputs' , ( ) => {
87
+ describe ( 'Two Inputs' , ( ) => {
104
88
it ( 'Should update the start input on first date selection' , ( ) => {
105
89
// TODO
106
90
} ) ;
@@ -126,7 +110,7 @@ describe('IgxDateRangeComponent', () => {
126
110
} ) ;
127
111
} ) ;
128
112
129
- describe ( 'IgxDateRange - Single Input' , ( ) => {
113
+ describe ( 'Single Input' , ( ) => {
130
114
/* The single input's text looks like this -> START_DATE - END_DATE */
131
115
132
116
it ( 'Should set the first part of the input properly on first date selection' , ( ) => {
@@ -153,6 +137,24 @@ describe('IgxDateRangeComponent', () => {
153
137
} ) ;
154
138
} ) ;
155
139
140
+ @Component ( {
141
+ selector : 'igx-date-range-test' ,
142
+ template : ''
143
+ } )
144
+ export class DateRangeTestComponent implements OnInit {
145
+ public todayButtonText : string ;
146
+ public doneButtonText : string ;
147
+ public mode : InteractionMode ;
148
+
149
+ @ViewChild ( IgxDateRangeComponent , { read : IgxDateRangeComponent , static : true } )
150
+ public dateRange : IgxDateRangeComponent ;
151
+
152
+ public ngOnInit ( ) : void {
153
+ this . todayButtonText = 'Today' ;
154
+ this . doneButtonText = 'Done' ;
155
+ }
156
+ }
157
+
156
158
@Component ( {
157
159
selector : 'igx-date-range-single-input-test' ,
158
160
template : `
@@ -164,34 +166,24 @@ describe('IgxDateRangeComponent', () => {
164
166
</igx-prefix>
165
167
</igx-input-group>
166
168
<igx-date-range [todayButtonText]="todayButtonText" [doneButtonText]="doneButtonText" [mode]="mode">
167
- <igx-input-group>
168
- <input #startDate igxDateRangeStart igxInput type="text">
169
- <label for="startDate" igxLabel>Check-in Date</label>
170
- <igx-prefix>
171
- <igx-icon>today</igx-icon>
172
- </igx-prefix>
173
- </igx-input-group>
174
- <igx-input-group>
175
- <input #endDate igxDateRangeEnd igxInput type="text">
176
- <label for="endDate" igxLabel>Check-out Date</label>
177
- <igx-prefix>
178
- <igx-icon>today</igx-icon>
179
- </igx-prefix>
180
- </igx-input-group>
181
- </igx-date-range>
169
+ <igx-input-group>
170
+ <input #startDate igxDateRangeStart igxInput type="text">
171
+ <label for="startDate" igxLabel>Check-in Date</label>
172
+ <igx-prefix>
173
+ <igx-icon>today</igx-icon>
174
+ </igx-prefix>
175
+ </igx-input-group>
176
+ <igx-input-group>
177
+ <input #endDate igxDateRangeEnd igxInput type="text">
178
+ <label for="endDate" igxLabel>Check-out Date</label>
179
+ <igx-prefix>
180
+ <igx-icon>today</igx-icon>
181
+ </igx-prefix>
182
+ </igx-input-group>
183
+ </igx-date-range>
182
184
`
183
185
} )
184
- export class DateRangeSingleInputTestComponent implements OnInit {
185
- public todayButtonText : string ;
186
- public doneButtonText : string ;
187
-
188
- constructor ( public mode ?: InteractionMode ) { }
189
-
190
- public ngOnInit ( ) : void {
191
- this . todayButtonText = 'Today' ;
192
- this . doneButtonText = 'Done' ;
193
- }
194
- }
186
+ export class DateRangeTwoInputsTestComponent extends DateRangeTestComponent { }
195
187
196
188
@Component ( {
197
189
selector : 'igx-date-range-two-inputs-test' ,
@@ -214,14 +206,29 @@ export class DateRangeSingleInputTestComponent implements OnInit {
214
206
</igx-date-range>
215
207
`
216
208
} )
217
- export class DateRangeTwoInputsTestComponent implements OnInit {
218
- public todayButtonText : string ;
219
- public doneButtonText : string ;
220
-
221
- constructor ( public mode ?: InteractionMode ) { }
222
-
223
- public ngOnInit ( ) : void {
224
- this . todayButtonText = 'Today' ;
225
- this . doneButtonText = 'Done' ;
226
- }
227
- }
209
+ export class DateRangeSingleInputTestComponent extends DateRangeTestComponent { }
210
+
211
+ @NgModule ( {
212
+ declarations : [
213
+ DateRangeSingleInputTestComponent ,
214
+ DateRangeTwoInputsTestComponent ,
215
+ DateRangeTestComponent
216
+ ] ,
217
+ imports : [
218
+ IgxDateRangeModule ,
219
+ NoopAnimationsModule ,
220
+ IgxInputGroupModule ,
221
+ ReactiveFormsModule ,
222
+ IgxIconModule ,
223
+ IgxCalendarModule ,
224
+ IgxButtonModule ,
225
+ IgxInputGroupModule ,
226
+ FormsModule
227
+ ] ,
228
+ exports : [
229
+ DateRangeSingleInputTestComponent ,
230
+ DateRangeTwoInputsTestComponent ,
231
+ DateRangeTestComponent
232
+ ]
233
+ } )
234
+ export class DateRangeTestingModule { }
0 commit comments