1
1
import { TimePickerComponent } from './timePicker.component' ;
2
- import { beforeEach , describe , expect , it } from '@angular/core/testing/src/testing_internal' ;
3
2
4
3
describe ( 'a timePicker component' , ( ) => {
5
4
let timePickerComponent : TimePickerComponent ;
6
5
let mockDateService : any ;
6
+ let eRef : any ;
7
+
7
8
// register all needed dependencies
8
9
beforeEach ( ( ) => {
9
10
// @ts -ignore
10
11
mockDateService = jasmine . createSpyObj ( 'mockDateService' , [ 'getDateList' , 'getMonths' , 'getAvailableYears' ] ) ;
11
12
12
13
mockDateService . getDateList . and . returnValue ( [ ] ) ;
13
- timePickerComponent = new TimePickerComponent ( < any > { } , mockDateService ) ;
14
+ timePickerComponent = new TimePickerComponent ( < any > { } , mockDateService , eRef ) ;
14
15
} ) ;
15
16
16
17
it ( 'should have an instance' , ( ) => {
@@ -41,7 +42,9 @@ describe('a timePicker component', () => {
41
42
it ( 'should set the selected hour and minute to now' , ( ) => {
42
43
const now = new Date ( ) ;
43
44
44
- timePickerComponent . setTimeToNow ( ) ;
45
+ timePickerComponent . setHourNow ( now . getHours ( ) ) ;
46
+ timePickerComponent . setMinuteNow ( now . getMinutes ( ) ) ;
47
+ timePickerComponent . mobileFormattedTime ;
45
48
46
49
expect ( timePickerComponent . selectedHour ) . toBe ( now . getHours ( ) ) ;
47
50
expect ( timePickerComponent . selectedMinute ) . toBe ( now . getMinutes ( ) ) ;
@@ -59,10 +62,9 @@ describe('a timePicker component', () => {
59
62
timePickerComponent . setHourNow ( 6 ) ;
60
63
timePickerComponent . mobileFormattedTime ;
61
64
62
-
63
65
expect ( timePickerComponent . selectedHour ) . toBe ( 6 ) ;
64
66
expect ( timePickerComponent . selectedMinute ) . toBe ( 15 ) ;
65
- expect ( timePickerComponent . selectedTime ) . toBe ( '6:15 pm ' ) ;
67
+ expect ( timePickerComponent . selectedTime ) . toBe ( '6:15 am ' ) ;
66
68
} ) ;
67
69
68
70
it ( 'should set the selected minute accordingly, upon user select' , ( ) => {
@@ -74,6 +76,6 @@ describe('a timePicker component', () => {
74
76
75
77
expect ( timePickerComponent . selectedHour ) . toBe ( 4 ) ;
76
78
expect ( timePickerComponent . selectedMinute ) . toBe ( 30 ) ;
77
- expect ( timePickerComponent . selectedTime ) . toBe ( '4:30 pm ' ) ;
79
+ expect ( timePickerComponent . selectedTime ) . toBe ( '4:30 am ' ) ;
78
80
} ) ;
79
81
} ) ;
0 commit comments