@@ -9,12 +9,6 @@ describe('TimeClockComponent', () => {
9
9
let fixture : ComponentFixture < TimeClockComponent > ;
10
10
let de : DebugElement ;
11
11
12
- function setup ( ) {
13
- const fixture = TestBed . createComponent ( TimeClockComponent ) ;
14
- const app = fixture . debugElement . componentInstance ;
15
- return { fixture, app } ;
16
- }
17
-
18
12
beforeEach ( async ( ( ) => {
19
13
TestBed . configureTestingModule ( {
20
14
declarations : [ TimeClockComponent , ProjectListHoverComponent ]
@@ -32,14 +26,6 @@ describe('TimeClockComponent', () => {
32
26
expect ( component ) . toBeTruthy ( ) ;
33
27
} ) ;
34
28
35
- it ( 'should have p tag as \'Dario clocked out at 00:00:00\'' , async ( ( ) => {
36
- const { fixture } = setup ( ) ;
37
- fixture . detectChanges ( ) ;
38
- const compile = fixture . debugElement . nativeElement ;
39
- const ptag = compile . querySelector ( 'p' ) ;
40
- expect ( ptag . textContent ) . toBe ( 'Dario clocked out at 00:00:00' ) ;
41
- } ) ) ;
42
-
43
29
it ( 'should set showfileds as true' , ( ) => {
44
30
const show = true ;
45
31
component . setShowFields ( show ) ;
@@ -62,33 +48,67 @@ describe('TimeClockComponent', () => {
62
48
expect ( component . setShowFields ) . toHaveBeenCalledWith ( true ) ;
63
49
} ) ;
64
50
65
- it ( 'should have button text as Options ' , async ( ( ) => {
66
- const { fixture } = setup ( ) ;
67
- fixture . detectChanges ( ) ;
68
- const x = document . getElementById ( 'optionsContainer' ) ;
69
- const ptag = x . querySelector ( 'button' ) ;
70
- expect ( ptag . textContent ) . toBe ( ' Options ' ) ;
71
- } ) ) ;
51
+ it ( 'should internt methods employeClockIn called ' , ( ) => {
52
+ spyOn ( component , 'startTimer' ) ;
53
+ spyOn ( component , 'setArrivalAndDepartureTimes' ) ;
54
+
55
+ component . employeClockIn ( ) ;
56
+ expect ( component . startTimer ) . toHaveBeenCalled ( ) ;
57
+ expect ( component . setArrivalAndDepartureTimes ) . toHaveBeenCalled ( ) ;
72
58
73
- it ( 'should set Clock In' , ( ) => {
74
- const { fixture } = setup ( ) ;
75
- fixture . detectChanges ( ) ;
76
- const x = document . getElementById ( 'clockInOutContainer' ) ;
77
- const ptag = x . querySelector ( 'button' ) ;
78
- expect ( ptag . textContent ) . toBe ( 'Clock In' ) ;
79
59
} ) ;
80
60
61
+ it ( 'called intern method setArrivalAndDepartureTimes' , ( ) => {
62
+ const show = true ;
63
+
64
+ component . isClockInEnable = false ;
65
+ component . execOnlyOneTimeCounter = true ;
66
+
67
+ spyOn ( component , 'setArrivalAndDepartureTimes' ) ;
68
+ spyOn ( component , 'startTimer' ) ;
69
+ component . setShowFields ( show ) ;
70
+
71
+ expect ( component . showFields ) . toBe ( true ) ;
72
+ expect ( component . setArrivalAndDepartureTimes ) . toHaveBeenCalled ( ) ;
73
+ expect ( component . startTimer ) . not . toHaveBeenCalled ( ) ;
74
+ } ) ;
75
+
76
+ it ( 'called intern methods of employeClockOut ' , ( ) => {
77
+ component . isEnterTechnology = true ;
78
+
79
+ spyOn ( component , 'setDefaultValuesToFields' ) ;
80
+ spyOn ( component , 'pauseTimer' ) ;
81
+ spyOn ( component , 'setArrivalAndDepartureTimes' ) ;
82
+
83
+ component . employeClockOut ( ) ;
84
+
85
+ expect ( component . setArrivalAndDepartureTimes ) . toHaveBeenCalled ( ) ;
86
+ expect ( component . pauseTimer ) . toHaveBeenCalled ( ) ;
87
+ expect ( component . setArrivalAndDepartureTimes ) . toHaveBeenCalled ( ) ;
88
+ } ) ;
89
+
90
+
91
+ it ( 'not called intern methods of employeClockOut ' , ( ) => {
92
+ component . isEnterTechnology = false ;
93
+
94
+ spyOn ( component , 'setDefaultValuesToFields' ) ;
95
+ spyOn ( component , 'pauseTimer' ) ;
96
+ spyOn ( component , 'setArrivalAndDepartureTimes' ) ;
97
+
98
+ component . employeClockOut ( ) ;
99
+
100
+ expect ( component . setArrivalAndDepartureTimes ) . not . toHaveBeenCalled ( ) ;
101
+ expect ( component . pauseTimer ) . not . toHaveBeenCalled ( ) ;
102
+ expect ( component . setArrivalAndDepartureTimes ) . not . toHaveBeenCalled ( ) ;
103
+ } ) ;
104
+
105
+
81
106
it ( 'should setVartToEmpty called' , ( ) => {
82
107
spyOn ( component , 'setDefaultValuesToFields' ) ;
83
108
component . setDefaultValuesToFields ( ) ;
84
109
expect ( component . setDefaultValuesToFields ) . toHaveBeenCalled ( ) ;
85
110
} ) ;
86
111
87
- it ( 'should employeClockIn called' , ( ) => {
88
- spyOn ( component , 'employeClockIn' ) ;
89
- component . employeClockIn ( ) ;
90
- expect ( component . employeClockIn ) . toHaveBeenCalled ( ) ;
91
- } ) ;
92
112
93
113
it ( 'should employeClockOut called' , ( ) => {
94
114
spyOn ( component , 'employeClockOut' ) ;
@@ -103,3 +123,5 @@ describe('TimeClockComponent', () => {
103
123
} ) ;
104
124
105
125
} ) ;
126
+
127
+
0 commit comments