@@ -6,6 +6,7 @@ import { ProjectListHoverComponent } from './project-list-hover.component';
66import { ProjectState } from '../../../customer-management/components/projects/components/store/project.reducer' ;
77import { getCustomerProjects } from '../../../customer-management/components/projects/components/store/project.selectors' ;
88import { FilterProjectPipe } from '../../../shared/pipes' ;
9+ import { CreateEntry , UpdateActiveEntry } from '../../store/entry.actions' ;
910
1011describe ( 'ProjectListHoverComponent' , ( ) => {
1112 let component : ProjectListHoverComponent ;
@@ -53,11 +54,36 @@ describe('ProjectListHoverComponent', () => {
5354 expect ( component ) . toBeTruthy ( ) ;
5455 } ) ;
5556
56- it ( 'clock-in dispatchs a new action' , ( ) => {
57+ it ( 'clock-in dispatchs a CreateEntry action' , ( ) => {
58+ const entry = {
59+ project_id : '2b87372b-3d0d-4dc0-832b-ae5863cd39e5' ,
60+ start_date : new Date ( ) . toISOString ( ) ,
61+ } ;
62+
63+ component . activeEntry = null ;
64+ spyOn ( store , 'dispatch' ) ;
65+
66+ component . clockIn ( '2b87372b-3d0d-4dc0-832b-ae5863cd39e5' ) ;
67+
68+ expect ( store . dispatch ) . toHaveBeenCalledWith ( new CreateEntry ( entry ) ) ;
69+ } ) ;
70+
71+ it ( 'clock-in dispatchs a UpdateActiveEntry action' , ( ) => {
72+ const entry = {
73+ id : '123' ,
74+ project_id : '2b87372b-3d0d-4dc0-832b-ae5863cd39e5' ,
75+ start_date : new Date ( ) . toISOString ( ) ,
76+ } ;
77+ const updatedEntry = {
78+ id : '123' ,
79+ project_id : '123372b-3d0d-4dc0-832b-ae5863cd39e5' ,
80+ } ;
81+
82+ component . activeEntry = entry ;
5783 spyOn ( store , 'dispatch' ) ;
5884
59- component . clockIn ( 'id ' ) ;
85+ component . clockIn ( '123372b-3d0d-4dc0-832b-ae5863cd39e5 ' ) ;
6086
61- expect ( store . dispatch ) . toHaveBeenCalled ( ) ;
87+ expect ( store . dispatch ) . toHaveBeenCalledWith ( new UpdateActiveEntry ( updatedEntry ) ) ;
6288 } ) ;
6389} ) ;
0 commit comments