@@ -9,12 +9,6 @@ describe('TimeClockComponent', () => {
99 let fixture : ComponentFixture < TimeClockComponent > ;
1010 let de : DebugElement ;
1111
12- function setup ( ) {
13- const fixture = TestBed . createComponent ( TimeClockComponent ) ;
14- const app = fixture . debugElement . componentInstance ;
15- return { fixture, app } ;
16- }
17-
1812 beforeEach ( async ( ( ) => {
1913 TestBed . configureTestingModule ( {
2014 declarations : [ TimeClockComponent , ProjectListHoverComponent ]
@@ -32,14 +26,6 @@ describe('TimeClockComponent', () => {
3226 expect ( component ) . toBeTruthy ( ) ;
3327 } ) ;
3428
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-
4329 it ( 'should set showfileds as true' , ( ) => {
4430 const show = true ;
4531 component . setShowFields ( show ) ;
@@ -62,33 +48,67 @@ describe('TimeClockComponent', () => {
6248 expect ( component . setShowFields ) . toHaveBeenCalledWith ( true ) ;
6349 } ) ;
6450
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 ( ) ;
7258
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' ) ;
7959 } ) ;
8060
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+
81106 it ( 'should setVartToEmpty called' , ( ) => {
82107 spyOn ( component , 'setDefaultValuesToFields' ) ;
83108 component . setDefaultValuesToFields ( ) ;
84109 expect ( component . setDefaultValuesToFields ) . toHaveBeenCalled ( ) ;
85110 } ) ;
86111
87- it ( 'should employeClockIn called' , ( ) => {
88- spyOn ( component , 'employeClockIn' ) ;
89- component . employeClockIn ( ) ;
90- expect ( component . employeClockIn ) . toHaveBeenCalled ( ) ;
91- } ) ;
92112
93113 it ( 'should employeClockOut called' , ( ) => {
94114 spyOn ( component , 'employeClockOut' ) ;
@@ -103,3 +123,5 @@ describe('TimeClockComponent', () => {
103123 } ) ;
104124
105125} ) ;
126+
127+
0 commit comments