@@ -7,6 +7,7 @@ import { ProjectListHoverComponent } from './project-list-hover.component';
77import { ProjectState } from '../../../customer-management/components/projects/components/store/project.reducer' ;
88import { getCustomerProjects } from '../../../customer-management/components/projects/components/store/project.selectors' ;
99import { FilterProjectPipe } from '../../../shared/pipes' ;
10+ import { CreateEntry , UpdateActiveEntry } from '../../store/entry.actions' ;
1011
1112describe ( 'ProjectListHoverComponent' , ( ) => {
1213 let component : ProjectListHoverComponent ;
@@ -58,12 +59,37 @@ describe('ProjectListHoverComponent', () => {
5859 expect ( component ) . toBeTruthy ( ) ;
5960 } ) ;
6061
61- it ( 'clock-in dispatchs a new action' , ( ) => {
62+ it ( 'clock-in dispatchs a CreateEntry action' , ( ) => {
63+ const entry = {
64+ project_id : '2b87372b-3d0d-4dc0-832b-ae5863cd39e5' ,
65+ start_date : new Date ( ) . toISOString ( ) ,
66+ } ;
67+
68+ component . activeEntry = null ;
69+ spyOn ( store , 'dispatch' ) ;
70+
71+ component . clockIn ( '2b87372b-3d0d-4dc0-832b-ae5863cd39e5' ) ;
72+
73+ expect ( store . dispatch ) . toHaveBeenCalledWith ( new CreateEntry ( entry ) ) ;
74+ } ) ;
75+
76+ it ( 'clock-in dispatchs a UpdateActiveEntry action' , ( ) => {
77+ const entry = {
78+ id : '123' ,
79+ project_id : '2b87372b-3d0d-4dc0-832b-ae5863cd39e5' ,
80+ start_date : new Date ( ) . toISOString ( ) ,
81+ } ;
82+ const updatedEntry = {
83+ id : '123' ,
84+ project_id : '123372b-3d0d-4dc0-832b-ae5863cd39e5' ,
85+ } ;
86+
87+ component . activeEntry = entry ;
6288 spyOn ( store , 'dispatch' ) ;
6389
64- component . clockIn ( 'id ' ) ;
90+ component . clockIn ( '123372b-3d0d-4dc0-832b-ae5863cd39e5 ' ) ;
6591
66- expect ( store . dispatch ) . toHaveBeenCalled ( ) ;
92+ expect ( store . dispatch ) . toHaveBeenCalledWith ( new UpdateActiveEntry ( updatedEntry ) ) ;
6793 } ) ;
6894
6995} ) ;
0 commit comments